sensor: - platform: template sensors: weewx_wind_bearing_template: value_template: > {% set direction = ['N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW','N'] %} {% set degree = states('sensor.weewx_wind_direction')|float %} {{ direction[((degree+11.25)/22.5)|int] }}