YR Weather sensor state as description instead number

Edited YR Weather from this:
1212

to this:

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","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]}}'
        entity_picture_template: "{{ state_attr('sensor.yr_symbol','entity_picture') }}"

from here:

Maybe add this to YR component

I cant get this to work (FYI: I am new at HA…)
The symbol is empty and just showing “Unknown” history when using the configuration.
Am I missing something?

Nice workaround. But I am not able to make it work, getting config error:

Error loading /config/configuration.yaml: expected ‘<document start>’, but found ‘<block sequence start>’ in “/config/sensors/sensor_environment.yaml”, line 33, column 2

Tried to play with your value_templae code, without luck:
value_template: '{%set list2 = "0","Clear sky","Fair","Partly cloudy","Cloudy"%}{{list2[states.sensor.yr_symbol.state|int]}}'

Where do I go wrong?

You only are using about 10% of the value template posted. It works in my setup but your ‘copy’ is very truncated.

Copied everything from the post first and getting config errors.

Did truncate for posting purposes only. But still getting configuration error. Should have made the config validation regardless of short or long list(?)

One again. - user-keyboard interface error. My bad.
One spaceing to the left of my sensor code, Arggh…

And in my istalation the YR sensor is named “sensor.weather_symbol” not “sensor.yr_symbol”. Be aware.

Thanks for providing this. However your values with weather states is wrong, it doesn’t 100% correspond with the number. Values 16 to 19 and 35 to 39 don’t exist on yr.no, so these need to be catched otherwise it will result in error or wrong labeling.

This a corrected value_template:

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","16","17","18","19","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","35","36","37","38","39","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.weather_symbol.state|int]}}'
entity_picture_template: "{{ state_attr('sensor.weather_symbol','entity_picture') }}"
2 Likes