From 8e4d5eb5fa48e0e9292a21b2dda02e819118704b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexey=20ALERT=20Rubash=D1=91ff?= Date: Tue, 6 Aug 2024 10:55:46 +0300 Subject: [PATCH 1/4] gitignore .idea --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 347bbce..d64cc9f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ docs/_build .coverage .vscode .*.swp +.idea From 1dc6d60260ce4a1bcd7aa76b3ccc40c0b0f10ceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexey=20ALERT=20Rubash=D1=91ff?= Date: Tue, 6 Aug 2024 11:16:45 +0300 Subject: [PATCH 2/4] docs bugfix --- docs/installation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/installation.rst b/docs/installation.rst index a1dd218..cfaf438 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -2,7 +2,7 @@ Installation ============ Option 1: Home Assistant Community Store (HACS) --------------- +----------------------------------------------- HACS is an integration in Home Assistant that allows you to install custom integrations, frontend elements, and add-ons From 6a0817da9dd6935cbf313f8cab1185a84136306d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexey=20ALERT=20Rubash=D1=91ff?= Date: Tue, 6 Aug 2024 11:17:02 +0300 Subject: [PATCH 3/4] state_active code example --- docs/reference.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/reference.rst b/docs/reference.rst index cc69c6f..bb16ef4 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -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 ^^^^^^^^^^^^ 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 4/4] 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 ^^^^^^^^^^^^^^^^