I made a binary sensor for the network connectivity for my NAS. This binary sensor is based on the ping platform. It works as intended.
I tried making a data_template to send the notifications but that does not work.
action:
service: notify.mobile_app_iphone_x_van_rutger
data_template:
{% if is_state("binary_sensor.synology_nas", "on") %}
title: Message From Computer
message: NAS is online
{% elif is_state("binary_sensor.synology_nas", "off" %}
title: Message From Computer
message: NAS is online
{% endif %}
I hope somone can help me as i’m pretty new to this. Hope to learn a bit more.
Templates can only go in a single field. You cannot template multiple fields. Jinja only returns a single field string. Also, you are missing the multi-line template identifier.
Example of single field
action:
service: notify.mobile_app_iphone_x_van_rutger
data_template:
title: blah #<--- SINGLE FIELD
message: blah #<--- SINGLE FIELD
what your stuff should look like
action:
service: notify.mobile_app_iphone_x_van_rutger
data_template:
title: Message From Computer
message: > #< THIS IS A MULTILINE TIMEPLATE IDENTIFIER
{% if is_state("binary_sensor.synology_nas", "on") %}
NAS is online
{% else %}
NAS is offline
{% endif %}
optimized
action:
service: notify.mobile_app_iphone_x_van_rutger
data_template:
title: Message From Computer
message: >
NAS is {{ 'on' if is_state("binary_sensor.synology_nas", "on") else 'off' }}line
Hi Petro,
is it possible to send a message with templated title?
i would like to see in the title the area_name of the entity that triggered the alarm:
service: notify.mobile_app_s21u_fl
data_template:
title: Rilevato Movimento in {{ area_name('{{trigger.to_state.entity_id}}') }}
message: {{ trigger.to_state.attributes.friendly_name }} <b>{{ trigger.to_state.state }}</b>
this is actually not working, it is back with ‘none’.