Skip to content

State Trigger Example

Matthew Scoville edited this page Sep 13, 2020 · 2 revisions

A simple State Trigger that fires when the state of group.device_trackers switches to not_home for more than 2 minutes (to prevent spamming if the state flips on/off)

It then sends a message to the log.

The state trigger can be used to trigger when doors open or people leave. It could also be used to trigger when a thermostat turns on/off to check if windows are all closed.

@state_trigger("group.device_trackers == 'not_home'") def state_trigger(): log.info(f"State Trigger test:") trig_info = task.wait_until( state_trigger="group.device_trackers == 'home'", timeout=120 ) if trig_info["trigger_type"] == "timeout": log.info(f"State Trigger test: fail") pass else: log.info(f"State Trigger test: pass") pass
Clone this wiki locally