Advertisement
JLindvig

Wind-Direction

Jan 8th, 2021
1,323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.46 KB | None | 0 0
  1. # _       ___           __      ____  _                __  _          
  2. #| |     / (_)___  ____/ /     / __ \(_)_______  _____/ /_(_)___  ____
  3. #| | /| / / / __ \/ __  /_____/ / / / / ___/ _ \/ ___/ __/ / __ \/ __ \
  4. #| |/ |/ / / / / / /_/ /_____/ /_/ / / /  /  __/ /__/ /_/ / /_/ / / / /
  5. #__/|__/_/_/ /_/\__,_/     /_____/_/_/   \___/\___/\__/_/\____/_/ /_/
  6. #                                                  by Jason Robert Hill                                          
  7.  
  8. wind_direction:
  9. #Requirements: None
  10.  
  11.   sensor:
  12.     - platform: template
  13.       sensors:
  14.        #takes wind bearing attribute from weather.hjem and makes it to a sensor      
  15.         wind_bearing_degrees:
  16.           friendly_name: "Vind Bearing"
  17.           unit_of_measurement: 'degrees'
  18.           icon_template: mdi:weather-windy
  19.           value_template: "{{ state_attr('weather.hjem', 'wind_bearing') }}"  
  20.  
  21.         #takes wind speed attribute from weather.hjem and makes it to a sensor      
  22.         wind_speed:
  23.           friendly_name: "Vind hastighed"
  24.           unit_of_measurement: m/s
  25.           value_template: "{{ ((state_attr('weather.hjem', 'wind_speed') |float ) * 0.2778) | round(1) }}"
  26.  
  27.         #Converts sensor.wind_bearing from degrees to compass orientation.      
  28.         wind_bearing_compass_direction:
  29.           friendly_name: "Vindretning"
  30.           icon_template: mdi:weather-windy
  31.           value_template: >-
  32.             {% set direction = ['NORD ↑','Nord-Nordøst ↗','Nordøst ↗','Øst-Nordøst ↗','Øst →','Øst-Sydøst ↘','Sødøst ↘','Syd-Sydøst ↘','Syd ↓','Syd-Sydvest ↙','Sydvest ↙','vest-Sydvest ↙','Vest ←','Vest-Nordvest ↖','Nordvest ↖','Nord-Nordvest ↖','Nord ↑'] %}
  33.             {{ direction[(((state_attr('weather.hjem', 'wind_bearing')|float)+11.25)/22.5)|int] }}
  34.  
  35.  
  36. # Cardinal Direction    Degree Direction
  37. #       N               348.75 - 11.25
  38. #       NNE             11.25 - 33.75
  39. #       NE              33.75 - 56.25
  40. #       ENE             56.25 - 78.75
  41. #       E               78.75 - 101.25
  42. #       ESE             101.25 - 123.75
  43. #       SE              123.75 - 146.25
  44. #       SSE             146.25 - 168.75
  45. #       S               168.75 - 191.25
  46. #       SSW             191.25 - 213.75
  47. #       SW              213.75 - 236.25
  48. #       WSW             236.25 - 258.75
  49. #        W              258.75 - 281.25
  50. #       WNW             281.25 - 303.75
  51. #       NW              303.75 - 326.25
  52. #       NNW             326.25 - 348.75
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement