Hi Forum,
I’m searching for a solution which involves a service template to create different notification messages according to the trigger entity for the automation. I’ve created a draft which doesn’t work and hope that a clever dude could help me finish this automation.
Here’s my code (where my problems are at the action lines):
- alias: 'NOTIFIKATION: Too hot in a room, test.'
trigger:
- platform: numeric_state
entity_id: sensor.living_temp
above: 25
- platform: numeric_state
entity_id: sensor.bath_temp
above: 30
- platform: numeric_state
entity_id: sensor.bed_temp
above: 25
- platform: numeric_state
entity_id: sensor.office_temp
above: 25
condition:
condition: and
conditions:
- condition: template
value_template: " {{ states.sensor.average_temperature.state <= states.sensor.yr_temperature.state }} "
action:
- service: notify.ios_iphone_xr
data_template:
title: "Temperature in room..."
message: >
{% if 'trigger.entity_id' = 'sensor.living_temp' %}
"Notification text 1"
{% if 'trigger.entity_id' = 'sensor.bath_temp' %}
"Notification text 2"
{% if 'trigger.entity_id' = 'sensor.bed_temp' %}
"Notification text 3"
{% if 'trigger.entity_id' = 'sensor.office_temp' %}
"Notification text 4"
{% endif %}
This look exactly as my intially thoughts. But what if I want to add a small amount of fixed text before the name of the trigger obejct, how do I implement that?
- service: notify.ios_iphone_xr
data_template:
title: "Temperature in room..."
message: >
small bit of text {{ trigger.to_state.name }} is {{ trigger.to_state.state }}
If it makes you feel warm and fuzzy, you can add quotes
- service: notify.ios_iphone_xr
data_template:
title: "Temperature in room..."
message: >
"small bit of text {{ trigger.to_state.name }} is {{ trigger.to_state.state }}"