Pull from Home Assistant (HA SSI Publisher)¶
Build a minimal setup that receives Home Assistant state over MQTT and decides whether to share it with a consent JSON (equivalent to a Consent VC).
What you'll do: MQTT → publisher → consent check → audit log
Prerequisites: Prerequisites (install tools), ideally Run the whole pipeline without hardware (HA Demo Simulator). The Quickstart (run the stack) stack is not used
Keep running: nothing needs to be running. This page starts the publisher. If IPFS from Quickstart is running, stop it first (see Required environment below)
What you need: PC (Docker)
Time required: approx. 45 min
Where this page belongs
- This is section 1.2 of Part 1 (Hands-on). Pick just one of the three pages in 1.2.
- The "Next" link at the bottom of the page points to the optional §1.4 phone page. Follow this page's Next steps section instead.
- "Phase 1–3" on this page are development stages of the platform, not the learning order (Hands-on).
- Previous page: Run the whole pipeline without hardware (HA Demo Simulator)
- Next page: Quickstart (run the stack), then section 1.3 of Hands-on (trade on the marketplace)
Goal¶
This covers a minimal setup that receives Home Assistant data via MQTT,
decides whether to allow it with a consent JSON, then forwards only allowed data and records audit logs.
The consent JSON is equivalent to a Consent VC, but it is registered directly at /consents and no VC signature is verified. You first receive and present a VC in a wallet in Authenticate the data provider (Consent VC / Stage 1) in Part 2.
Pipeline:
Home Assistant -> MQTT -> (optional Node-RED) -> Data Publisher -> Platform API
The following diagram shows how the publisher decides whether received data may be shared.
flowchart TB
IN1["curl<br>POST /simulate/publish<br>(topic, payload, purpose)"] --> N["publisher: derives the<br>dataset_id from topic and payload"]
IN2["mosquitto_pub<br>(MQTT :1883)"] -->|"purpose is the default, research"| N
N --> C1{"Is there a consent with<br>the same dataset_id?"}
CON["POST /consents<br>consent JSON"] -.-> C1
C1 -->|"yes"| C2{"Is the purpose in<br>allowed_purposes?"}
C2 -->|"yes"| C3{"Is now between<br>valid_from and valid_to?"}
C3 -->|"yes"| SEND["send to the Platform API<br>(/platform/ingest)"]
SEND -->|"success"| A1["audit log: allow"]
SEND -->|"failure"| A3["audit log: send_error"]
C1 -->|"no"| A2["audit log: deny<br>(no_matching_consent)"]
C2 -->|"no"| A2
C3 -->|"no"| A2
classDef allow fill:#e3f4e1,stroke:#2e7d32,color:#1b5e20
classDef deny fill:#fde2e2,stroke:#c0392b,color:#7b241c
class A1 allow
class A2 deny
For example, homeassistant/state/sensor/temperature in step 3 becomes home/env/temperature. In step 4 a consent with the same dataset_id exists, but its purposes do not include marketing, so the result is deny.
Shortest path¶
For a first pass, these four steps are enough.
PLATFORM_INGEST_READ_ENABLED=true docker compose -f infra/docker-compose.yml up --build -d- Register
consent_temperature.json - Send the
temperaturerequest through/simulate/publish - Inspect
/audit/logsand confirmallow
Branches after that:
- If you only want HTTP simulation: compare one
allowedand onedeniedcase - If you want to inspect MQTT ingestion as well: publish
person_detectedwithmosquitto_pub - If you want to try Phase 2 (event sharing): continue with the
flood_risk_highorpossible_litteringhands-on pages (§2.1 of Part 2)
What this page covers¶
- the minimal Phase 1 setup: where data is received, where it is decided, and where it is recorded
- how to assemble
topic,payload, andpurposeinto one request - how to read
allowed,denied, and the audit log
Common issues¶
- the relation between
topicanddataset_idis hard to grasp at first - a consent JSON can be registered and still produce
deniedifpurposedoes not match - HTTP simulation and MQTT ingestion are two different checkpoints
Required environment¶
- Docker / Docker Compose
curl- if IPFS started in Quickstart (run the stack) is still running, stop it first from the source repository with
cd ~/program/Blockchain_IoT_Marketplace/ipfs && docker compose down(IPFS and the publisher both use port 8080)
Matching sample files:
examples/consent_temperature.jsonexamples/consent_power.jsonexamples/consent_person_detected.jsonexamples/consent_flood_risk_high.jsonexamples/consent_possible_littering.jsonexamples/payload_temperature.jsonexamples/payload_power.jsonexamples/payload_person_detected.jsonexamples/payload_flood_risk_high.jsonexamples/payload_possible_littering.json
Exercise programs:
This exercise asks learners to construct the minimum request body for /simulate/publish.
The problem program focuses on how topic, payload, and purpose are combined into one request.
Phase 1: Confirm the minimal setup¶
1. Start services¶
PLATFORM_INGEST_READ_ENABLED=true enables GET /platform/ingest, which you use in step 6 to check the delivered data (it is a demo-only API that returns everything without authentication, so it is off by default).
cd ~/program/Blockchain_IoT_Marketplace
PLATFORM_INGEST_READ_ENABLED=true docker compose -f infra/docker-compose.yml up --build -d
Health check:
curl http://localhost:8080/health
Expected:
{"status":"ok","service":"publisher"}
2. Register the consent JSON (equivalent to a Consent VC)¶
curl -X POST http://localhost:8080/consents -H 'Content-Type: application/json' -d @examples/consent_temperature.json
curl -X POST http://localhost:8080/consents -H 'Content-Type: application/json' -d @examples/consent_power.json
curl -X POST http://localhost:8080/consents -H 'Content-Type: application/json' -d @examples/consent_person_detected.json
Additional files used by the Phase 2 hands-on pages:
examples/consent_flood_risk_high.jsonexamples/consent_possible_littering.json
The setup needed for the checks is now complete. Next, compare a request that is allowed and a request that is denied.
Phase 1: Compare allowed and denied¶
3. Allowed case¶
curl -X POST http://localhost:8080/simulate/publish \
-H 'Content-Type: application/json' \
-d '{
"topic":"homeassistant/state/sensor/temperature",
"payload":{
"entity_id":"sensor.living_room_temperature",
"state":"24.1",
"attributes":{"unit_of_measurement":"C"},
"ts":"2026-02-28T10:00:00Z",
"source":"home_assistant"
},
"purpose":"research"
}'
Expected:
{"status":"allowed","dataset_id":"home/env/temperature"}
4. Denied case¶
curl -X POST http://localhost:8080/simulate/publish \
-H 'Content-Type: application/json' \
-d '{
"topic":"homeassistant/state/sensor/power",
"payload":{
"entity_id":"sensor.main_power",
"state":"520",
"attributes":{"unit_of_measurement":"W"},
"ts":"2026-02-28T10:00:10Z",
"source":"home_assistant"
},
"purpose":"marketing"
}'
Expected:
{"status":"denied","dataset_id":"home/energy/power","reason":"no_matching_consent"}
A request with the correct structure is still rejected when purpose does not match. Next, check the same decision through the MQTT path.
Phase 1: Inspect MQTT ingestion and audit logs¶
5. Test MQTT ingestion path¶
docker exec -i iw3ip-mosquitto mosquitto_pub \
-h localhost -p 1883 \
-t homeassistant/event/person_detected \
-m '{"event_type":"person_detected","data":{"camera_id":"front_door","confidence":0.93},"ts":"2026-02-28T10:00:20Z","source":"edge_inference"}'
6. Check audit logs¶
curl 'http://localhost:8080/audit/logs?limit=10'
Checkpoints:
- actions include
allow,deny, and/orsend_error - each record includes
dataset_id,purpose, andmessage_hash
Also confirm that the allowed data reached the destination (Platform API).
curl http://localhost:8080/platform/ingest
Checkpoints:
- the data from step 3 (
"dataset_id":"home/env/temperature") is included (the deniedhome/energy/powerfrom step 4 is not) - if
{"detail":"platform_ingest_read_disabled"}is returned,PLATFORM_INGEST_READ_ENABLED=truewas missing in step 1. Restart with it (see "GET /platform/ingestreturns 404" in Troubleshooting). The restart clears the data held in the publisher's memory, so send step 3 again before checking
7. Stop services¶
docker compose -f infra/docker-compose.yml down
Extension hints¶
- Phase 2: prioritize
homeassistant/event/...for event-driven sharing - Phase 3: add SSI Gateway (PEP) before publisher for VC presentation control
Phase 2 event sharing is covered in these §2.1 pages of Part 2:
- Share disaster events (Phase 2)
- Share detections, not raw frames (Phase 2)
Next steps¶
One page from 1.2 is enough. Next, start the stack with Quickstart (run the stack), then go to section 1.3 of Hands-on, where you list an item, buy it, and receive it.
- 1.3 does not use the publisher. First stop it with the command in 7. Stop services.
- 1.3 uses the Quickstart (run the stack) stack (terminals 1–7). Start it after the publisher is stopped, because the Quickstart IPFS and the publisher both use port 8080.
- If you chose this page in 1.2, list an item in 1.3 by running the sample of Detect with a USB webcam (OpenCV) in mock mode.