description: ""
trigger:
- type: temperature
platform: device
device_id: xxxxxxxxxxxxxx
entity_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
domain: sensor
above: 25
below: 10
for:
hours: 0
minutes: 1
seconds: 0
- type: temperature
platform: device
device_id: xxxxxxxxxxxxxxxxxxxx
entity_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
domain: sensor
above: 25
below: 10
for:
hours: 0
minutes: 1
seconds: 0
condition: []
action: []
mode: single
#combined multiple sensor notifications
1 messages · Page 1 of 1 (latest)
I want to send a notification if any one of these sensor is out of range, a notification will be sent with temperature and humidty values
for a single sensor it is simple ```action:
- service: notify.persistent_notification
data:
title: Waste Room Temperature Alert!!
message: >-
current Temperature is:
{{states('sensor.a4_cxxxxxxxx_temperature',with_unit=true) }}
Humidity is: {{
states('sensor.a4_xxxxxxxxxxxxxxx_humidity',with_unit=true) }} - service: notify.ha_temp_email
data:
title: Waste Room Temperature Alert!!
message: >-
current Temperature is:
{{states('sensor.a4_xxxxxxxxxxxxxxxxx_temperature',with_unit=true) }}
Humidity is: {{
states('sensor.a4_xxxxxxxxxxxxxxxx_humidity',with_unit=true) }}
enabled: true
mode: single```
came up with this service: notify.persistent_notification data: title: Waste Room Temperature Alert!! message: >- Temperature out of range : {{ trigger.to_state.name }} is above 18 Humidity is: {{ states('sensor.a4_xxxxxxxxxxxxxxx_humidity',with_unit=true) }}
got this error Error rendering data template: UndefinedError: 'trigger' is undefined
are you using the RUN button in the automation GUI to test?
in that case there is no trigger, so trigger variables won't work
BTW no need to censor those entity_ids en device_ids, they are just randomly created by HA to generate a unique id
Think of it this way, if you press RUN, how should HA know which of the two triggers to use?
looks fine, I would use state triggers though
you should be able to test the automation by changing the state in devtools > states, but I'm not 100% sure if that works with device trigger
any example?
Wait, numeric state in this case
- platform: numeric_state
entity_id: xxxxxx
above: 25
below: 10
for:
minutes: 1
not working
That's not really a lot of information you are giving. What's not working?
can't save it gives error at data(0)
let me post the complete automation
notification generated ```Pump room temperature Alert!!
is above 24C
description: ""
trigger:
- platform: numeric_state
entity_id: sensor.pump_room1_f7e5_temperature
for:
hours: 0
minutes: 1
seconds: 0
above: 24
- platform: numeric_state
entity_id: sensor.a4_c1_38_85_14_c4_14c4_temperature
above: 24
for:
hours: 0
minutes: 1
seconds: 0
- platform: numeric_state
entity_id: sensor.a4_c1_38_85_14_c4_14c4_temperature
for:
hours: 0
minutes: 1
seconds: 0
below: 15
- platform: numeric_state
entity_id: sensor.pump_room1_f7e5_temperature
for:
hours: 0
minutes: 1
seconds: 0
below: 15
condition: []
action:
- service: notify.persistent_notification
data:
title: Pump room temperature Alert!!
message: "{{ trigger.entity_id }} is above 24C"
mode: single
why I can't save new automation even after changing data? there is no save button
no mention of entity which trigged it
notification Pump room temperature Alert!! is above 24C
Are you pressing the RUN button in the GUI to test?
That doesn't work with trigger variables. How do you expect HA to tell which entity triggered an automation if it wasn't triggered by an entity
I already told you that here #1159757635172696114 message
Hmm. I should change the trigger value to test it
Change the state in developer tools > states
Okay
can't change it in dev tools > states
found a way
sensor.pump_room1_f7e5_temperature is above 24C```
worked
Sure you can
Change the value in the circle and then press the button to test
Change the name in the entity details
Yes it worked with this method
Entity details?
Can't post screen shots here
Here
So should change entity I'd?
sensor.pump_room1_f7e5_temperature is above 24C``` this was generated as notification
Name is correct I want name in notifications
Something on these line ``` Pump room temperature Alert!!
Pump room temperature is 30C which is above 24C
Pump 1 Temperature is above 24C```
Pump 2 Temperature is above 24C```
how to change the notifcation if temp goes below the range?
Lots of options
- Two different automations
- use a choose action and trigger ids
- use #templates-archived to define the message based on the
to_stateof the trigger
The one you prefer
Btw, you can use one trigger for all entities
alias: Pump temperature trial
trigger:
- platform: numeric_state
entity_id:
- sensor.pump_room1_f7e5_temperature
- sensor.a4_c1_38_85_14_c4_14c4_temperature
for:
minutes: 1
above: 24
id: high
- platform: numeric_state
entity_id:
- sensor.a4_c1_38_85_14_c4_14c4_temperature
- sensor.pump_room1_f7e5_temperature
for:
minutes: 1
below: 15
id: low
action:
- if:
- condition: trigger
id: high
then:
- service: notify.persistent_notification
data:
title: "{{ trigger.to_state.name | title }} temperature Alert!!"
message: "{{ trigger.to_state.name }} is above 24C"
else:
- service: notify.persistent_notification
data:
title: "{{ trigger.to_state.name | title }} temperature Alert!!"
message: "{{ trigger.to_state.name }} is below 15C"
mode: single
is the 2nd option with the choose
alias: Pump temperature trial
trigger:
- platform: numeric_state
entity_id:
- sensor.pump_room1_f7e5_temperature
- sensor.a4_c1_38_85_14_c4_14c4_temperature
for:
minutes: 1
above: 24
id: high
- platform: numeric_state
entity_id:
- sensor.a4_c1_38_85_14_c4_14c4_temperature
- sensor.pump_room1_f7e5_temperature
for:
minutes: 1
below: 15
id: low
action:
- service: notify.persistent_notification
data:
title: "{{ trigger.to_state.name | title }} temperature Alert!!"
message: "{{ trigger.to_state.name }} is {{ 'above 24' if trigger.id == 'high' else 'below 15' }}C"
mode: single
And
is option 3
both use ids?
Basically I only use high in both examples
But both examples use trigger ids yes
You can also use other ways, you can use the state as well
used this and this is how it looked like Pump 1 Temperature temperature Alert!! Pump 1 Temperature is below 15C
Pump 1 Temperature is above 24C
Okay, I assume the entity is named Pump 1 then
yes
So it works then