Petro identified the following error: original template contains a typo. Should be states function not state. See petroâs post below containing streamlined version.
well, that could be possible indeed,as the notify service appears no to need the data_template field to be able to use templatesâŠ
still, Ive always found that an odd thing, so use data_template if a template is needed.
sounds like something else is going on.
@ibennani : can you show us the automation in the developer-tools/state, so we can se it actually is âonâ ?
I know youâve used âinitial_state: trueâ but maybe you have restarted HA, and the automation got turned_off somehow? btw, you can leave out the initial_state, since states of automations are restored at startup. Unless of course you happen to switch these automations on/off during operation, and you want to make sure it is on at startup.
Also, concentrating on this automation, are you sure the binary_sensor has changed state? If not, it wouldnât triggerâŠ
Well he is triggering on a change to either state so heâs got twice the chance, but your right, it it donât change it donât trigger. but he does say : -
As for a message notification template not needing data_template - Thatâs just wrong in all sorts of ways "Itâs Agin te lawz âoâ natur " (btw, Iâm not blaming you for that ! )
since he can trigger manually, and the message is notified, we can conclude it has to do with either the trigger, or the condition block, not the action block.
a- automation is off
b- trigger isnât changing
c- condition isnât evaluated to true
d- syntax is incorrect (which not always throws an error)âŠ
- alias: 'Notify Hub Offline'
id: 'Notify Hub Offline'
# initial_state: 'on'
trigger:
# platform: template
# value_template: >
# {{ expand('group.hubs_binary_pinged')|map(attribute='entity_id')| list | join(', ')}}
platform: state
entity_id:
- binary_sensor.asus_router
- binary_sensor.hassio_mqtt
- binary_sensor.hassio_rpi4
- binary_sensor.ikea_tradfri
- binary_sensor.philips_hue
- binary_sensor.iungo
- binary_sensor.solaredge
- binary_sensor.timecapsule
- binary_sensor.synology
- binary_sensor.kantoor_thermostat
to: 'off'
for:
seconds: 30
condition: []
# condition: template
# value_template: >
# {{ state_attr('automation.notify_hub_offline','last_triggered') != none and
# as_timestamp(now()) | int -
# as_timestamp(state_attr('automation.notify_hub_offline','last_triggered'))
# | default(0) | int > 30 }}
#no extra notification condition, always send notification!
action:
# - service: homeassistant.update_entity
# entity_id: binary_sensor.hubs_offline
- service: notify.notify #HA app notification
data_template:
title: 'Hassio Rpi4 system message: Hub offline!'
message: >
{{as_timestamp(now())|timestamp_custom('%X')}} :
{{trigger.to_state.attributes.friendly_name}} has gone offline.
Check status to restore functionality.'
- service: notify.system #Pushbullet notification
data_template:
title: 'Hassio Rpi4 system message: Hub offline!'
message: >
{{as_timestamp(now())|timestamp_custom('%X')}} :
{{trigger.to_state.attributes.friendly_name}} has gone offline.
Check status to restore functionality.'
- service: persistent_notification.create
data_template:
title: 'Hassio Rpi4 system message: {{trigger.to_state.name}} offline!'
message: >
{{as_timestamp(now())|timestamp_custom('%X')}} :
{{trigger.to_state.name}} has gone offline. Check status to restore functionality.
notification_id: >
{{trigger.to_state.object_id}}-hub-notification
- service: script.intercom_message
data_template:
message_en: >
Hassio Rpi4 system message: Hub {{trigger.to_state.name}} has gone offline. Check status to
restore functionality.
message_nl: >
Hassio Rpi4 systeem bericht: Hub {{trigger.to_state.name}} is uitgeschakeld.
Controleer status om functionaliteit te herstellen.
and its got all the components you use. Only thing I can see is you are not using a list. Give that a try?
Also, use {{states('binary_sensor.skafferidorren')}} not {{state('binary_sensor.skafferidorren')}} (mind the sâŠ) which is what you missed in the template to begin with, so that wouldnât be correctâŠ
Hello.
This is one of those embarrassing moments when you post something, going away for a few hours and when you come back, the thread is flooded with comments telling youâre wrong.
âŠand all the comments are true!!!
Of course that row of code did not work. I have been around for to long to even say it dit workâŠ
Anyway, thanks a lot everyone for your commitment in my question. @petro, your solution did work as expected. THANKS!!!