Hi,
I am trying to get a message showing when there is a change of state from off to on, meaning the window is open. I want to get a notification with the name of the window. I have searched through this forum, and have tried different lines, still does not work. Automation shows as triggered, but I do not any kind of notification. Other automations with simple messages work fine. I tried the way it is below, I tried {{ trigger.name }} and {{ trigger.entity_id }}.
- id: '1596119039079'
alias: TEST window is open
description: ''
trigger:
- entity_id: binary_sensor.living_room_window_sensor
from: 'off'
platform: state
to: 'on'
- entity_id: binary_sensor.bedroom_window_sensor
from: 'off'
platform: state
to: 'on'
condition: []
action:
- data:
message: Window {{ trigger.to_state.attributes.friendly_name }} is open
service: notify.notify
mode: single
EDIT: Sorry, we’re not picking on you. We just have too much time on our hands! This is actually a very common mistake for people new to HA automations.
First, you can combine your trigger into one trigger, because you check both for the same state change.
Second, you need to use data_template instead of data as @Troon pointed out.
Try like this:
- id: '1596119039079'
alias: TEST window is open
description: ''
trigger:
- entity_id: binary_sensor.living_room_window_sensor, binary_sensor.bedroom_window_sensor
from: 'off'
platform: state
to: 'on'
action:
- data_template:
message: Window {{ trigger.to_state.attributes.friendly_name }} is open
service: notify.notify
would you be so kind to mark the post that helped you find the solution as the solution? This way other people who might have the same problem will immediately see the solution, instead of scrolling through all replies.
thanks for this post, it fixed my problem but, I used to have service: notify.mobile_app_iphone and worked fine setting it up with automation from Hassio and not messing with the config file. i don’t know what is the difference between notify.notify and that. plus this should be easy to set up notification from automation but that doesn’t work anymore!!