From 1dc4da743a3a473d7042a560ed3b4f0351eb9e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexey=20ALERT=20Rubash=D1=91ff?= Date: Tue, 6 Aug 2024 11:17:10 +0300 Subject: [PATCH] time_active code example --- docs/reference.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/reference.rst b/docs/reference.rst index bb16ef4..e4e5beb 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -872,6 +872,16 @@ true if the current time doesn't match any of the "not" (negative) specification allows multiple arguments with and without ``not``. The condition will be met if the current time matches any of the positive arguments, and none of the negative arguments. +.. 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 + @time_active("range(8:00, 22:00)") # but only during the day + def motion_controlled_light(**kwargs): + log.info(f"got motion. turning on the lights") + light.turn_on(entity_id="light.hallway") + + @webhook_trigger ^^^^^^^^^^^^^^^^