Advertisement
boelle11

Untitled

Jan 27th, 2022
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. sensor:
  2. - platform: template
  3. sensors:
  4. weather_wind_dir:
  5. friendly_name: Vind Retning
  6. value_template: >
  7. {% set dir = states('sensor.openweathermap_harboore_wind_bearing')|float %}
  8. {% if 11.25 < dir <= 33.75 %} NNOE
  9. {% elif 33.75 < dir <= 56.25 %} NOE
  10. {% elif 56.25 < dir <= 78.75 %} OENOE
  11. {% elif 78.75 < dir <= 101.25 %} OE
  12. {% elif 101.25 < dir <= 123.75 %} OESOE
  13. {% elif 123.75 < dir <= 146.25 %} SOE
  14. {% elif 146.25 < dir <= 168.75 %} SSOE
  15. {% elif 168.75 < dir <= 191.25 %} S
  16. {% elif 191.25 < dir <= 213.75 %} SSV
  17. {% elif 213.75 < dir <= 236.25 %} SV
  18. {% elif 236.25 < dir <= 258.75 %} VSV
  19. {% elif 258.75 < dir <= 281.25 %} V
  20. {% elif 281.25 < dir <= 303.75 %} VNV
  21. {% elif 303.75 < dir <= 326.25 %} NV
  22. {% elif 326.25 < dir <= 348.75 %} NNV
  23. {% else %} N
  24. {% endif %}
  25.  
  26.  
  27. # and this one adds dynamic icons to states
  28. weather_wind_dir_gui:
  29. entity_id: sensor.weather_wind_dir
  30. friendly_name_template: "{{ state_attr('sensor.weather_wind_dir', 'friendly_name') }}"
  31. value_template: "{{ states('sensor.weather_wind_dir') }}"
  32. icon_template: >
  33. {% set state = states('sensor.weather_wind_dir') %}
  34. {% if 11.25 < state <= 33.75 %}
  35. mdi:weather-windy
  36. {% else %}
  37. mdi:weather-windy
  38. {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement