Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

state_active and state_trigger examples #626

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ docs/_build
.coverage
.vscode
.*.swp
.idea
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Installation
============

Option 1: Home Assistant Community Store (HACS)
--------------
-----------------------------------------------
ALERTua marked this conversation as resolved.
Show resolved Hide resolved

HACS is an integration in Home Assistant that allows you to
install custom integrations, frontend elements, and add-ons
Expand Down
20 changes: 20 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 Expand Up @@ -862,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
^^^^^^^^^^^^^^^^

Expand Down
Loading