Template YR Weather sensor

YR Weather’s “yr_symbol” entity shown like this:
1212

Here is list of all YR Weather states:

Made Template Sensor from that list:
value_template: '{%set list2 = "0","Clear sky","Fair","Partly cloudy","Cloudy","Rain showers","Rain showers and thunder","Sleet showers","Snow showers","Rain","Heavy rain","Heavy rain and thunder","Sleet","Snow","Snow and thunder","Fog","Sleet showers and thunder","Snow showers and thunder","Rain and thunder","Sleet and thunder","Light rain showers and thunder","Heavy rain showers and thunder","Light sleet showers and thunder","Heavy sleet showers and thunder","Light snow showers and thunder","Heavy snow showers and thunder","Light rain and thunder","Light sleet and thunder","Heavy sleet and thunder","Light snow and thunder","Heavy snow and thunder","Light rain showers","Heavy rain showers","Light sleet showers","Heavy sleet showers","Light snow showers","Heavy snow showers","Light rain","Light sleet","Heavy sleet","Light snow","Heavy snow"%}{{list2[states.sensor.yr_symbol.state|int]}}'

Which shows like this:
2323

How can I combine them to one sensor like this:
3434

add an icon_template to the sensor template for icons or a entity_picture_template for pictures. I’m not sure where those fancy Icons are located. As for the name Weather, just set the friendly name. This is all covered in the documentation for template sensor:

Thanks, but there are 100-150 icons and doing “if” for each maybe not best way,

Is it possible to keep “yr_symbol” entity and edit the attribute/state to my custom one?

No, map the icons to the template just like you did with the strings. Make list2 with the same order as list2 in your example, except replace the names with the icon name:

example:

{% set list2 = [ 'mdi:icon1', 'mdi:icon2'] %}
{{ list2[states.sensor.yr_symbol.state|int] %}

Literally no different from what you did, same amount of work.

There are 50 weather states and 2-3 icons for each for day/night/winter, so it is not 1:1 list

You could try to pull the icon from the sensor itself. I do not know if it will work. You’d have to verify:

{{ state_attr('sensor.yr_symbol', 'icon') }}
1 Like

looks like it works, you’d just have to have an if statement checking for None to make sure you always have an icon.

1 Like

Thanks for the direction, actually its much easier than expected here is result:

555

/configuration.yaml:

sensor:
  - platform: template
    sensors:
      yrwthr:
        value_template: '{%set list2 = "0","Clear Sky","Fair","Partly Cloudy","Cloudy","Rain Showers","Rain Showers And Thunder","Sleet Showers","Snow Showers","Rain","Heavy Rain","Heavy Rain And Thunder","Sleet","Snow","Snow And Thunder","Fog","0","0","0","0","Sleet Showers And Thunder","Snow Showers And Thunder","Rain And Thunder","Sleet And Thunder","Light Rain Showers And Thunder","Heavy Rain Showers And Thunder","Light Sleet Showers And Thunder","Heavy Sleet Showers And Thunder","Light Snow Showers And Thunder","Heavy Snow Showers And Thunder","Light Rain And Thunder","Light Sleet And Thunder","Heavy Sleet And Thunder","Light Snow And Thunder","Heavy Snow And Thunder","0","0","0","0","0","Light Rain Showers","Heavy Rain Showers","Light Sleet Showers","Heavy Sleet Showers","Light Snow Showers","Heavy Snow Showers","Light Rain","Light Sleet","Heavy Sleet","Light Snow","Heavy Snow"%}{{list2[states.sensor.yr_symbol.state|int]}}'
        entity_picture_template: "{{ state_attr('sensor.yr_symbol','entity_picture') }}"
2 Likes

Hi
Old thread I know but maybe you can still help

It is not more possible to fetch the icons directly from met.no
How does this set list work? From where does this entiry_picture template get its pictures?