Advertisement
dykandDK

HA - State change event with template condition

Aug 7th, 2020
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 0.68 KB | None | 0 0
  1. - id: 'test_anybody_home'
  2.   alias: 'Test: Somebody returns home'
  3.   description: ''
  4.   trigger:
  5.     event_type: state_changed
  6.     platform: event
  7.   condition:
  8.     - condition: template
  9.       # Only look at persons who changes state from 'not_home' to 'home'
  10.       value_template: >
  11.        {{ trigger.event.data.entity_id.startswith('person.')
  12.          and trigger.event.data.old_state is not none
  13.          and trigger.event.data.old_state.state == 'not_home'
  14.          and trigger.event.data.new_state is not none
  15.          and trigger.event.data.new_state.state == 'home' }}
  16.   action:
  17.   - data:
  18.       message: Somebody is now home
  19.     service: notify.notify
  20.   mode: single
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement