template:
  - sensor:
      - name: "Weewx Wind Bearing"
        unique_id: weewx_wind_bearing_template
        state: >
          {% 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(none) %}
          {% if degree is not none %}
            {% set d = (degree % 360) %}
            {{ direction[((d + 11.25) / 22.5) | int] }}
          {% else %}
            unknown
          {% endif %}
