Skip to content

Commit

Permalink
state_active code example
Browse files Browse the repository at this point in the history
  • Loading branch information
ALERTua committed Aug 6, 2024
1 parent 1dc6d60 commit 6a0817d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,16 @@ will be ``None`` if the trigger is not a state trigger, if a different state var
caused the state trigger, or if the state variable that caused the trigger was set for the
first time (so there is no prior value).

.. code:: python
@state_trigger("binary_sensor.motion_detected == 'on'") # trigger on motion detection
@state_active("input_boolean.motion_light_automation == 'on'") # but only if the automation is enabled
def motion_controlled_light(**kwargs):
log.info(f"got motion. turning on the lights")
light.turn_on(entity_id="light.hallway")
@time_active
^^^^^^^^^^^^

Expand Down

0 comments on commit 6a0817d

Please sign in to comment.