Dear community,
I have maybe stupid question: Im using the NINA integration and my Home Assistant is forwarding me all messages to my phone. The action is quite simple:
Trigger:
platform: state
entity_id:
- binary_sensor.warning_rheinfelden_baden_stadt_lorrach_baden_wurttemberg_1
to: "on"
id: Nina-1
Action:
- conditions:
- condition: trigger
id:
- Nina-1
sequence:
- service: notify.mobile_app_marco_s_iphone
data:
title: >-
{{
state_attr('binary_sensor.warning_rheinfelden_baden_stadt_lorrach_baden_wurttemberg_1',
'headline') }}
message: >-
Von {{
as_timestamp(state_attr('binary_sensor.warning_rheinfelden_baden_stadt_lorrach_baden_wurttemberg_1',
'start')) | timestamp_custom('%d.%m.%Y %-H:%M') }} bis {{
as_timestamp(state_attr('binary_sensor.warning_rheinfelden_baden_stadt_lorrach_baden_wurttemberg_1',
'expires')) | timestamp_custom('%d.%m.%Y %-H:%M') }}
{{
state_attr('binary_sensor.warning_rheinfelden_baden_stadt_lorrach_baden_wurttemberg_1',
'description') }}
So far so good, all works as expected. Within the two lasst nights, I had some alarms without an “expires” value:
Unfortunately the Action failed, because it cant convert the empty values (expires) to a custom time stamp as requested.
So my plan is:
If expires is empty/not set, ignore the part and only send the beginning of the message like this:
message: >-
Von {{
as_timestamp(state_attr('binary_sensor.warning_rheinfelden_baden_stadt_lorrach_baden_wurttemberg_1',
'start')) | timestamp_custom('%d.%m.%Y %-H:%M') }}
{{
state_attr('binary_sensor.warning_rheinfelden_baden_stadt_lorrach_baden_wurttemberg_1',
'description') }}
if the expires is set, send the whole message as in the very top. Is there an easy way or do this in the existing code without having multiple actions?
best regards
Marco