Hello everyone,
I’ll first try to explain what I want to achieve and then talk about the way I try to achieve it.
I want my dashboard to change, depending on weather forecast values.
For example: an icon is supposed to show the rain animation and get the rain icon, when rain is coming.
Only when rain is coming, I want the hourly forecast to show up on my dashboard.
However, if it is cloudy, then I do not want to see the hourly forecast but still want the cloud animation and icon.
If it is cloudy and rainy, then rain should get the priority.
This leads me to my first problem: I do not know how to prioritize if-statements.
I have tried to create a template sensor that lists the weather conditions of the next hours.
{% for i in range (8) -%}
{{(state_attr('sensor.new_weather_sensor_hourly',
'forecast')[i]['condition'])}}
{% if state_attr("sensor.new_weather_sensor_hourly",
"forecast")[i]["condition"] == 'rainy' %}
test
{% endif%}
{% endfor -%}
My second problem: That does not really help me though as I don’t know how to access the values from the for loop and check for “rain”, “snow” and so on. Also, ‘test’ is printed every time ‘rainy’ comes up in the list.
With namespace I only found information about numbers.
When creating a list, I do not know what to filter for as the [condition] part is not a state so this format won’t work:
state: "{{ **states** | selectattr('state', 'in', ['unavailable', 'unknown', 'none']) | list | count }}"
{% set my_list = [ (state_attr('sensor.new_weather_sensor_hourly',
'forecast', ) [0] ['condition']),
(state_attr('sensor.new_weather_sensor_hourly',
'forecast', ) [1] ['condition']),
(state_attr('sensor.new_weather_sensor_hourly',
'forecast', ) [2] ['condition']),
(state_attr('sensor.new_weather_sensor_hourly',
'forecast', ) [3] ['condition']),
(state_attr('sensor.new_weather_sensor_hourly',
'forecast', ) [4] ['condition']),
(state_attr('sensor.new_weather_sensor_hourly',
'forecast', ) [5] ['condition']),
(state_attr('sensor.new_weather_sensor_hourly',
'forecast', ) [6] ['condition']),
(state_attr('sensor.new_weather_sensor_hourly',
'forecast', ) [7] ['condition']),
(state_attr('sensor.new_weather_sensor_hourly',
'forecast', ) [8] ['condition']) ] -%}
Does anyone know of a good way to get prioritized information from my forecast sensor in another sensor that I can then base decisions on for my dashboard? This has cost me hours so far and I have no clue what direction to go now…
I appreciate the help