For the complete documentation index, see llms.txt. This page is also available as Markdown.

For Data Providers

This section covers simulation and real Home Assistant bridging.


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 .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 need DEPHY_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

Flag
Description

-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):

  1. Settings โ†’ Devices & Services โ†’ Integrations

  2. Click Add Integration โ†’ Search for HACS

  3. Authorize GitHub, restart if prompted

  4. In HACS: Explore & Download Repositories โ†’ Search โ€œXiaomi Homeโ€ (or โ€œXiaomi Miotโ€) โ†’ Download

  5. Restart Home Assistant

  6. Settings โ†’ Devices & Services โ†’ Add Integration โ†’ Xiaomi Home

  7. 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

  1. Click your user profile (bottom-left).

  2. Scroll to Long-Lived Access Tokens.

  3. Click Create Token, name it, and copy immediately.

  4. Store it securely โ€” itโ€™s shown only once.

Add it to .env as:


๐Ÿ‘Œ 4. Configure the Bridge Environment

  1. Clone the repo (if not already):

  2. Install Deno (see deno.land).

  3. Add .env:

  4. 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

Flag
Description

-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โ€™s entityPrefixes and allowedEntitySuffixes, 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

  1. Open your Topic in the frontend.

  2. Ensure Access Mode and grants/subscriptions are valid.

  3. Wait for one auth epoch (~5 min).

  4. Events will appear if you are authorized and the bridge is publishing successfully.


Last updated