Sensor Wind compass - up for grabs

follow-up:
please have a look at How to shorten/join this template?

how @datamonkey helped me create this even shorter and way more intelligent template:

  wind_compass:
    friendly_name: Windrichting
    value_template: >
      {{ states('sensor.br_wind_direction_azimuth') }}
    friendly_name_template: >
      {{ states('sensor.wind_compass_abbreviation') }}
    unit_of_measurement: '°'
    entity_picture_template: >
      {% set degrees = states('sensor.br_wind_direction_azimuth')|float %}
      {% set path = '/local/weather/wind_compass/' %}
      {% set ext = '.png' %}
      {{path-}}
      {%- if 354.38 <= degrees or degrees <= 5.62 -%} 0
      {%- else -%}
      {{ ( ((degrees/11.25)|round )*11.25 )| round}}
      {%- endif -%}
      {{-ext-}}

so cool.

3 Likes

Wow. Nifty : )

I saw your full solution here.
Maybe you can define an array of jsons and have all your mappings in one place.
Not sure if you can share it between template sensors, you would need to try.

{% set dir = [
  {"abr": "N" ,   "friendly" : "North"} ,
  {"abr": "NbE",  "friendly" : "North by East"},
  {"abr": "NNE",  "friendly" : "North North East"},
  {"abr": "NEbN", "friendly" : "North East by North"},
  ...
  {"abr": "N" ,   "friendly" : "North"} 
] %}

{% set degrees = 7  %}
{% set d = (degrees/11.25)|round  %}

Abbreviation = {{dir[d].abr}}
Friendly = {{dir[d].friendly}}
Picture =  {{dir[d].abr|lower}}.png

returns

Abbreviation = NbE
Friendly = North by East
Picture = nbe.png

this would require you to rename the pictures, or you add another pair in the array to link to the picture name

thanks to @petro its getting even better:

  wind_compass_abbreviation:
    friendly_name: Windrichting Afkorting
    value_template: >
      {% set degrees = states('sensor.br_wind_direction_azimuth')|float %}
      {% set abbr = ['N','NNNO','NNO','ONNO','NO','NONO','ONO','OONO','O','OOZO','OZO','ZOZO','ZO',
                     'OZZO','ZZO','ZZZO','Z','ZZZW','ZZW','ZZW','ZW','ZWZW','WZW','WWZW','W','WWNW',
                     'WNW','NWNW','NW','WNNW','NNW','NNNW' ] %}
      {%- set i = ((degrees / 11.25) | round(0)) | int %}
      {%- set i = 0 if i == 32 else i %}
      {{ abbr[i] }}

  wind_compass_direction:
    friendly_name: Windrichting
    value_template: >
      {% set degrees = states('sensor.br_wind_direction_azimuth')|float %}
      {% set direction = ['Noord','Noord Ten Oosten','Noordnoordoost','Noordoost Ten Noorden','Noordoost',
                          'Noordoost Ten Oosten','Oostnoordoost','Oost Ten Noorden','Oost',
                          'Oost Ten Zuiden','Oostzuidoost','Zuidoost Ten Oosten','Zuidoost',
                          'Zuidoost Ten Zuiden','Zuidzuidoost','Zuid Ten Oosten','Zuid',
                          'Zuid Ten Westen','Zuidzuidwest','Zuidwest Ten Zuiden','Zuidwest',
                          'Zuidwest Ten Westen','Westzuidwest','West Ten Zuiden','West',
                          'West Ten Noorden','Westnoordwest','Noordwest Ten Westen','Noordwest',
                          'Noordwest Ten Noorden','Noordnoordwest','Noord Ten Westen'] %}
      {%- set i = ((degrees / 11.25) | round(0)) | int %}
      {%- set i = 0 if i == 32 else i %}
      {{ direction[i] }}
2 Likes

now this I must study :wink:

have a look at the post above for 2 separate sensors with comparable lists. Is already really very nice.
Combining those into 1 is the next challenge…
thanks for the suggestion , and please don’t hold back ;

