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 [email protected]:dephy-io/hass2nostr.git
👌 2. Install Deno
👌 3. Configure Environment
cp .env.example .env
Then edit .env
and fill in your Nostr secret key:
DEPHY_SECRET_KEY=<your_nostr_secret_key>
💡 Note: When running the simulator, only
DEPHY_SECRET_KEY
is 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 cdb9247ec7ab3302fd12450ae7453ab9f833639f109833f06c5d909991d62a3c
Flag 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
sudo docker pull homeassistant/home-assistant
docker run -d \
--name homeassistant \
--privileged \
--restart=unless-stopped \
-v /data/homeassistant:/config \
--network=host \
homeassistant/home-assistant
👌 2. Install HACS & Xiaomi Integrations
sudo docker exec -it homeassistant bash
wget -O - https://get.hacs.xyz | bash -
exit
sudo docker restart homeassistant
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:
DEPHY_HA_TOKEN=<your_token>
👌 4. Configure the Bridge Environment
Clone the repo (if not already):
git clone [email protected]:dephy-io/hass2nostr.git
Install Deno (see deno.land).
Add
.env
:DEPHY_SECRET_KEY=<your_nostr_secret_key> DEPHY_HA_TOKEN=<your_home_assistant_long_lived_token>
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:
cdb9247ec7ab3302fd12450ae7453ab9f833639f109833f06c5d909991d62a3c
Run:
deno task run bridge \
-r wss://canary-relay.dephy.dev \
-w qingping_air_monitor \
-o qingping_air_monitor \
-i 300000 \
-m cdb9247ec7ab3302fd12450ae7453ab9f833639f109833f06c5d909991d62a3c
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/states
from HASS, filters by your module’sentityPrefixes
andallowedEntitySuffixes
, 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