Run the whole pipeline without hardware (HA Demo Simulator)¶
A page that runs data generation through sharing in a minimal setup, using Home Assistant's demo mode with no real device. A good one to try first.
What you'll do: Stream Home Assistant demo data into the publisher and watch it in the browser
Prerequisites: Prerequisites (install tools) is done. Quickstart (run the stack) is not needed
Keep running: nothing needs to be running. This page starts the publisher and Home Assistant. If IPFS from Quickstart is running, stop it first (see Required environment below)
What you need: PC only (Docker is enough)
Time required: approx. 20 min (optional sections not included)
Where this page belongs
- This is section 1.1 of Part 1 (Hands-on). It is the first hands-on page.
- "Phase 1–3" on this page are development stages of the platform, not the learning order (Hands-on).
- Previous page: Prerequisites (install tools)
- Next page: Quickstart (run the stack) (if you use a camera in 1.2). If you pick HA SSI Publisher in 1.2, go directly to Pull from Home Assistant (HA SSI Publisher).
Goal¶
This is a minimal simulation environment for trying the Home Assistant and IW3IP integration without real devices.
It uses Home Assistant demo entities to reproduce the following local flow:
Home Assistant demo -> MQTT -> (optional Node-RED) -> Data Publisher -> Platform API / Audit Log
This page uses one environment to show Phase 1 state sharing, Phase 2 event sharing, and a Phase 3 assistant execution flow.
The following diagram shows the data flow on this page.
flowchart TB
HA["Home Assistant demo<br>script (mqtt.publish)"] -->|"homeassistant/state/...<br>homeassistant/event/..."| MQ["mosquitto<br>(MQTT :1883)"]
MQ --> PUB["publisher (:8080)<br>receives and normalizes"]
SIM["curl<br>POST /simulate/publish"] -->|"sets purpose"| PUB
PUB --> CHK{"Is there a matching consent?<br>(dataset_id, purpose, validity period)"}
CON["POST /consents<br>consent JSON"] --> CHK
CHK -->|"allow"| ING["recorded in<br>/platform/ingest"]
CHK -->|"allow / deny"| AUD["recorded in<br>/audit/logs"]
ING -.->|"Phase 3:<br>run_phase3_from_ingest.py"| AST["assistant (:8090)<br>plan / execute"]
classDef allow fill:#e3f4e1,stroke:#2e7d32,color:#1b5e20
class ING allow
The publisher has two entry points: MQTT and HTTP (/simulate/publish). Data from either one goes through the same consent check. Data from MQTT carries no purpose, so the publisher uses its default (research). Both allowed (allow) and denied (deny) messages are recorded in /audit/logs.
Shortest path¶
For a first pass, these five steps are enough.
PLATFORM_INGEST_READ_ENABLED=true docker compose -f infra/docker-compose.yml --profile ha-demo up --build -d- Open
http://localhost:8123and add theMQTTintegration - Register the consent JSON (equivalent to a Consent VC)
- Run
script.iw3ip_publish_demo_temperatureorscript.iw3ip_publish_demo_possible_litteringfromDeveloper Tools -> Actions - Check the shared result with
curl http://localhost:8080/platform/ingest
Branches:
- If you only want Phase 1: send
temperatureandpower, then inspectplatform/ingest - If you want to continue to Phase 2: send
possible_litteringand inspect bothallowanddeny - If you want to continue to Phase 3: start
ha-demo-phase3and runrun_phase3_from_ingest.py --plan-only
What this page covers¶
- how to reproduce
temperature,power,person_detected,flood_risk_high, andpossible_litteringwithout real devices - how IW3IP publisher receives, normalizes, and records data coming from Home Assistant through MQTT
- the difference between Phase 1 state sharing and Phase 2 event sharing
- how the registered consent changes
allowedanddenied - how to pass the events accumulated in
/platform/ingestto the Phase 3assistant
Common issues¶
- starting Home Assistant alone is not enough; you must add the
MQTTintegration before the scripts can publish - if the consent JSON is not registered, the scripts may run but the expected sharing behavior will not appear
- Home Assistant can publish an event correctly and the publisher can still reject it if
purposedoes not match - because there are no physical devices, the flow is easier to lose sight of, so check both
/platform/ingestand/audit/logs - in Phase 3 it is easy to mix up sharing and execution, because publisher and assistant are separate services
Required environment¶
- Docker / Docker Compose
- a browser that can open
http://localhost:8123 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)
This hands-on assumes the source-code repository Blockchain_IoT_Marketplace on the main branch.
Main matching files:
- README (English)
- README (Japanese)
- examples/ha_demo/README.md
- configuration.yaml
- scripts.yaml
- run_phase3_from_ingest.py
Phase 1: Confirm the basic state-sharing path¶
In Phase 1, the goal is to confirm that the basic path from Home Assistant to the publisher is working. It is enough to send one state-oriented dataset first and confirm that it appears in platform/ingest.
1. Start services¶
Start the simulation environment. PLATFORM_INGEST_READ_ENABLED=true enables GET /platform/ingest, which this page uses to inspect ingested data. It is a demo-only API that returns every row without authentication and is disabled (404) unless set. From Part 2 onward, reads use a token obtained by presenting a VC.
cd ~/program/Blockchain_IoT_Marketplace
PLATFORM_INGEST_READ_ENABLED=true docker compose -f infra/docker-compose.yml --profile ha-demo up --build -d
If you also want Node-RED:
PLATFORM_INGEST_READ_ENABLED=true docker compose -f infra/docker-compose.yml --profile ha-demo --profile nodered up --build -d
Check:
curl http://localhost:8080/health
Expected:
{"status":"ok","service":"publisher"}
2. Initial Home Assistant setup¶
Open:
http://localhost:8123
On the first run, create a local user. After logging in, first confirm that the Overview page opens correctly.
Real screen example:

