I’m trying to create a notifcation message depending on the temperature, but I can’t get my elif to work. What is wrong with this code?
Error message: Message malformed: template value should be a string for dictionary value @ data[‘action’][0][‘data’]
service: notify.notify
data:
title: notification title
message:
{% set temp_now = 0 %}
temp_now = {{state_attr ('weather.mycity_forecast','temperature')}}
forecast_msg = ""
{% if temp_now < -10 %} forecast_msg = "msg1"
{% elif temp_now temp_now >-9 AND temp_now <5 %} forecast_msg = "msg2"
{% elif temp_now >6 AND temp_now <20 %} forecast_msg = "msg3"
{% elif temp_now >20 AND temp_now <25 %} forecast_msg = "msg 4"
{% else %} forecast_msg = "msg5"
{% endif %}
"Forecast: " {{ states("weather.mycity_forecast")}} " Temperature: " temp_now °C." forecast_msg
Thanks for helping a very newbie with yaml.