You are browsing as a guest. Sign up (or log in) to start making projects!

44m 33s logged

Device-Triggered Chaining: Automations Now React to Device State Changes

The Rule Engine already supported schedule triggers and one hardcoded event source (the YOLO “person_detected” signal). This update adds a much more general capability: automations can now trigger off of any device state change, not just security events.

What’s New

  • Added emit_device_event(room, dev_type, command), a helper that builds an event name in the form {room}{dev_type}{command} (e.g. living_room_lg_tv_on) and forwards it to AutomationManager.trigger_event.
  • Wired this into the /api/tv endpoint: every time a TV command succeeds, the system now emits an event describing exactly what just happened.
  • This means a rule can be created like “when the Living Room TV turns on → turn on the Living Room lights” without any new trigger type — it reuses the same event-rule machinery already built for the security pipeline.
  • Event names are deterministic and human-readable, so building new automations from the dashboard just means picking the right device + command combo as the trigger.

Why This Matters

Until now, “smart” behavior meant either a fixed schedule or a single special-cased sensor event. This generalizes the pattern: any device action can become a trigger for any other device action, which is the actual foundation of “automation chaining” (TV on → lights on, plug on → AC on, etc.) rather than a one-off integration.

Challenges

  • emit_device_event is currently only called from the TV handler. The Tapo, Philips Hue, Yeelight, and Daikin handlers don’t emit events yet, so right now only TV state changes can kick off a chain — everything else is still a dead end as a trigger source. This is the next thing to close.
  • Needed to be careful that emitting the event happens after the command actually succeeds, not just after it’s requested, so a failed TV command doesn’t fire a chain based on a state change that never happened.

Next Steps

  • Add emit_device_event calls to the remaining device handlers (Tapo light/LED strip, Hue, Yeelight, Daikin) so any device can act as a trigger, not just TVs.
  • Once persistence for automation actions is fully solid across restarts, move on to energy monitoring for the Tapo smart plugs.
0
1

Comments 0

No comments yet. Be the first!