HomeAssistant: Difference between revisions

From Noisebridge
Jump to navigation Jump to search
Correct HA host (Pi4, not Beyla); fix local dashboard URL
Jet (talk | contribs)
m add link to noisebell
 
(One intermediate revision by one other user not shown)
Line 27: Line 27:
=== Open/Close Switch Group ===
=== Open/Close Switch Group ===


These devices turn on when Noisebridge opens and off when it closes:
These devices turn on when Noisebridge opens and off when it closes. All are assigned to the '''RNA Lounge''' area in HA.
 
Note: despite being called "lights", these are all <code>switch.*</code> entities (Tuya smart plugs powering physical lights) — not HA <code>light.*</code> entities.


{| class="wikitable"
{| class="wikitable"
! Device !! What It Is
! Entity ID !! What It Is
|-
|-
| <code>switch.flaschentaschen_socket_1</code> || [[Flaschentaschen]] LED display
| <code>switch.flaschentaschen_socket_1</code> || [[Flaschentaschen]] LED display
Line 37: Line 39:
|-
|-
| <code>switch.mini_smart_plug_socket_1</code> || [[Beyla]] lights (RNA Lounge)
| <code>switch.mini_smart_plug_socket_1</code> || [[Beyla]] lights (RNA Lounge)
|}
=== Other Devices ===
{| class="wikitable"
! Entity ID !! Notes
|-
| <code>switch.mini_smart_plug_5_socket_1</code> || Currently unavailable — not in any automation; may need reconnection
|-
| <code>light.home_assistant_connect_zwa_2_led</code> || Z-Wave dongle LED — not a room light
|}
|}


Line 43: Line 55:
The hallway decorative lights (<code>switch.mini_smart_plug_2_socket_1</code>) run on a sunset/sunrise schedule — on at dusk, off at dawn — independent of open/close status.
The hallway decorative lights (<code>switch.mini_smart_plug_2_socket_1</code>) run on a sunset/sunrise schedule — on at dusk, off at dawn — independent of open/close status.


== How the Noisebell Automation Works ==
== How the [[Noisebell]] Automation Works ==


[[Noisebell]] is a door sensor system that publishes the space's open/closed status. The Home Assistant automation polls the Noisebell status API every 5 minutes and updates a sensor (<code>sensor.noisebridge_open_status</code>). When that sensor changes state, HA triggers the Open/Close switch group.
The data flow from door sensor to smart plug:


Because Tuya smart plugs communicate through the cloud and are occasionally flaky, the automation includes retry logic: up to 5 attempts, 2 minutes apart, before giving up. If a new status change arrives mid-retry, the pending retries are cancelled and the new state takes over.
# '''Upstream API:''' <code>https://noisebell.extremist.software/status</code> — returns <code>open</code> or <code>closed</code>
# '''Poller:''' <code>noisebridge_status_updater.py</code> runs on [[Beyla]] via cron every 5 minutes, polls the upstream API, and POSTs to an HA webhook to fire the automation
# '''Automation:''' <code>automation.noisebell</code> — triggered by webhook, turns the Open/Close switch group on or off depending on status
# '''Retry logic:''' Up to 5 attempts, 2 minutes apart, until all switches match the target state — handles Tuya cloud and WiFi flakiness
# '''Mode: restart''' — if status changes again mid-retry, the loop restarts with the new target


Manual overrides are respected — if you've switched something by hand, the automation won't fight you.
Manual overrides are respected — retries only happen during the ~10 minute post-transition window, so hand-switching a plug won't get fought.


== Lights Dashboard ==
== Lights Dashboard ==
Line 63: Line 79:


To connect to the API you need a long-lived access token from the HA web UI. Store it in <code>.ha_env</code> (see <code>.ha_env.example</code> in the repo).
To connect to the API you need a long-lived access token from the HA web UI. Store it in <code>.ha_env</code> (see <code>.ha_env.example</code> in the repo).
== Known Issues ==
* <code>switch.mini_smart_plug_5_socket_1</code> is unavailable — may need reconnection or may control a light not yet assigned to any automation
* The status server (<code>noisebridge_status_server.py</code>, port 8099) exposes the HA sensor state over HTTP with no auth — this is intentional for easy local querying


