Skip to content

Commit 6a0817d

Browse files
committed
state_active code example
1 parent 1dc6d60 commit 6a0817d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

docs/reference.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,16 @@ will be ``None`` if the trigger is not a state trigger, if a different state var
822822
caused the state trigger, or if the state variable that caused the trigger was set for the
823823
first time (so there is no prior value).
824824

825+
.. code:: python
826+
827+
@state_trigger("binary_sensor.motion_detected == 'on'") # trigger on motion detection
828+
@state_active("input_boolean.motion_light_automation == 'on'") # but only if the automation is enabled
829+
def motion_controlled_light(**kwargs):
830+
log.info(f"got motion. turning on the lights")
831+
light.turn_on(entity_id="light.hallway")
832+
833+
834+
825835
@time_active
826836
^^^^^^^^^^^^
827837

0 commit comments

Comments
 (0)