Closed ToastedTortilla closed 4 years ago
I also struggled wit that one - According to the documentation one should use the '>-' Syntax in the template sensor, but I also had no luck. This is my code I tried unsuccessfully:
value_template: >-
{{ "Outlook: " +
states('sensor.dark_sky_summary_0d') +
" " +
"Forecasted High of " +
states('sensor.dark_sky_daytime_high_temperature_0d') +
"C. " +
states('sensor.weather_week_text') }}
friendly_name: 'Irrigation Weather Outlook'
Hi,
Here is my weather outlook sensor. Hopefully you will be able to adapt it to your needs. The specific part you are interested in I think is <br>
at the end of the last set
line.
- platform: template
sensors:
irrigation_weather_outlook:
value_template: >
{% set current = state_attr('sensor.weather_api_current', 'current') %}
{% set current_conditons = current.condition.text %}
{% set max_high_temp = states('sensor.weather_api_forecast_max_temp_today') %}
{% set will_rain_today = states('sensor.weather_api_forecast_will_it_rain_today') %}
{% set will_rain_tomorrow = states('sensor.weather_api_forecast_will_it_rain_tomorrow') %}
{% set total_rain_today = states('sensor.weather_api_forecast_total_rain_today') %}
{% set total_rain_tomorrow = states('sensor.weather_api_forecast_total_rain_tomorrow') %}
{% set chance_of_rain_today = states('sensor.weather_api_forecast_chance_of_rain_today') %}
{% set chance_of_rain_tomorrow = states('sensor.weather_api_forecast_chance_of_rain_tomorow') %}
{% set rain_today = total_rain_today ~ 'mm / ' ~ chance_of_rain_today ~ '%' %}
{% set rain_tomorrow = total_rain_tomorrow ~ 'mm / ' ~ chance_of_rain_tomorrow ~ '%' %}
{% set outlook = 'Outlook: ' ~ current_conditons ~ ', High Temp ' ~ max_high_temp ~ '°C<br>' %}
{% if will_rain_today == '1' and will_rain_tomorrow == '1' %}
{% set outlook = outlook ~ 'Rain Today (' ~ rain_today ~ ') & Tomorrow (' ~ rain_tomorrow ~ ')' %}
{% elif will_rain_today == '1' %}
{% set outlook = outlook ~ 'Rain Today (' ~ rain_today ~ '), none tomorrow' %}
{% elif will_rain_tomorrow == '1' %}
{% set outlook = outlook ~ 'Rain Tomorrow (' ~ rain_tomorrow ~ ')' %}
{% else %}
{% set outlook = outlook ~ 'No rain forecast today or tomorrow.' %}
{% endif %}
{{ outlook }}
entity_picture_template: >
{% set current = state_attr('sensor.weather_api_current', 'current') %}
{% set is_day = current.is_day %}
{% set icon = current.condition.icon %}
{% set icon = icon.split('/')[-1] %}
{% set icon = icon.split('.')[0] %}
{% set is_day = current.is_day %}
{% if is_day %}
{{ '/local/icons/weather_icons/weather_api_day/' ~ icon ~ '.png' }}
{% else %}
{{ '/local/icons/weather_icons/weather_api_night/' ~ icon ~ '.png' }}
{% endif %}
I hope that helps...
The <br>
did the trick, I now have a multi-line weather outlook like in the screenshot! There were no combinations of whitespace, \n
and template parameters that I could get to work - thanks @kloggy.
In the sample screenshot, there is a two line weather outlook displayed under the cycle name. This is done using the sensor.irrigation_weather_outlook sensor.
I'm struggling in being able to create a multi-line state for that sensor that would display the information like it does in the screenshot. Every attempt I've made results in the newlines being ignored and it being a very long single line.
Would you be able to paste a sample of how you created your sensor.irrigation_weather_outlook so that is displays across two lines?