Share disaster events¶
Share edge-generated disaster events instead of raw camera frames.
What you'll do: Emit disaster events from mock data, share, observe
Prerequisites: Part 1 (§1.1–§1.3) is done (this page uses mock data, so you can do it without a camera)
Keep running: nothing needs to be running. This page starts the publisher. Keep the Quickstart IPFS stopped (it shares port 8080)
What you need: PC only
Time required: approx. 30 min
Where this page belongs
- This is section 2.1 of Part 2 (Stage 0) (Hands-on). Pick just one of the two pages in 2.1. The other one is Share detections, not raw frames.
- "Phase 1" and "Phase 2" on this page are development stages of the platform, not the learning order (Hands-on).
- Previous page: section 1.3 of Part 1 (Hands-on). 1.4 is optional
- Next page: Authenticate the data provider (Consent VC / Stage 1) (2.2)
This hands-on is designed as a minimal Phase 2: Event / Intelligence Sharing exercise.
Instead of sharing camera images or raw sensor streams, it shares disaster-related events generated at the edge.
This page uses the existing HA SSI Publisher as the base and reproduces the following flow with simulated data:
simulated sensor / edge inference -> disaster event -> Consent VC check -> allow / deny -> audit log
Shortest path¶
For a first pass, these four steps are enough.
- start the publisher
- register
consent_flood_risk_high.json - send
flood_risk_highwithpurpose = disaster_response - inspect
/platform/ingestand/audit/logs
Branches after that:
- If you only want to confirm the allowed path: you can finish once you have confirmed
allowed - If you want to understand consent properly: also send
advertisingand confirm the denied case - If you want to inspect the MQTT path too: finish with
mosquitto_pub
What this page helps you understand¶
- why Phase 2 moves from raw-data sharing to event sharing
- how
flood_risk_highbecomesallowedordenied - how to read
/platform/ingestand/audit/logsseparately
The diagram below shows how the publisher decides whether to share an event.
flowchart TB
IN["Receive an event<br>topic: homeassistant/event/flood_risk_high"]
NORM["Convert to dataset_id<br>home/event/flood_risk_high"]
Q1{"Is a consent registered<br>for this dataset_id?"}
Q2{"Is purpose in<br>allowed_purposes?"}
Q3{"Is now between<br>valid_from and valid_to?"}
OK["allowed<br>forwarded to /platform/ingest"]
NG["denied<br>reason: no_matching_consent"]
AUD["/audit/logs<br>records allow / deny"]
IN --> NORM --> Q1
Q1 -->|"yes"| Q2
Q1 -->|"no"| NG
Q2 -->|"yes"| Q3
Q2 -->|"no"| NG
Q3 -->|"yes"| OK
Q3 -->|"no"| NG
OK --> AUD
NG --> AUD
classDef allow fill:#e3f4e1,stroke:#2e7d32,color:#1b5e20
classDef deny fill:#fde2e2,stroke:#c0392b,color:#7b241c
class OK allow
class NG deny
With the consent on this page, disaster_response is allowed and advertising is denied at the check "Is purpose in allowed_purposes?". An event sent over MQTT carries no purpose, so it is checked with the publisher's default, research.
Common pitfalls¶
dataset_idandevent_typeare easy to mix up- the
purposein the request must matchallowed_purposesin the registered consent - even when the flow is correct,
allowedanddeniedare confirmed in different places
Required environment¶
- you can run Pull from Home Assistant (HA SSI Publisher)
- Docker / Docker Compose is available
- If the IPFS from the Quickstart (run the stack) is still running, stop it first (
cd ~/program/Blockchain_IoT_Marketplace/ipfs && docker compose down); IPFS and the publisher both use port 8080 curlis available
This hands-on assumes the source-code repository Blockchain_IoT_Marketplace on the main branch.
Matching sample files:
examples/consent_flood_risk_high.jsonexamples/payload_flood_risk_high.json
Exercise programs:
This exercise asks learners to complete the request that sends a flood_risk_high event to /simulate/publish.
The problem program makes the allowed / denied difference visible at code level by changing only the purpose.
Scenario¶
Assume an edge sensor near a river generates a flood_risk_high event based on rising water level and surrounding conditions.
The event may be shared for municipal disaster response or research, but should not be shared for advertising.
Instead of sharing the raw sensor stream, we share an event like this:
{
"event_type": "flood_risk_high",
"data": {
"sensor_id": "river-west-01",
"location": "west_river_area",
"water_level_m": 1.82,
"severity": "high"
},
"ts": "2026-03-08T10:15:05Z",
"source": "edge_inference"
}
When this event is sent to homeassistant/event/flood_risk_high, the Publisher normalizes it to dataset_id = home/event/flood_risk_high.
The same event content is also available in examples/payload_flood_risk_high.json in the source repository.
Phase 2: Prepare the event-sharing baseline¶
1. Start the services¶
Run the following in the source-code repository. 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 Stage 3 of Part 2 (authenticating the data viewer) 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 up --build -d
Health check:
curl http://localhost:8080/health
Expected:
{"status":"ok","service":"publisher"}
2. Register the consent JSON for this hands-on (equivalent to a Consent VC)¶
The content is equivalent to a Consent VC, but here you register the JSON directly at /consents and no VC signature is verified. VCs are first used in 2.2.
This hands-on allows home/event/flood_risk_high only for disaster_response and research.
The same consent content is also available in examples/consent_flood_risk_high.json in the source repository.
curl -X POST http://localhost:8080/consents \
-H 'Content-Type: application/json' \
-d '{
"vc_id": "consent-flood-risk-001",
"subject_did": "did:example:river-community",
"dataset_id": "home/event/flood_risk_high",
"allowed_purposes": ["disaster_response", "research"],
"retention_days": 30,
"reshare_allowed": false,
"valid_from": "2026-02-01T00:00:00Z",
"valid_to": "2030-12-31T23:59:59Z",
"signature": "PLACEHOLDER"
}'
Expected:
{"status":"stored", ...}
Check:
curl http://localhost:8080/consents
At this point, the minimum setup for evaluating flood_risk_high is ready. The next step is to send the same event under two different purposes and compare the result.
Phase 2: Compare allowed and denied¶
3. Reproduce an allowed case¶
Inject a disaster event with purpose = disaster_response.
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":{
"sensor_id":"river-west-01",
"location":"west_river_area",
"water_level_m":1.82,
"severity":"high"
},
"ts":"2026-03-08T10:15:05Z",
"source":"edge_inference"
},
"purpose":"disaster_response"
}'
Expected:
{"status":"allowed","dataset_id":"home/event/flood_risk_high"}
4. Inspect what reached the Platform API¶
If the event is allowed, it is forwarded to the dummy Platform API inside the Publisher.
curl http://localhost:8080/platform/ingest
Checkpoints:
dataset_idishome/event/flood_risk_highpurposeisdisaster_responsepayload.message_typeiseventpayload.payload.event_typeisflood_risk_high
5. Reproduce a denied case¶
Now send the same event with purpose = advertising.
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":{
"sensor_id":"river-west-01",
"location":"west_river_area",
"water_level_m":1.82,
"severity":"high"
},
"ts":"2026-03-08T10:16:05Z",
"source":"edge_inference"
},
"purpose":"advertising"
}'
Expected:
{"status":"denied","dataset_id":"home/event/flood_risk_high","reason":"no_matching_consent"}
6. Check the audit logs¶
curl 'http://localhost:8080/audit/logs?limit=10'
Checkpoints:
- both
allowanddenyare recorded dataset_idishome/event/flood_risk_highpurposeisdisaster_responseoradvertisingmessage_hashis recorded
The goal of Phase 2 is to be able to explain under which conditions an event is shared. Finally, confirm the same behavior through the MQTT path.
Phase 2: Confirm the same policy through MQTT¶
7. Try the MQTT path as well¶
You can reproduce the same event-sharing flow through MQTT instead of HTTP simulation.
docker exec -i iw3ip-mosquitto mosquitto_pub \
-h localhost -p 1883 \
-t homeassistant/event/flood_risk_high \
-m '{"event_type":"flood_risk_high","data":{"sensor_id":"river-west-01","location":"west_river_area","water_level_m":1.82,"severity":"high"},"ts":"2026-03-08T10:17:05Z","source":"edge_inference"}'
Then check the audit logs again:
curl 'http://localhost:8080/audit/logs?limit=10'
Success criteria¶
This hands-on is successful if you can confirm all of the following:
home/event/flood_risk_highis handled as an event-sharing datasetdisaster_responsebecomesallowedadvertisingbecomesdenied- allowed events appear in
/platform/ingest - both allow and deny outcomes appear in
/audit/logs
Why this is Phase 2¶
Phase 1 focused mainly on state data such as temperature and power.
This hands-on moves to the next step: sharing events interpreted at the edge instead of sharing raw data directly.
The focus therefore changes as follows:
- Phase 1:
stateand raw-like data - Phase 2:
eventand inference-oriented outputs
Natural extensions¶
- add
high_co2orabnormal_vibrationusing the same pattern - keep water-level values private and share only events
- connect the events to map visualization or notification apps
- split Consent VCs by sharing destination
Next steps¶
One page from 2.1 is enough. Next is Authenticate the data provider (Consent VC / Stage 1) in 2.2 (Hands-on).
- You can keep the publisher running. Step 1 of the next page starts it again with the
ssi-walletprofile. - Keep the Quickstart IPFS stopped. IPFS and the publisher both use port 8080.
- After you finish Stage 1, you can also try the appendix at the bottom of this page.
If you stop here, stop the publisher with cd ~/program/Blockchain_IoT_Marketplace && docker compose -f infra/docker-compose.yml down.
Appendix: wallet-mode authorization¶
This appendix is optional. It uses Authenticate the data provider (Consent VC / Stage 1) (Stage 1), so try it after you finish Stage 1. You can come back to this page after Stage 1.
The main flow registers consent_flood_risk_high.json via POST to
/consents — i.e. consent is stored as plaintext JSON on the publisher.
The hands-on Authenticate the data provider (Consent VC / Stage 1) takes a different
route: residents or observers hold a VC in their phone wallet and present
it via OID4VP. The publisher ships ConsentVC PDs for both
home/event/flood_risk_high (matches the main flow exactly) and
home/env/flood_risk_high, so disaster events can be gated through
the wallet using the same dataset as the main hands-on.
What's the same, what's different¶
| Aspect | Main flow (/consents JSON) |
Wallet mode (Stage 1: ConsentVC) |
|---|---|---|
| Consent storage | publisher server | mobile wallet |
| Transport | JSON POST | OID4VP (QR / deeplink) |
| Validity window | valid_to TTL |
short-lived PolicyToken per presentation (5 min, single-use) |
| Revocation | DELETE /consents |
drop from wallet (revoke is not implemented) |
| Audit log | purpose / dataset_id |
also holder_did / vc_hash |
The decision logic is identical: (dataset_id, purpose) decides
allow / deny. What changes is whether the consenter's identity is
backed by a verifiable credential and how the consent is delivered. In a
disaster-response setting, a resident can present a consent VC from the
wallet to allow sharing of their district's data.
How to try it (sketch)¶
Gating every MQTT event through the wallet doesn't fit PolicyToken's single-use semantics. Instead, we recommend sending one event with curl:
A phone wallet cannot reach the PC's localhost, so open the URLs below in a PC browser with <HOST_IP> replaced by the PC's LAN IP (see Hands-on for how to find it).
First, restart with the ssi-wallet profile.
cd ~/program/Blockchain_IoT_Marketplace
PLATFORM_INGEST_READ_ENABLED=true docker compose -f infra/docker-compose.yml --profile ssi-wallet up --build -d
- Issue a ConsentVC for the same dataset the main flow uses:
(allowed purposes:
http://<HOST_IP>:8080/issuer/offer?type=ConsentVC&dataset_id=home/event/flood_risk_high&purpose=disaster_responsedisaster_response,safety,emergency_planning) - Receive in the wallet, then present:
http://<HOST_IP>:8080/verifier/request?dataset_id=home/event/flood_risk_high&purpose=disaster_response - Take the PolicyToken and POST a Stage-0-shaped event.
The PolicyToken is the value after
token=on thepolicy_token_issuedline in the publisher log. Copy it intoPOLICY(valid for 5 minutes):Replacecd ~/program/Blockchain_IoT_Marketplace docker compose -f infra/docker-compose.yml logs publisher 2>&1 | grep policy_token_issued | tail -n 1<value after token=>with the value aftertoken=that is printed, and run:If 5 minutes have passed orPOLICY='<value after token=>'policy_token_expiredis returned, redo the presentation and use thetoken=value from the last line printed above.curl -X POST http://localhost:8080/platform/ingest \ -H "Authorization: Bearer $POLICY" \ -H "Content-Type: application/json" \ -d '{ "dataset_id":"home/event/flood_risk_high", "purpose":"disaster_response", "event_type":"flood_risk_high", "data":{"sensor_id":"river-west-01","location":"west_river_area","water_level_m":1.82,"severity":"high"}, "ts":"2026-04-28T10:17:05Z", "source":"edge_inference" }' - Confirm
/audit/logsshowsreason=policy_token_consumed:<jti>
Notes¶
- A ConsentVC PD for
home/event/flood_risk_high(consent-event-flood-risk-high.json) is registered, so the wallet flow ingests the exact same event shape (sensor_id / water_level_m / severity) that the main flow uses. - Continuous MQTT under wallet mode requires an M2M token usable any number of times within its TTL (ServiceVC), which is covered in Authenticate machines (Service VC / Stage 4 prep).
Related¶
- Symmetric read-side gating: Authenticate the viewer (Viewer VC / Stage 3)