For Data Providers
This section covers simulation and real Home Assistant bridging.
๐งช A. Simulate Device Data (Recommended First Step)
Before using real Home Assistant, test your setup with the built-in simulator.
๐ 1. Clone and Prepare
git clone git@github.com:dephy-io/hass2nostr.git๐ 2. Install Deno
๐ 3. Configure Environment
cp .env.example .envThen edit .env and fill in your Nostr secret key:
DEPHY_SECRET_KEY=<your_nostr_secret_key>๐ก Note: When running the simulator, only
DEPHY_SECRET_KEYis required. You donโt needDEPHY_HA_TOKENโ that token is only necessary later when running the bridge with a real Home Assistant connection.
๐ 4. Run the Simulator
deno task run simulate \
-w chunmi_tsa1 \
-r wss://canary-relay.dephy.dev \
-o playground \
-m cdb9247ec7ab3302fd12450ae7453ab9f833639f109833f06c5d909991d62a3cFlag Reference
-r
Relay WebSocket endpoint
-w
Device type(s) to simulate
-o
Target Topic name
-i
Interval (ms) between events
-m
Controller pubkey to mention
๐ B. Bridge to Real Home Assistant
This section explains connecting a real HASS instance and running the bridge.
๐ 1. Run Home Assistant via Docker
๐ 2. Install HACS & Xiaomi Integrations
Then in the web UI (http://192.168.x.x:8123):
Settings โ Devices & Services โ Integrations
Click Add Integration โ Search for HACS
Authorize GitHub, restart if prompted
In HACS: Explore & Download Repositories โ Search โXiaomi Homeโ (or โXiaomi Miotโ) โ Download
Restart Home Assistant
Settings โ Devices & Services โ Add Integration โ Xiaomi Home
If redirect URL fails (
homeassistant.local), replace with your IP (e.g.http://192.168.x.x:8123/...)
๐ 3. Generate a Long-Lived Access Token
Click your user profile (bottom-left).
Scroll to Long-Lived Access Tokens.
Click Create Token, name it, and copy immediately.
Store it securely โ itโs shown only once.
Add it to .env as:
๐ 4. Configure the Bridge Environment
Clone the repo (if not already):
Install Deno (see deno.land).
Add
.env:Verify the needed device type exists in
src/device-types/.If not, create or adapt one per developer section above.
๐ 5. Run the Bridge
Default controller pubkey:
Run:
Flag Reference
-r
Relay WebSocket endpoint
-w
Device type module (in src/device-types/)
-o
Target Topic name
-i
Publish interval (ms)
-m
Controller pubkey to mention/notify
Runtime Notes
The bridge polls
/api/statesfrom HASS, filters by your moduleโsentityPrefixesandallowedEntitySuffixes, truncates attributes, and publishes to the relay as Nostr events.If a value is non-numeric, that entity will be skipped automatically.
๐ 6. Monitor Your Stream
Open your Topic in the frontend.
Ensure Access Mode and grants/subscriptions are valid.
Wait for one auth epoch (~5 min).
Events will appear if you are authorized and the bridge is publishing successfully.
Last updated

