Created
July 28, 2020 10:01
-
-
Save AlexxIT/99ff662fe26e1db9afe27f2a4dd492e8 to your computer and use it in GitHub Desktop.
Home Assistant Context Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
automation: | |
- trigger: | |
platform: numeric_state | |
entity_id: switch.sonoff_th | |
value_template: >- | |
{% if states.switch.sonoff_th.context.user_id and states.switch.sonoff_th.state == 'on' %} | |
1{% else %}0{% endif %} | |
above: 0 | |
action: | |
service: persistent_notification.create | |
data: | |
message: "Включился юзером" | |
- trigger: | |
platform: numeric_state | |
entity_id: switch.sonoff_th | |
value_template: >- | |
{% if states.switch.sonoff_th.context.id == states.automation.every_munute.context.id and states.switch.sonoff_th.state == 'on' %} | |
1{% else %}0{% endif %} | |
above: 0 | |
action: | |
service: persistent_notification.create | |
data: | |
message: "Включился автоматизацией" | |
- alias: every_munute | |
trigger: | |
platform: time_pattern | |
minutes: "*" | |
action: | |
service: homeassistant.toggle | |
entity_id: switch.sonoff_th |
Для начинающих пользователей как этим воспользоватся?)
{% if trigger.to_state.context.user_id and trigger.to_state.state == 'on' %}
тоже будет работать?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
platform: numeric_state
используется потому чтоplatform: state
не поддерживает шаблоны, аplatform: template
реагирует вообще на все события в системе.