meanwhile, here’s a sensor with all info in 1:

  wind_compass_direction:
    friendly_name_template: >
      {% set degrees = states('sensor.br_wind_direction_azimuth')|float %}
      {% set abbr = states('sensor.wind_compass_abbreviation') %}
      {{abbr}} : {{degrees}} °
    value_template: >
      {% set degrees = states('sensor.br_wind_direction_azimuth')|float %}
      {% set direction = ['Noord','Noord Ten Oosten','Noordnoordoost','Noordoost Ten Noorden','Noordoost',
                          'Noordoost Ten Oosten','Oostnoordoost','Oost Ten Noorden',
                          'Oost','Oost Ten Zuiden','Oostzuidoost','Zuidoost Ten Oosten','Zuidoost',
                          'Zuidoost Ten Zuiden','Zuidzuidoost','Zuid Ten Oosten',
                          'Zuid','Zuid Ten Westen','Zuidzuidwest','Zuidwest Ten Zuiden','Zuidwest',
                          'Zuidwest Ten Westen','Westzuidwest','West Ten Zuiden',
                          'West','West Ten Noorden','Westnoordwest','Noordwest Ten Westen','Noordwest',
                          'Noordwest Ten Noorden','Noordnoordwest','Noord Ten Westen'] %}
      {%- set i = ((degrees / 11.25) | round(0)) | int %}
      {%- set i = 0 if i == 32 else i %}
      {{ direction[i] }}
    entity_picture_template: >
      {%- set degrees = states('sensor.br_wind_direction_azimuth')|float %}
      {%- set path = '/local/weather/wind_compass/' %}
      {%- set ext = '.png' %}
      {%- set num = ((degrees // 11.25) * 11.25 // 1) | int %}
      {%- set num  = 0 if num  == 360 else num %}
      {{ "{}{}{}".format(path,num,ext) }}

42

2 Likes

Is it possible to show this on the map component in Home assistant ?

I have not tried putting this sensor on the map. Think that sensor need latitude and longitude attributes, and it will display automatically.

Thanks guys for the job, work well to track ISS.

entities:
  - entity: sensor.iss_compass_direction
style: |
  ha-card {
    background: url(/local/pictures/WindCompass/windrose2.png);
    color: red;
    text-shadow: 1px 1px 0 #FFF;
  }
type: glance

Sans%20titre

Can someone post how they setup the template? I tried but each time the Check Configuration it says something about format error in code. Now is this to be used under Sensor on the config or something else? I love the idea in using this but can’t seem to get the coding right. I see where some shorten it but I don’t think that works with the Yr.no sensor.

Hi!

I use Tomahawk’s code, and here is simple Lovelace Wind compass card:

Sensors:

  - platform: template
    sensors: 
      wind_compass_abbreviation:
        value_template: >-
          {% if 354.38 <= states('sensor.weather_wind_direction')|float <= 5.62 %}
             N
          {% elif 5.63 <= states('sensor.weather_wind_direction')|float <= 16.87 %}
             NbE
          {% elif 16.88 <= states('sensor.weather_wind_direction')|float <= 28.12 %}
             NNE
          {% elif 28.13 <= states('sensor.weather_wind_direction')|float <= 39.37 %}
             NEbN
          {% elif 39.38 <= states('sensor.weather_wind_direction')|float <= 50.62 %}
             NE
          {% elif 50.63 <= states('sensor.weather_wind_direction')|float <= 61.87 %}
             NEbE
          {% elif 61.88 <= states('sensor.weather_wind_direction')|float <= 73.12 %}
             ENE
          {% elif 73.13 <= states('sensor.weather_wind_direction')|float <= 84.37 %}
             EbN
          {% elif 84.38 <= states('sensor.weather_wind_direction')|float <= 95.62 %}
             E
          {% elif 95.63 <= states('sensor.weather_wind_direction')|float <= 106.87 %}
             EbS
          {% elif 106.88 <= states('sensor.weather_wind_direction')|float <= 118.12 %}
             ESE
          {% elif 118.13 <= states('sensor.weather_wind_direction')|float <= 129.37 %}
             SEbE
          {% elif 129.38 <= states('sensor.weather_wind_direction')|float <= 140.62 %}
             SE
          {% elif 140.63 <= states('sensor.weather_wind_direction')|float <= 151.87 %}
             SEbS
          {% elif 151.88 <= states('sensor.weather_wind_direction')|float <= 163.12 %}
             SSE
          {% elif 163.13 <= states('sensor.weather_wind_direction')|float <= 174.37 %}
             SbE
          {% elif 174.38 <= states('sensor.weather_wind_direction')|float <= 185.62 %}
             S
          {% elif 185.63 <= states('sensor.weather_wind_direction')|float <= 196.87 %}
             SbW
          {% elif 196.88 <= states('sensor.weather_wind_direction')|float <= 208.12 %}
             SSW
          {% elif 208.13 <= states('sensor.weather_wind_direction')|float <= 219.37 %}
             SWbS
          {% elif 219.38 <= states('sensor.weather_wind_direction')|float <= 230.62 %}
             SW
          {% elif 230.63 <= states('sensor.weather_wind_direction')|float <= 241.87 %}
             SWbW
          {% elif 241.88 <= states('sensor.weather_wind_direction')|float <= 253.12 %}
             WSW
          {% elif 253.13 <= states('sensor.weather_wind_direction')|float <= 264.37 %}
             WbS
          {% elif 264.38 <= states('sensor.weather_wind_direction')|float <= 275.62 %}
             W
          {% elif 275.63 <= states('sensor.weather_wind_direction')|float <= 286.87 %}
             WbN
          {% elif 286.88 <= states('sensor.weather_wind_direction')|float <= 298.12 %}
             WNW
          {% elif 298.13 <= states('sensor.weather_wind_direction')|float <= 309.37 %}
             NWbW
          {% elif 309.38 <= states('sensor.weather_wind_direction')|float <= 320.62 %}
             NW
          {% elif 320.63 <= states('sensor.weather_wind_direction')|float <= 331.87 %}
             NWbN
          {% elif 331.88 <= states('sensor.weather_wind_direction')|float <= 343.12 %}
             NNW
          {% elif 343.13 <= states('sensor.weather_wind_direction')|float <= 354.37 %}
             NbW
          {% endif %}

Lovelace:

  elements:
    - entity: sensor.wind_compass_abbreviation
      image: /local/WindCompass/E.png
      state_image:
        'N': /local/WindCompass/N.png
        NbE: /local/WindCompass/NbE.png
        NNE: /local/WindCompass/NNE.png
        NEbN: /local/WindCompass/NEbN.png
        NE: /local/WindCompass/NE.png
        NEbE: /local/WindCompass/NEbE.png
        ENE: /local/WindCompass/ENE.png
        EbN: /local/WindCompass/EbN.png
        E: /local/WindCompass/E.png
        EbS: /local/WindCompass/EbS.png
        ESE: /local/WindCompass/ESE.png
        SEbE: /local/WindCompass/SEbE.png
        SE: /local/WindCompass/SE.png
        SEbS: /local/WindCompass/SEbS.png
        SSE: /local/WindCompass/SSE.png
        SbE: /local/WindCompass/SbE.png
        S: /local/WindCompass/S.png
        SbW: /local/WindCompass/SbW.png
        SSW: /local/WindCompass/SSW.png
        SWbS: /local/WindCompass/SWbS.png
        SW: /local/WindCompass/SW.png
        SWbW: /local/WindCompass/SWbW.png
        WSW: /local/WindCompass/WSW.png
        WbS: /local/WindCompass/WbS.png
        W: /local/WindCompass/W.png
        WbN: /local/WindCompass/WbN.png
        WNW: /local/WindCompass/WNW.png
        NWbW: /local/WindCompass/NWbW.png
        NW: /local/WindCompass/NW.png
        NWbN: /local/WindCompass/NWbN.png
        NNW: /local/WindCompass/NNW.png
        NbW: /local/WindCompass/NbW.png
      style:
        left: 50%
        top: 50%
        width: 100%
      type: image
  image: /local/WindCompass/background.png
  type: picture-elements

:beers:

1 Like

try:

          {%- set degrees = states('sensor.winddirection')|float %}
          {%- set path = '/local/weather/wind_compass/' %}
          {%- set ext = '.png' %}
          {%- set num = ((degrees // 11.25) * 11.25 // 1) | int %}
          {%- set num  = 0 if num  == 360 else num %}
          {{ "{}{}{}".format(path,num,ext) }}

and

      wind_compass_abbreviation:
        friendly_name: Windrichting Afkorting
        value_template: >
          {% set degrees = states('sensor.winddirection')|float %}
          {% set abbr = ['N','NNNO','NNO','ONNO','NO','NONO','ONO','OONO',
                         'O','OOZO','OZO','ZOZO','ZO','OZZO','ZZO','ZZZO',
                         'Z','ZZZW','ZZW','ZZW','ZW','ZWZW','WZW','WWZW',
                         'W','WWNW','WNW','NWNW','NW','WNNW','NNW','NNNW' ] %}
          {%- set i = ((degrees / 11.25) | round(0)) | int %}
          {%- set i = 0 if i == 32 else i %}
          {{ abbr[i] }}
2 Likes

Awesome! It works really well!

Thanks

Thanks a lot .
I have a netatmo wheather station.
I made the following code

  - platform: template
    sensors:
      wind_angle:
        friendly_name: "Wind angle"
        unit_of_measurement: 'degrees'
        value_template: "{{ states('sensor.netatmo_netatmo_sceaux_anemometre_balcon_angle') | regex_findall_index('([0-9]+)',index=0,ignorecase=TRUE)  }}"
  - platform: template
    sensors:
        wind_compass:
#           friendly_name: Windrichting
#           icon_template: mdi:compass
           value_template: >
             {{ states('sensor.wind_angle') }}
           friendly_name_template: >
             {% set degrees = states('sensor.wind_angle')|float %}
             {% set abbr = ['N','NNNE','NNE','ENNE','NE','NENE','ENE','EENE','E','EESE','ESE','SESE','SE',
                     'ESSE','SSE','SSSE','S','SSSW','SSW','WSSW','SW','SWSW','WSW','WWSW','W','WWNW',
                     'WNW','NWNW','NW','WNNW','NNW','NNNW' ] %}
             {%- set i = ((degrees / 11.25) | round(0)) | int %}
             {%- set i = 0 if i == 32 else i %}
             {{ abbr[i] }}
           unit_of_measurement: '°'
           entity_picture_template: >
                {% set degrees = states('sensor.wind_angle')|float %}
                {% set path = '/local/WindCompass/' %}
                {% set ext = '.png' %}
                {{path-}}
                {%- if 354.38 <= degrees or degrees <= 5.62 -%} 0
                {%- else -%}
                {{ ( ((degrees/11.25)|round )*11.25 )| round}}
                {%- endif -%}
                {{-ext-}}


I 've used the above “png” files.
NB : the files have to be put at home_assistant/www/foobar path. It is seen as /local/foobar.

@jugla Maybe also add some attributes to your compass:

        entity_picture_template: >-
                {% set degrees = states('sensor.wind_angle')|float %}
                {% set path = '/local/WindCompass/' %}
                {% set ext = '.png' %}
                {{path-}}
                {%- if 354.38 <= degrees or degrees <= 5.62 -%} 0
                {%- else -%}
                {{ ( ((degrees/11.25)|round )*11.25 )| round}}
                {%- endif -%}
                {{-ext-}}
        attribute_templates:
          speed: "{{states('sensor.weather_wind_speed')}} {{state_attr('sensor.weather_wind_speed', 'unit_of_measurement')}}" 
          speed_txt: >-
           {% set speed = states('sensor.weather_wind_speed')|float %}
           {% if 0 <= speed <= 0.2 %} Stille
           {% elif speed <= 1.5 %} Flau vind
           {% elif speed <= 3.3 %} Svak vind
           {% elif speed <= 5.4 %} Lett bris
           {% elif speed <= 7.9 %} Laber bris
           {% elif speed <= 10.7 %} Frisk bris
           {% elif speed <= 13.8 %} Liten kuling
           {% elif speed <= 17.1 %} Stiv kuling
           {% elif speed <= 20.7 %} Sterk kuling
           {% elif speed <= 24.4 %} Liten storm
           {% elif speed <= 28.4 %} Full storm
           {% elif speed <= 32.6 %} Sterk storm
           {% elif speed > 32.7 %} Orkan
           {% endif %}

Thanks a lot, I will try.
Just a remark with the “round formula”

 ((degrees/11.25)|round )*11.25 )| round}

You must link(or copy) some xxx.png.
112 --> 113
123 --> 124
157 --> 158
168 --> 169
202 --> 203
213 --> 214
22 --> 23
247 --> 248
258 --> 259
292 --> 293
303 --> 304
337 --> 338
348 --> 349
33 --> 34
And to simplify the code, you can link 0 with 360.

1 Like

Just wanted to add that I made a little Python script that generates wind direction icons that also incorporate some indication of the wind speed in whatever style you want (feel free to make them fancier) and I made a relatively simple template as well:

My template is relatively simple and uses rounding like this:

sensor:
  - platform: template
    sensors:
      wind_compass:
          friendly_name: "Wind bearing"
          value_template: >
              {{ state_attr("weather.ksea_hourly", "wind_bearing") }}
          unit_of_measurement: "°"
          entity_picture_template: >
              {% set path = '/local/wind/' %}
              {% set ext = '.png' %}
              {{path-}}
              {{((state_attr("weather.ksea_hourly", "wind_bearing") * 16 / 360)|round(0) *360/16) | int-}}_
              {%- if state_attr("weather.ksea_hourly","wind_speed") <= 8 -%}L
              {%- elif state_attr("weather.ksea_hourly","wind_speed") <= 15 -%}M
              {%- else -%}H
              {%-endif-%}
              {{-ext-}}

Not too beautiful yet, but works!

badge

3 Likes

Hi, I created a Lovelace Card that accepts an entity and displays a css build compass. No images required! Might be of use to some of you.

2 Likes

Hi I have configured windcompass as per your advice and everything works fine but when the wind direction is O ° the image does not work correctly in the North direction

####################################################
#            WIND COMPASS                          #
####################################################
- platform: template
  sensors: 
    wind_compass_abbreviation:
#      icon_template: mdi:compass
      value_template: >-
        {% if 354.38 <= states('sensor.openweathermap_wind_bearing')|float <= 5.62 %}
           N
        {% elif 5.63 <= states('sensor.openweathermap_wind_bearing')|float <= 16.87 %}
           NbE
        {% elif 16.88 <= states('sensor.openweathermap_wind_bearing')|float <= 28.12 %}
           NNE
        {% elif 28.13 <= states('sensor.openweathermap_wind_bearing')|float <= 39.37 %}
           NEbN
        {% elif 39.38 <= states('sensor.openweathermap_wind_bearing')|float <= 50.62 %}
           NE
        {% elif 50.63 <= states('sensor.openweathermap_wind_bearing')|float <= 61.87 %}
           NEbE
        {% elif 61.88 <= states('sensor.openweathermap_wind_bearing')|float <= 73.12 %}
           ENE
        {% elif 73.13 <= states('sensor.openweathermap_wind_bearing')|float <= 84.37 %}
           EbN
        {% elif 84.38 <= states('sensor.openweathermap_wind_bearing')|float <= 95.62 %}
           E
        {% elif 95.63 <= states('sensor.openweathermap_wind_bearing')|float <= 106.87 %}
           EbS
        {% elif 106.88 <= states('sensor.openweathermap_wind_bearing')|float <= 118.12 %}
           ESE
        {% elif 118.13 <= states('sensor.openweathermap_wind_bearing')|float <= 129.37 %}
           SEbE
        {% elif 129.38 <= states('sensor.openweathermap_wind_bearing')|float <= 140.62 %}
           SE
        {% elif 140.63 <= states('sensor.openweathermap_wind_bearing')|float <= 151.87 %}
           SEbS
        {% elif 151.88 <= states('sensor.openweathermap_wind_bearing')|float <= 163.12 %}
           SSE
        {% elif 163.13 <= states('sensor.openweathermap_wind_bearing')|float <= 174.37 %}
           SbE
        {% elif 174.38 <= states('sensor.openweathermap_wind_bearing')|float <= 185.62 %}
           S
        {% elif 185.63 <= states('sensor.openweathermap_wind_bearing')|float <= 196.87 %}
           SbW
        {% elif 196.88 <= states('sensor.openweathermap_wind_bearing')|float <= 208.12 %}
           SSW
        {% elif 208.13 <= states('sensor.openweathermap_wind_bearing')|float <= 219.37 %}
           SWbS
        {% elif 219.38 <= states('sensor.openweathermap_wind_bearing')|float <= 230.62 %}
           SW
        {% elif 230.63 <= states('sensor.openweathermap_wind_bearing')|float <= 241.87 %}
           SWbW
        {% elif 241.88 <= states('sensor.openweathermap_wind_bearing')|float <= 253.12 %}
           WSW
        {% elif 253.13 <= states('sensor.openweathermap_wind_bearing')|float <= 264.37 %}
           WbS
        {% elif 264.38 <= states('sensor.openweathermap_wind_bearing')|float <= 275.62 %}
           W
        {% elif 275.63 <= states('sensor.openweathermap_wind_bearing')|float <= 286.87 %}
           WbN
        {% elif 286.88 <= states('sensor.openweathermap_wind_bearing')|float <= 298.12 %}
           WNW
        {% elif 298.13 <= states('sensor.openweathermap_wind_bearing')|float <= 309.37 %}
           NWbW
        {% elif 309.38 <= states('sensor.openweathermap_wind_bearing')|float <= 320.62 %}
           NW
        {% elif 320.63 <= states('sensor.openweathermap_wind_bearing')|float <= 331.87 %}
           NWbN
        {% elif 331.88 <= states('sensor.openweathermap_wind_bearing')|float <= 343.12 %}
           NNW
        {% elif 343.13 <= states('sensor.openweathermap_wind_bearing')|float <= 354.37 %}
           NbW
        {% endif %}   
 
#- platform: template
#  sensors: 
#    wind_compass_point:
#      value_template: >-
#        {% if 354.38 <= states('sensor.openweathermap_wind_bearing')|float <= 5.62 %}
#           North 
#        {% elif 5.63 <= states('sensor.openweathermap_wind_bearing')|float <= 16.87 %}
#           North by east 
#        {% elif 16.88 <= states('sensor.openweathermap_wind_bearing')|float <= 28.12 %}
#           North-northeast
#        {% elif 28.13 <= states('sensor.openweathermap_wind_bearing')|float <= 39.37 %}
#           Northeast by north
#        {% elif 39.38 <= states('sensor.openweathermap_wind_bearing')|float <= 50.62 %}
#           Northeast
#        {% elif 50.63 <= states('sensor.openweathermap_wind_bearing')|float <= 61.87 %}
#           Northeast by east 
#        {% elif 61.88 <= states('sensor.openweathermap_wind_bearing')|float <= 73.12 %}
#           East-northeast 
#        {% elif 73.13 <= states('sensor.openweathermap_wind_bearing')|float <= 84.37 %}
#           East by north 
#        {% elif 84.38 <= states('sensor.openweathermap_wind_bearing')|float <= 95.62 %}
#           East 
#        {% elif 95.63 <= states('sensor.openweathermap_wind_bearing')|float <= 106.87 %}
#           East by south
#        {% elif 106.88 <= states('sensor.openweathermap_wind_bearing')|float <= 118.12 %}
#           East-southeast 
#        {% elif 118.13 <= states('sensor.openweathermap_wind_bearing')|float <= 129.37 %}
#           Southeast by east
#        {% elif 129.38 <= states('sensor.openweathermap_wind_bearing')|float <= 140.62 %}
#           Southeast
#        {% elif 140.63 <= states('sensor.openweathermap_wind_bearing')|float <= 151.87 %}
#           Southeast by south
#        {% elif 151.88 <= states('sensor.openweathermap_wind_bearing')|float <= 163.12 %}
#           South-southeast 
#        {% elif 163.13 <= states('sensor.openweathermap_wind_bearing')|float <= 174.37 %}
#           South by east
#        {% elif 174.38 <= states('sensor.openweathermap_wind_bearing')|float <= 185.62 %}
#           South
#        {% elif 185.63 <= states('sensor.openweathermap_wind_bearing')|float <= 196.87 %}
#           South by west 
#        {% elif 196.88 <= states('sensor.openweathermap_wind_bearing')|float <= 208.12 %}
#           South-southwest
#        {% elif 208.13 <= states('sensor.openweathermap_wind_bearing')|float <= 219.37 %}
#           Southwest by south
#        {% elif 219.38 <= states('sensor.openweathermap_wind_bearing')|float <= 230.62 %}
#           Southwest
#        {% elif 230.63 <= states('sensor.openweathermap_wind_bearing')|float <= 241.87 %}
#           Southwest by west
#        {% elif 241.88 <= states('sensor.openweathermap_wind_bearing')|float <= 253.12 %}
#           West-southwest 
#        {% elif 253.13 <= states('sensor.openweathermap_wind_bearing')|float <= 264.37 %}
#           West by south 
#        {% elif 264.38 <= states('sensor.openweathermap_wind_bearing')|float <= 275.62 %}
#           West
#        {% elif 275.63 <= states('sensor.openweathermap_wind_bearing')|float <= 286.87 %}
#           West by north
#        {% elif 286.88 <= states('sensor.openweathermap_wind_bearing')|float <= 298.12 %}
#           West-northwest
#        {% elif 298.13 <= states('sensor.openweathermap_wind_bearing')|float <= 309.37 %}
#           Northwest by west
#        {% elif 309.38 <= states('sensor.openweathermap_wind_bearing')|float <= 320.62 %}
#           Northwest 
#        {% elif 320.63 <= states('sensor.openweathermap_wind_bearing')|float <= 331.87 %}
#           Northwest by north
#        {% elif 331.88 <= states('sensor.openweathermap_wind_bearing')|float <= 343.12 %}
#           North-northwest
#        {% elif 343.13 <= states('sensor.openweathermap_wind_bearing')|float <= 354.37 %}
#           North by west
#        {% endif %}
        
    # direzione in gradi con icona bussola 
    wind_compass: 
      friendly_name: "Wind direction"
      value_template: '{{ states.sensor.openweathermap_wind_bearing.state }}'
      friendly_name_template: "Wind direction - {{ states.sensor.wind_compass_point.state }}"
      unit_of_measurement: '°'
      entity_picture_template: >-
        {% if 354.38 <= states('sensor.openweathermap_wind_bearing')|float <= 5.62 %}
            /local/weather/windcompass/N.png
        {% elif 5.63 <= states('sensor.openweathermap_wind_bearing')|float <= 16.87 %}
            /local/weather/windcompass/NbE.png
        {% elif 16.88 <= states('sensor.openweathermap_wind_bearing')|float <= 28.12 %}
            /local/weather/windcompass/NNE.png
        {% elif 28.13 <= states('sensor.openweathermap_wind_bearing')|float <= 39.37 %}
            /local/weather/windcompass/NEbE.png
        {% elif 39.38 <= states('sensor.openweathermap_wind_bearing')|float <= 50.62 %}
            /local/weather/windcompass/NE.png
        {% elif 50.63 <= states('sensor.openweathermap_wind_bearing')|float <= 61.87 %}
            /local/weather/windcompass/NEbE.png
        {% elif 61.88 <= states('sensor.openweathermap_wind_bearing')|float <= 73.12 %}
            /local/weather/windcompass/ENE.png
        {% elif 73.13 <= states('sensor.openweathermap_wind_bearing')|float <= 84.37 %}
            /local/weather/windcompass/EbN.png
        {% elif 84.38 <= states('sensor.openweathermap_wind_bearing')|float <= 95.62 %}
            /local/weather/windcompass/E.png
        {% elif 95.63 <= states('sensor.openweathermap_wind_bearing')|float <= 106.87 %}
            /local/weather/windcompass/EbS.png
        {% elif 106.88 <= states('sensor.openweathermap_wind_bearing')|float <= 118.12 %}
            /local/weather/windcompass/ESE.png
        {% elif 118.13 <= states('sensor.openweathermap_wind_bearing')|float <= 129.37 %}
            /local/weather/windcompass/SEbE.png
        {% elif 129.38 <= states('sensor.openweathermap_wind_bearing')|float <= 140.62 %}
            /local/weather/windcompass/SE.png
        {% elif 140.63 <= states('sensor.openweathermap_wind_bearing')|float <= 151.87 %}
            /local/weather/windcompass/SEbS.png
        {% elif 151.88 <= states('sensor.openweathermap_wind_bearing')|float <= 163.12 %}
            /local/weather/windcompass/SSE.png
        {% elif 163.13 <= states('sensor.openweathermap_wind_bearing')|float <= 174.37 %}
            /local/weather/windcompass/SbE.png
        {% elif 174.38 <= states('sensor.openweathermap_wind_bearing')|float <= 185.62 %}
            /local/weather/windcompass/S.png
        {% elif 185.63 <= states('sensor.openweathermap_wind_bearing')|float <= 196.87 %}
            /local/weather/windcompass/SbW.png
        {% elif 196.88 <= states('sensor.openweathermap_wind_bearing')|float <= 208.12 %}
            /local/weather/windcompass/SSW.png
        {% elif 208.13 <= states('sensor.openweathermap_wind_bearing')|float <= 219.37 %}
            /local/weather/windcompass/SWbS.png
        {% elif 219.38 <= states('sensor.openweathermap_wind_bearing')|float <= 230.62 %}
            /local/weather/windcompass/SW.png
        {% elif 230.63 <= states('sensor.openweathermap_wind_bearing')|float <= 241.87 %}
            /local/weather/windcompass/SWbW.png
        {% elif 241.88 <= states('sensor.openweathermap_wind_bearing')|float <= 253.12 %}
            /local/weather/windcompass/WSW.png
        {% elif 253.13 <= states('sensor.openweathermap_wind_bearing')|float <= 264.37 %}
            /local/weather/windcompass/WbS.png
        {% elif 264.38 <= states('sensor.openweathermap_wind_bearing')|float <= 275.62 %}
            /local/weather/windcompass/W.png
        {% elif 275.63 <= states('sensor.openweathermap_wind_bearing')|float <= 286.87 %}
            /local/weather/windcompass/WbN.png
        {% elif 286.88 <= states('sensor.openweathermap_wind_bearing')|float <= 298.12 %}
            /local/weather/windcompass/WNW.png
        {% elif 298.13 <= states('sensor.openweathermap_wind_bearing')|float <= 309.37 %}
            /local/weather/windcompass/NWbW.png
        {% elif 309.38 <= states('sensor.openweathermap_wind_bearing')|float <= 320.62 %}
            /local/weather/windcompass/NW.png
        {% elif 320.63 <= states('sensor.openweathermap_wind_bearing')|float <= 331.87 %}
            /local/weather/windcompass/NWbN.png
        {% elif 331.88 <= states('sensor.openweathermap_wind_bearing')|float <= 343.12 %}
            /local/weather/windcompass/NNW.png
        {% elif 343.13 <= states('sensor.openweathermap_wind_bearing')|float <= 354.37 %}
            /local/weather/windcompass/NbW.png
        {% endif %}

small problem

You are right. Something has changes so this does not work anymore.
This should work:

         {% set degrees = states('sensor.wind_compass')|float %}
         {% if  degrees <= 5.62   %} /local/WindCompass/0.png
         {% elif degrees <= 16.87 %} /local/WindCompass/11.png
         {% elif degrees <= 28.12 %} /local/WindCompass/22.png
         {% elif degrees <= 39.37 %} /local/WindCompass/33.png
         {% elif degrees <= 50.62 %} /local/WindCompass/45.png
         {% elif degrees <= 61.87 %} /local/WindCompass/56.png
         {% elif degrees <= 73.12 %} /local/WindCompass/67.png
         {% elif degrees <= 84.37 %} /local/WindCompass/78.png
         {% elif degrees <= 95.62 %} /local/WindCompass/90.png
         {% elif degrees <= 106.87 %} /local/WindCompass/101.png
         {% elif degrees <= 118.12 %} /local/WindCompass/112.png
         {% elif degrees <= 129.37 %} /local/WindCompass/123.png
         {% elif degrees <= 140.62 %} /local/WindCompass/135.png
         {% elif degrees <= 151.87 %} /local/WindCompass/146.png
         {% elif degrees <= 163.12 %} /local/WindCompass/157.png
         {% elif degrees <= 174.37 %} /local/WindCompass/168.png
         {% elif degrees <= 185.62 %} /local/WindCompass/180.png
         {% elif degrees <= 196.87 %} /local/WindCompass/191.png
         {% elif degrees <= 208.12 %} /local/WindCompass/202.png
         {% elif degrees <= 219.37 %} /local/WindCompass/213.png
         {% elif degrees <= 230.62 %} /local/WindCompass/225.png
         {% elif degrees <= 241.87 %} /local/WindCompass/236.png
         {% elif degrees <= 253.12 %} /local/WindCompass/247.png
         {% elif degrees <= 264.37 %} /local/WindCompass/258.png
         {% elif degrees <= 275.62 %} /local/WindCompass/270.png
         {% elif degrees <= 286.87 %} /local/WindCompass/281.png
         {% elif degrees <= 298.12 %} /local/WindCompass/292.png
         {% elif degrees <= 309.37 %} /local/WindCompass/303.png
         {% elif degrees <= 320.62 %} /local/WindCompass/315.png
         {% elif degrees <= 331.87 %} /local/WindCompass/326.png
         {% elif degrees <= 343.12 %} /local/WindCompass/337.png
         {% elif degrees <= 354.37 %} /local/WindCompass/348.png
         {% else  %} /local/WindCompass/0.png
         {% endif %}

it works! @Tomahawk Thank you very much