== Maintainers ==
== Maintainers ==

Latest revision as of 19:00, 25 March 2026

Home Assistant is an open-source home automation platform. Noisebridge runs a local instance to coordinate smart plugs, lights, and space-status automations — things that need to respond to whether the space is open or closed, or to sunrise/sunset.

Configuration repo: github.com/nthmost/noisebridge-ha

Why Does Noisebridge Have This?

[edit | edit source]

Home Assistant lets us accumulate smart lights, switches, and other WiFi, Zigbee, and Z-Wave devices and do fancy integrated stuff with them. For example: automating the shutoff of all the lights in the RNA Lounge when someone flips the switch to close the space when they're the last one out.

The emphasis on local matters: we run HA on our own hardware, not in a vendor's cloud. This means automations work even when a manufacturer's API goes down.

Hardware

[edit | edit source]

Home Assistant Host

[edit | edit source]
  • Host: homeassistant.local (10.21.0.43:8123) — accessible on the NB LAN
  • Runs on a Raspberry Pi 4 (clear plastic case, Mary Poppins server rack)
  • The automation scripts live on Beyla (RNA Lounge server) and interact with HA over the local network

The Rack Phone

[edit | edit source]

There is an Android phone mounted in the server rack whose sole job is to add and configure new smart plugs and lights. Smart home devices (especially Tuya-based ones) require a phone app to do initial setup and join them to the WiFi. Rather than borrowing someone's personal phone each time, the rack phone stays provisioned with the relevant apps and credentials so any maintainer can onboard a new device without hassle.

What It Controls

[edit | edit source]

Open/Close Switch Group

[edit | edit source]

These devices turn on when Noisebridge opens and off when it closes. All are assigned to the RNA Lounge area in HA.

Note: despite being called "lights", these are all switch.* entities (Tuya smart plugs powering physical lights) — not HA light.* entities.

Entity ID What It Is
switch.flaschentaschen_socket_1 Flaschentaschen LED display
switch.salt_lamp_1_socket_1 Open sign
switch.mini_smart_plug_socket_1 Beyla lights (RNA Lounge)

Other Devices

[edit | edit source]
Entity ID Notes
switch.mini_smart_plug_5_socket_1 Currently unavailable — not in any automation; may need reconnection
light.home_assistant_connect_zwa_2_led Z-Wave dongle LED — not a room light

Hallway Deco Lights

[edit | edit source]

The hallway decorative lights (switch.mini_smart_plug_2_socket_1) run on a sunset/sunrise schedule — on at dusk, off at dawn — independent of open/close status.

How the Noisebell Automation Works

[edit | edit source]

The data flow from door sensor to smart plug:

  1. Upstream API: https://noisebell.extremist.software/status — returns open or closed
  2. Poller: noisebridge_status_updater.py runs on Beyla via cron every 5 minutes, polls the upstream API, and POSTs to an HA webhook to fire the automation
  3. Automation: automation.noisebell — triggered by webhook, turns the Open/Close switch group on or off depending on status
  4. Retry logic: Up to 5 attempts, 2 minutes apart, until all switches match the target state — handles Tuya cloud and WiFi flakiness
  5. Mode: restart — if status changes again mid-retry, the loop restarts with the new target

Manual overrides are respected — retries only happen during the ~10 minute post-transition window, so hand-switching a plug won't get fought.

Lights Dashboard

[edit | edit source]

A simple web dashboard shows the current state of all switches and auto-refreshes every 15 seconds:

Setup & Configuration

[edit | edit source]

Configuration is managed via ha_configure.py, which pushes automation and switch group definitions to HA via its REST API. This means the configuration is code — repeatable, version-controlled, and recoverable if the HA instance needs to be rebuilt.

To connect to the API you need a long-lived access token from the HA web UI. Store it in .ha_env (see .ha_env.example in the repo).

Known Issues

[edit | edit source]
  • switch.mini_smart_plug_5_socket_1 is unavailable — may need reconnection or may control a light not yet assigned to any automation
  • The status server (noisebridge_status_server.py, port 8099) exposes the HA sensor state over HTTP with no auth — this is intentional for easy local querying

Maintainers

[edit | edit source]