I need to make an automation that sends the alarm panel status on change detected to a notification. the problem i am having how to put the status in the message part of the notification.
i.e. how I can put the entity status into the notification message? I managed to do in in Node-Red by sending the msg.payload but I am having problems with the Automation
petro
(Petro)
November 23, 2019, 4:53pm
2
well, for one, i’m assuming your googling around for the word ‘status’ and that’s your problem. Status is not a thing in home assistant. You need to figure out the lingo so you know what to look for and what to ask.
hi petro … I think it should be State not Status.
I tried using the is_state but till now I did not manage.
what I need to send the state shown here:
petro
(Petro)
November 23, 2019, 5:13pm
4
well, post your current automation and I can help you tailor it. It’s going to require templates.
thanks for helping out … unfortunately I never used templates in automations. This is what I have working right now:
- id: '1574523322809'
alias: Alarm Panel Change send Notification
description: Alarm Panel Change send Notification
trigger:
- entity_id: alarm_control_panel.alarm_panel
platform: state
condition: []
action:
- data:
message: Alarm Status Changed
service: notify.hassio_notifier_s7
petro
(Petro)
November 23, 2019, 6:09pm
6
to get the state,
change your action to:
- data_template:
message: "Alarm status changed to {{ trigger.to_state.state }}"
service: notify.hassio_notifier_s7
1 Like
thanks again!
Tried it … but not working. In the logfile I got:
2019-11-23 19:23:41 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.alarm_panel_change_send_notification. Error rendering template for call_service at pos 1: UndefinedError: ‘trigger’ is undefined
What does trigger do?
Tinkerer
(aka DubhAd on GitHub)
November 23, 2019, 7:25pm
8
See the docs . It’ll work, as long as you don’t try to trigger it manually.
managed to make it work! thanks for your help!
The GUI does not let you use data_template, had to do it from the yaml file.
Ricks88
December 17, 2021, 11:29am
10
@petro
I am trying to make something simular, but i can not get it to work. Can you have a look at it maybe:
alias: AllergyInfo Air Quality Today
description: Luchtkwaliteit Vandaag Notification
trigger:
- platform: time
at: '13:00'
condition:
- alias: Test
condition: or
conditions:
- condition: state
entity_id: sensor.air_quality_today_names
state: Slecht
- condition: state
entity_id: sensor.air_quality_today_names
state: Ongezond
- condition: state
entity_id: sensor.air_quality_today_names
state: Zeer Ongezond
- condition: state
entity_id: sensor.air_quality_today_names
state: Gevraarlijk
action:
- data_template:
message: "Alarm status changed to {{ sensor.air_quality_today.state }}"
title: TEST
service: notify.rick_android
mode: single
It does not send any notification
petro
(Petro)
December 17, 2021, 11:31am
11
All you had to do was copy the code without changing anything aside from the notification service
EDIT: NEvermind, your trigger is a time trigger. Change the code to grab the state using the state method. i.e. states('your_entity_id_in_single_quotes')
2 Likes
Ricks88
December 17, 2021, 1:23pm
15
Thank you! it works
action:
- data_template:
message: '{{ states(''sensor.acc_air_today_info'') }}'
title: >-
Allery Info - Luchtkwaliteit is {{
states('sensor.air_quality_today_names') }} Vandaag
service: notify.rick_android
mode: single