What to check:
Settingsis visible in the lower-left navigation- the central page is the normal
Overviewscreen - login has completed and the standard dashboard is open
Then open Settings -> Devices & Services -> Integrations and add the MQTT integration.
Settings:
- Host:
mosquitto - Port:
1883
The purpose of this step is to make mqtt.publish available from Home Assistant scripts. After the integration is added, the setup for this hands-on is ready when the MQTT detail screen shows the mosquitto service.
Real screen example:

What to check:
- the integration name
MQTTis visible - the
mosquittoservice is shown - once this screen is visible, Home Assistant is ready to use
mqtt.publish
3. Register the consent JSON (equivalent to a Consent VC)¶
Register the consents for the demo datasets as JSON at /consents. The content is equivalent to a Consent VC, but no VC signature is verified here. You first receive and present a VC in a wallet in Authenticate the data provider (Consent VC / Stage 1) in Part 2.
curl -X POST http://localhost:8080/consents -H 'Content-Type: application/json' -d @examples/ha_demo/consent_temperature.json
curl -X POST http://localhost:8080/consents -H 'Content-Type: application/json' -d @examples/ha_demo/consent_power.json
curl -X POST http://localhost:8080/consents -H 'Content-Type: application/json' -d @examples/ha_demo/consent_person_detected.json
curl -X POST http://localhost:8080/consents -H 'Content-Type: application/json' -d @examples/ha_demo/consent_flood_risk_high.json
curl -X POST http://localhost:8080/consents -H 'Content-Type: application/json' -d @examples/ha_demo/consent_possible_littering.json
curl -X POST http://localhost:8080/consents -H 'Content-Type: application/json' -d @examples/ha_demo/consent_suspicious_activity.json
Expected:
- each response includes
"status":"stored"
Matching files:
- consent_temperature.json
- consent_power.json
- consent_person_detected.json
- consent_flood_risk_high.json
- consent_possible_littering.json
- consent_suspicious_activity.json
4. Send demo data from Home Assistant¶
In Home Assistant, open Developer Tools -> Actions and run these scripts. In practice, it is easiest to choose script.turn_on in the action selector and then specify the target script entity.
Real screen example:

What to check:
- the
Actionstab is selected script.turn_oncan be chosen in the action selector-
the execution button can be used to invoke the target script
-
script.iw3ip_publish_demo_temperature script.iw3ip_publish_demo_powerscript.iw3ip_publish_demo_person_detectedscript.iw3ip_publish_demo_flood_risk_highscript.iw3ip_publish_demo_possible_litteringscript.iw3ip_publish_demo_suspicious_activityscript.iw3ip_publish_demo_phase3_safety_scenario
These scripts call mqtt.publish defined in scripts.yaml.
Phase mapping:
- Phase 1:
temperaturepowerperson_detected- Phase 2:
flood_risk_highpossible_litteringsuspicious_activity
5. Check publisher results¶
After running a Home Assistant script, inspect the publisher side.
curl http://localhost:8080/platform/ingest
curl 'http://localhost:8080/audit/logs?limit=10'
Checkpoints:
platform/ingestcontains sent recordsaudit/logscontainsallowdataset_id,purpose,message_hash, andraw_topicare visible
From the audit log, read whether the data was sent and also under which conditions it was sent.
Example output:
Focus points:
/platform/ingestcontains bothhome/event/possible_litteringandhome/event/suspicious_activity/audit/logsshowsaction: allowwith the expectedraw_topic
So far you have confirmed that events matching a registered consent are shared. The next exercise checks what happens when a consent expires.
Exercise: an expired consent causes denials¶
This exercise is optional. To finish 1.1, steps 1–5 are enough.
The bundled examples/ha_demo/consent_*.json files have valid_to set to 2030-12-31T23:59:59Z, so nothing expires as shipped. Here you deliberately register an expired possible_littering consent, confirm that events are denied, and then fix it. This shows how a VC's validity period (valid_from–valid_to) works.
Step 1. Register an expired consent¶
Send the consent to /consents with valid_to rewritten to a past date. The file itself is not changed. Consents are overwritten per vc_id, so this replaces the one you registered in step 3.
sed 's/"valid_to": "2030-12-31T23:59:59Z"/"valid_to": "2026-05-01T00:00:00Z"/' examples/ha_demo/consent_possible_littering.json \
| curl -X POST http://localhost:8080/consents -H 'Content-Type: application/json' -d @-
Confirm the response has "status":"stored" and valid_to is 2026-05-01T00:00:00Z.
If you have already done Share detections, not raw frames, Enrich camera data with a local VLM, or the tiered-access pages (such as Tier the response by trust (DataUserVC / Stage T)), a valid consent for the same possible_littering (consent-littering-001 or local-vlm-distribution-consent-webcam-001) remains and no denial happens. Check with curl http://localhost:8080/consents, and if it is there, delete it with the command below. If you need them after this exercise, register the deleted consents again (curl -X POST http://localhost:8080/consents -H 'Content-Type: application/json' -d @examples/consent_possible_littering.json; for the local VLM consent use -d @examples/hands_on/local_vlm_distribution/fixtures/consent_webcam.json).
curl -X DELETE http://localhost:8080/consents/consent-littering-001
curl -X DELETE http://localhost:8080/consents/local-vlm-distribution-consent-webcam-001
Then run script.iw3ip_publish_demo_possible_littering and script.iw3ip_publish_demo_suspicious_activity from step 4.
Step 2. Confirm the denial in the audit log¶
Read the audit log. In zsh, quote the URL because ? is treated as a glob.
curl 'http://localhost:8080/audit/logs?limit=20'
Look at action / dataset_id / reason / subject_did.
What should you be able to read off?
possible_litteringhasaction: "deny",reason: "no_matching_consent", andsubject_did: "unknown".suspicious_activityhasaction: "allow",reason: "sent", andsubject_didholds the data subject DID of the matching consent (did:example:ha-demo-operator).- So the problem is not that a consent is missing, but that no matching consent is found.
Step 3. Find the cause¶
List the registered consents and compare valid_from and valid_to for possible_littering and suspicious_activity.
curl http://localhost:8080/consents
Hint
valid_from–valid_to is the VC's validity period. If today's date falls outside this range, the consent does not match.
Step 4. Fix and re-register¶
Re-register the original file (valid_to in 2030) and confirm the response contains "status":"stored".
curl -X POST http://localhost:8080/consents -H 'Content-Type: application/json' -d @examples/ha_demo/consent_possible_littering.json
Step 5. Re-send the event and verify¶
Run script.iw3ip_publish_demo_possible_littering again, then confirm the event now appears in /platform/ingest.
curl 'http://localhost:8080/platform/ingest'
If it still fails
- Existing
denyentries remain in the log as history. Always verify with a new event sent after the consent was re-registered. - If it is still denied, check that the event's
purposeis included in the consent'sallowed_purposes. - See the "
no_matching_consent" item in Troubleshooting for details.
Something to think about¶
Why do VCs have an expiry at all? Consider what becomes safer compared with consent that never expires, and how you would operate the system when a consent expires in production.
Once this part works, the basic sharing path from Home Assistant to the publisher is in place. Next, confirm a rejection caused by a purpose mismatch.
Phase 2: Confirm event sharing and denial¶
This section is optional. The shortest path only needs Phase 1.
6. Check a denied case¶
The Home Assistant scripts mainly exercise allowed paths, so use HTTP simulation to confirm denial.
curl -X POST http://localhost:8080/simulate/publish \
-H 'Content-Type: application/json' \
-d '{
"topic":"homeassistant/event/flood_risk_high",
"payload":{
"event_type":"flood_risk_high",
"data":{"zone":"river-west","severity":"high"},
"ts":"2026-03-10T10:05:00Z",
"source":"home_assistant_demo"
},
"purpose":"advertising"
}'
Expected:
{"status":"denied","dataset_id":"home/event/flood_risk_high","reason":"no_matching_consent"}
This makes it clear that generating an event and being allowed to share it are separate questions.
How to read the flow:
What to check here:
- the input topic can be correct and still be rejected when
purposedoes not match the registered consent - you should confirm the rejection in both the
simulate/publishresponse andaudit/logs
7. Test the MQTT path directly¶
This step is optional too.
You can also publish directly to the same topic without Home Assistant.
docker exec -i iw3ip-mosquitto mosquitto_pub \
-h localhost -p 1883 \
-t homeassistant/event/possible_littering \
-m "$(cat examples/ha_demo/payload_possible_littering.json)"
Related files:
- payload_temperature.json
- payload_power.json
- payload_person_detected.json
- payload_flood_risk_high.json
- payload_possible_littering.json
This confirms that data sent through the same MQTT path is not always shared. In Phase 3, you pass the shared events to the assistant and check request interpretation and execution.
Phase 3: Confirm assistant planning and execution¶
This section is optional. Phase 3 is also covered in Run the regional safety assistant (Part 3). This section uses Python 3.
8. Try Phase 3¶
In Phase 3, the events accumulated by the publisher are converted into assistant observed_events, and then you inspect plan -> execute.
Start:
PLATFORM_INGEST_READ_ENABLED=true docker compose -f infra/docker-compose.yml --profile ha-demo-phase3 up --build -d
Then run this Home Assistant script:
script.iw3ip_publish_demo_phase3_safety_scenario
That script publishes the following sequence for park-north:
- three
possible_litteringevents - one
suspicious_activityevent
Next, inspect the plan first:
python3 examples/ha_demo/run_phase3_from_ingest.py \
--plan-only \
--request-file examples/ha_demo/phase3_request_park_safety.json
At this stage, check:
statusisplannedplan.watch_eventsincludespossible_litteringandsuspicious_activityplan.actionsincludeslight_onandsend_notification
Example output:
{
"status": "planned",
"plan": {
"target_area": "park-north",
"watch_events": ["possible_littering", "suspicious_activity"],
"actions": [
{"action_type": "light_on", "target": "park-north-light-1"},
{"action_type": "send_notification", "target": "park-north-manager"}
]
}
}
Then pass the events accumulated in the publisher to the assistant and check execute:
python3 examples/ha_demo/run_phase3_from_ingest.py \
--request-file examples/ha_demo/phase3_request_park_safety.json
Expected:
execution.evaluation.triggeredistrueactions_executedincludeslight_onandsend_notification
This confirms that request interpretation (plan) and execution against observed events (execute) are separate steps.
Example output:
Focus points in execute:
evaluation.triggeredistruematched_counts.possible_litteringis 3 or morematched_counts.suspicious_activityis 1 or moreactions_executedcontains two actions
/platform/ingest still holds the events sent in earlier steps, so any park-north events from step 4 or the exercise that are still inside the time window are counted too. To see exactly 3 and 1, restart the publisher with docker compose -f infra/docker-compose.yml restart publisher before running the script (the stored events are in memory and are cleared; registered consents are kept).
Additional notes¶
9. If you want to use Node-RED¶
Node-RED is useful when you want easier manual injection or time-based pseudo events.
Import flow:
Node-RED is optional in this setup.
It is better to first understand the full path with Home Assistant demo alone, and only then add Node-RED if you want clearer event injection.
10. What is Phase 1, Phase 2, and Phase 3 here?¶
This sample lets you go through Phase 1, Phase 2, and Phase 3 in a single environment.
- Phase 1:
- state sharing such as
temperatureandpower - basic receive, normalize, send, and record flow
- Phase 2:
- event sharing such as
flood_risk_highandpossible_littering - conditional sharing based on
purposeand the registered consent - Phase 3:
- pass publisher events to the assistant and execute the plan
- inspect
triggeredandactions_executed
For the next page in the learning order, see Next steps.
11. Stop services¶
Whether or not you started Node-RED or Phase 3, this one command stops everything:
docker compose -f infra/docker-compose.yml --profile ha-demo --profile ha-demo-phase3 --profile nodered down
If you go on to Quickstart (run the stack), stop the publisher here. The IPFS that Quickstart starts and the publisher both use port 8080.
Future extensions¶
This sample covered the basic IW3IP path. Later, it could be connected to external environments such as the following.
FIWARE¶
FIWARE is an IoT platform family centered on Context Broker and IoT Agent components for cities, facilities, and multi-organization data flows [1]. It is heavier than Home Assistant, but it suits research extensions that involve data sharing across multiple parties and subscription-based notification. Its official tutorials [2] walk through the components step by step.
Eclipse Ditto¶
Eclipse Ditto is a digital-twin platform for device state and command handling [3]. Combined with IW3IP Phase 3, it lets you trace the chain from shared events to decisions, state updates, and control results. Connecting devices over MQTT is described in [4].
CARLA¶
CARLA is a simulator for urban spaces, vehicles, pedestrians, and virtual sensors [5]. It takes more effort to set up, but it can generate events for regional safety, disaster response, and traffic, and can serve as an evaluation environment for Phase 2 / 3. Its usage is described in the documentation [6].
Next steps¶
Next is Quickstart (run the stack). After that, go to section 1.2 of Part 1 and pick one of the three pages in 1.2 of Hands-on that matches your equipment.
- Detect a person on an AI camera (HUSKYLENS2) and Detect with a USB webcam (OpenCV) use the Quickstart stack. First stop the publisher with the command in 11. Stop services, then go to Quickstart.
- If you pick HA SSI Publisher in 1.2, go directly to Pull from Home Assistant (HA SSI Publisher) before Quickstart. It uses the same publisher as this page. Stop it with 11. Stop services, then start it again in step 1 of that page. Run Quickstart after that page, before 1.3.
Phase 2 and 3 of this page are covered again later in the course, on these pages. You do not need to go there now.
- Share disaster events (section 2.1 of Part 2)
- Run the regional safety assistant (Part 3)
If you stop here, shut everything down with the command in 11. Stop services.
References¶
[1] FIWARE Foundation, "FIWARE," https://fiware.org/
[2] FIWARE Foundation, "NGSI-v2 Smart Supermarket Tutorials," https://fiware-tutorials.readthedocs.io/en/latest/
[3] Eclipse Foundation, "Eclipse Ditto," https://eclipse.dev/ditto/
[4] Eclipse Foundation, "Eclipse Ditto Documentation: MQTT 3.1.1 protocol binding," https://eclipse.dev/ditto/connectivity-protocol-bindings-mqtt.html
[5] CARLA Team, "CARLA Simulator," https://carla.org/
[6] CARLA Team, "CARLA Simulator Documentation," https://carla.readthedocs.io/