DIY Zigbee weather station

I have the same issue here, after updating HA and Zigbee2mqtt, the humidity, temperature and pressure readings became unavailable.
I see the values are updated in Zigbee2mqtt, but not shown in the dashboard.
Anyone has the same issue and found a solution?

It still doesn’t work for me. I had the device on all the time (3 weeks) and there was no problem with it. The problem is with the HA software part or z2mqtt. I gave up for a while because I’m on a business trip. It would be a pity to abandon this topic, because I already have all the sensors for it.

Same here, temp, pressure and humidity gone…

Hi, I don’t know anything about electronics. My actions consist of reproducing the work of others. What does “~R” mean in your diagram?
image

“~R” is the variable resistance of the vane.

After some research, if I remove the following lines associated to the availability then I am able to see again the Tem, Humidity and Pressure:
availability_topic:…
payload_available:…
payload_not_available:…

1 Like

Shout out to Mike, Thank you!

I managed to assemble a weather station, but not all entities work or work incorrectly. First of all, the pressure is incorrectly indicated. Secondly, the following entities do not work: wind direction, wind force (both) and wind speed. I am surprised that wind force (both) and wind speed do not work because they are probably calculated from the wind pulse and this entity works. Can the wind direction failure be caused by incorrect connection of the wires? In the wind direction indicator, I only connected 2 of the 4 wires. Additionally, when I manually switch Daily rain clicks, 0 is still displayed, so Rainfall today also indicates 0. Can you advise what to do?

did you comment out (#) on all the MQTT sensors?

#availability_topic: "zigbee2mqtt/bridge/state"
#payload_available: "online"
#payload_not_available: "offline"

Yes I removed it. It had no effect.
For pressure I modified the code as follows
value_template: “{{ ((value_json.pressure_l1| float ) | round (0))/100 }}”

As I wrote earlier - I am surprised that entities that are calculated and not data received from sensors are not available.

For wind direction. Regardless of how I change the position of the wind flag, the voltage it is still the same. Is it a matter of bad connection?

In general, I slightly mydified the codes using Gemini AI.

This is how it looks now.

This is how the codes look

/homeassistant/mqtt_sensors/weatherstation.yaml

#########################################################
#                                                       #
#      BME280 DATA                                      #
#                                                       #
######################################################### 

- state_topic: "zigbee2mqtt/0x00124b00025e47c3"
  unit_of_measurement: "%"
  value_template: "{{ value_json.humidity_l1| round(0) }}"
  json_attributes_topic: "zigbee2mqtt/0x00124b00025e47c3/attributes" 
  icon: mdi:water-percent 
  name: "Humidity shed"
  unique_id: humshed
    
- state_topic: "zigbee2mqtt/0x00124b00025e47c3"
  unit_of_measurement: "hpa"
  value_template: "{{ ((value_json.pressure_l1| float ) | round (0))/100 }}"
  json_attributes_topic: "zigbee2mqtt/0x00124b00025e47c3/attributes" 
  icon: mdi:weight  
  name: "Pressure shed"
  unique_id: preshed
    
- state_topic: "zigbee2mqtt/0x00124b00025e47c3"
  unit_of_measurement: "°C"
  value_template: "{{ value_json.temperature_l1| round(1) }}"
  json_attributes_topic: "zigbee2mqtt/0x00124b00025e47c3/attributes" 
  icon: mdi:thermometer-lines  
  name: "Temperature shed"
  unique_id: tempshed
#########################################################
#                                                       #
#      WIND                                             #
#                                                       #
#########################################################

- state_topic: "zigbee2mqtt/0x00124b00025e47c3"
  unit_of_measurement: "v"
  value_template: "{{ value_json.l8| round(2) }}"
  json_attributes_topic: "zigbee2mqtt/0x00124b00025e47c3/attributes" 
  icon: mdi:call-made
  name: "Wind voltage"
  unique_id: windvoltage

- state_topic: "zigbee2mqtt/0x00124b00025e47c3"
  unit_of_measurement: "rpm"
  value_template: "{{ value_json.l6 }}"
  json_attributes_topic: "zigbee2mqtt/0x00124b00025e47c3/attributes" 
  icon: mdi:call-made
  name: "Windpulse"
  unique_id: windpulse
   

#########################################################
#                                                       #
#            END OF CONFIGURATION FILE                  # 
#                                                       # 
#########################################################

/homeassistant/sensors/sensors.yaml

#########################################################
#                                                       #
#      BME280 DATA                                      #
#                                                       #
######################################################### 

- platform: template
  sensors:
      humidity_abs_shed:
        value_template: >-
          {% set h, t = states('sensor.humidity_shed') | float, states('sensor.temperature_shed') %}
          {% if not h or t == 'unknown' -%}
            'unknown'
          {%- else %}
            {% set t = t | float %}
            {{ (h*6.112*2.1674*e**((t*17.67)/(t+243.5))/(t+273.15))|round(1) }}
          {% endif %}
        unit_of_measurement: g/m³
        friendly_name: Absolute Humidity shed

- platform: template
  sensors:
      dewpoint_shed:
        friendly_name: "Dewpoint shed"
        value_template: >-
          {{ (log( states('sensor.humidity_shed')|int / 100 ) + 18.678 * states('sensor.temperature_shed')|float / (257.14 + states('sensor.temperature_shed')|float ) )| round (1) }}  
        unit_of_measurement: °C
        
#########################################################
#                                                       #
#      RAIN METER                                       #
#                                                       #
#########################################################  

- platform: history_stats
  name: Daily rain clicks
  entity_id: switch.0x00124b00025e47c3_l5
  state: 'off'
  type: count
  start: '{{ now().replace(hour=0, minute=0, second=0) }}'
  end: '{{ now() }}'

- platform: template
  sensors:
    rainfall_today:
      friendly_name: Rainfall today
      unit_of_measurement: mm
      value_template: >-
        {% set count = states('sensor.daily_rain_clicks') | int(0) %}
        {% set mm_per_pulse = 0.30303 %}
        {% set mm = count * mm_per_pulse %}
        {{ mm | round(1, 'floor') }}    
          
#########################################################
#                                                       #
#      ANEMOMETER                                       #
#                                                       #
#########################################################

- platform: template
  sensors:
    windspeed:
      friendly_name: Wind speed
      unit_of_measurement: m/s
      # m_per_pulse = (r * 2 * Pi)/2 = (0.09 * 2 * 3.14)/2 = 0.2826 m
      value_template: >-
        {% set count = states('sensor.wind_pulse') | int %}
        {% set m_per_pulse = 0.2826 %}
        {% set mps = count * m_per_pulse %}
        {{ mps | round(0) }}

- platform: template
  sensors:
    windkmh:
      friendly_name: Wind speed kmh
      unit_of_measurement: km/h
      value_template: >-
        {% set mps = states('sensor.windspeed') | float %}
        {{ (mps * 3.6) | round(1) }}

- platform: template
  sensors:
    windforce:
      friendly_name: Wind force
      icon_template: "mdi:weather-windy"
      value_template: >-
        {% set wind = states('sensor.windspeed') | float %}
        {% set wind_round = wind | round(1) %}
        {% if wind <= 0.2 %}Bft: 0, Wind stil, {{ wind_round }} m/s
        {% elif wind <= 1.5 %}Bft: 1, Zwak: flauwe wind, {{ wind_round }} m/s
        {% elif wind <= 3.3 %}Bft: 2, Zwak, {{ wind_round }} m/s
        {% elif wind <= 5.4 %}Bft: 3, Matig: lichte bries, {{ wind_round }} m/s
        {% elif wind <= 7.9 %}Bft: 4, Matig: flauwe bries, {{ wind_round }} m/s
        {% elif wind <= 10.7 %}Bft: 5, Vrij krachtig, {{ wind_round }} m/s
        {% elif wind <= 13.8 %}Bft: 6, Krachtig, {{ wind_round }} m/s
        {% elif wind <= 17.1 %}Bft: 7, Hard, {{ wind_round }} m/s
        {% elif wind <= 20.7 %}Bft: 8, Stormachting, {{ wind_round }} m/s
        {% elif wind <= 24.4 %}Bft: 9, Storm, {{ wind_round }} m/s
        {% elif wind <= 28.4 %}Bft: 10, Zware storm, {{ wind_round }} m/s
        {% elif wind <= 32.6 %}Bft: 11, Zeer zware storm, {{ wind_round }} m/s
        {% else %}Bft: 12, Orkaan, {{ wind_round }} m/s
        {%- endif %}

- platform: template
  sensors:
    beaufort:
      friendly_name: Wind force (Bft)
      icon_template: "mdi:weather-windy"
      unit_of_measurement: Bft
      value_template: >-
        {% set wind = states('sensor.windspeed') | float %}
        {% if wind <= 0.2 %}0
        {% elif wind <= 1.5 %}1
        {% elif wind <= 3.3 %}2
        {% elif wind <= 5.4 %}3
        {% elif wind <= 7.9 %}4
        {% elif wind <= 10.7 %}5
        {% elif wind <= 13.8 %}6
        {% elif wind <= 17.1 %}7
        {% elif wind <= 20.7 %}8
        {% elif wind <= 24.4 %}9
        {% elif wind <= 28.4 %}10
        {% elif wind <= 32.6 %}11
        {% else %}12
        {%- endif %}
             
#########################################################
#                                                       #
#      WIND DIRECTION                                   #
#                                                       #
#########################################################

- platform: template
  sensors:
    wind_azimuth:
      friendly_name: Wind azimuth
      unit_of_measurement: '°'
      value_template: >-
        {% set wind = states('sensor.wind_voltage') | float %}
        {% if wind <= 0.21 %}112.5
        {% elif wind <= 0.27 %}67.5
        {% elif wind <= 0.30 %}90.0
        {% elif wind <= 0.41 %}157.5
        {% elif wind <= 0.60 %}135.0
        {% elif wind <= 0.79 %}202.5
        {% elif wind <= 0.93 %}180.0
        {% elif wind <= 1.31 %}22.5
        {% elif wind <= 1.49 %}45.0
        {% elif wind <= 1.93 %}247.5
        {% elif wind <= 2.03 %}225.0
        {% elif wind <= 2.26 %}337.5
        {% elif wind <= 2.53 %}0.0
        {% elif wind <= 2.67 %}292.5
        {% elif wind <= 2.86 %}315.0
        {% elif wind <= 3.05 %}270.0
        {% else %}295.5
        {%- endif %}

- platform: template
  sensors:
    wind_direction:
      friendly_name: Wind direction
      icon_template: "mdi:compass-outline"
      value_template: >
        {% set degrees = states('sensor.wind_azimuth') | float %}
        {% set abbr = ['N','NNE','NE','ENE','E','ESE','SE',
        'SSE','S','SSW','SW','WSW','W','WNW','NW','NNW' ] %}
        {%- set i = ((degrees / 22.5) | round(0)) | int %}
        {%- set i = 0 if i == 16 else i %}
        {{ abbr[i] }}

#########################################################
#                                                       #
#            END OF CONFIGURATION FILE                  # 
#                                                       # 
#########################################################

/homeassistant/configuration.yaml

mqtt: 
  sensor: !include_dir_merge_list mqtt_sensors 
  switch: !include_dir_merge_list mqtt_switches
  
sensor: !include_dir_merge_list sensors

Hi,
I have the code for the sensors set up like this and it works for me
/homeassistant/sensors.yaml

More information about my entire project here.


#########################################################
#                                                       #
#      BME280 DATA                                      #
#                                                       #
######################################################### 

  - platform: template
    sensors:
      humidity_abs_shed:
        value_template: >-
          {% set h, t = states('sensor.humidity_shed') | float, states('sensor.temperature_shed') %}
          {% if not h or t == 'unknown' -%}
            'unknown'
          {%- else %}
            {% set t = t | float %}
            {{ (h*6.112*2.1674*e**((t*17.67)/(t+243.5))/(t+273.15))|round(1) }}
          {% endif %}
        unit_of_measurement: g/m³
        friendly_name: Absolute Humidity shed

  - platform: template
    sensors:
      dewpoint_shed:
        friendly_name: "Dewpoint shed"
        value_template: >-
          {{ (log( states('sensor.humidity_shed')|int / 100 ) + 18.678 * states('sensor.temperature_shed')|float / (257.14 + states('sensor.temperature_shed')|float ) )| round (1) }}  
        unit_of_measurement: °C

#########################################################
#                                                       #
#      RAIN METER                                       #
#                                                       #
#########################################################  

  - platform: history_stats
    name: Daily rain clicks
    entity_id: switch.0x00124b000633d676_l5
    state: 'off'
    type: count
    start: '{{ now().replace(hour=0, minute=0, second=0) }}'
    end: '{{ now() }}'
    
  - platform: template
    sensors:
      rainfall_today:
        friendly_name: Rainfall today
        unit_of_measurement: mm
        value_template: >-
          {% set count = states('sensor.daily_rain_clicks') | int(0)  %}
          {% set mm_per_pulse = 0.30303 %}
          {% set mm = count * mm_per_pulse %}
          {{ mm|round(1, 'floor') }}    
          
#########################################################
#                                                       #
#      ANEMOMETER                                       #
#                                                       #
#########################################################

  - platform: template
    sensors:
      windspeed:
        friendly_name: Wind speed
        unit_of_measurement: m/s
        # m_per_pulse = (r * 2 * Pi)/2 = (0.09 * 2 * 3.14)/2 = 0.2862 m
        value_template: >-
          {% set count = states('sensor.wind_pulse') | int %}
          {% set m_per_pulse = 0.2826 %} 
          {% set mps = count * m_per_pulse %}
          {{ mps|round(0) }}    
          
  - platform: template
    sensors:
      windkmh:
        friendly_name: Wind speed
        unit_of_measurement: km/h
        value_template: >-
          {% set count = states('sensor.windspeed') | int %}
          {% set conversion =  0.2777778 %} 
          {% set mps = count * conversion %}
          {{ mps|round(0) }}      

  - platform: template
    sensors:
      windforce:
        friendly_name: Wind force
        icon_template: "mdi:weather-windy"
        value_template: "{% set wind = states('sensor.windspeed')|float %}
        {% set wind_round = wind|round(1) %}
        {% if wind <= 0.2 %}Bft: 0, Wind stil, {{wind_round}} m/s
        {% elif wind <= 1.5 %}Bft: 1, Zwak: flauwe wind, {{wind_round}} m/s
        {% elif wind <= 3.3 %}Bft: 2, Zwak, {{wind_round}} m/s
        {% elif wind <= 5.4 %}Bft: 3, Matig: lichte bries, {{wind_round}} m/s
        {% elif wind <= 7.9 %}Bft: 4, Matig: flauwe bries, {{wind_round}} m/s
        {% elif wind <= 10.7 %}Bft: 5, Vrij krachtig, {{wind_round}} m/s
        {% elif wind <= 13.8 %}Bft: 6, Krachtig, {{wind_round}} m/s
        {% elif wind <= 17.1 %}Bft: 7, Hard, {{wind_round}} m/s
        {% elif wind <= 20.7 %}Bft: 8, Stormachting, {{wind_round}} m/s
        {% elif wind <= 24.4 %}Bft: 9, Storm, {{wind_round}} m/s
        {% elif wind <= 28.4 %}Bft: 10, Zware storm, {{wind_round}} m/s
        {% elif wind <= 32.6 %}Bft: 11, Zeer zware storm, {{wind_round}} m/s
        {% else %}Bft: 12, Orkaan, {{wind_round}} m/s
        {%- endif %}"


  - platform: template
    sensors:
      beaufort: 
        friendly_name: Wind force
        icon_template: " mdi:weather-windy" 
        unit_of_measurement: Bft
        value_template: "{% set wind = states('sensor.windspeed')|float %} 
        {% if wind <= 0.2 %}0
        {% elif wind <= 1.5 %}1
        {% elif wind <= 3.3 %}2
        {% elif wind <= 5.4 %}3
        {% elif wind <= 7.9 %}4
        {% elif wind <= 10.7 %}5
        {% elif wind <= 13.8 %}6
        {% elif wind <= 17.1 %}7
        {% elif wind <= 20.7 %}8
        {% elif wind <= 24.4 %}9
        {% elif wind <= 28.4 %}10
        {% elif wind <= 32.6 %}11
        {% else %} > 32.6 %}12
        {%- endif %}"
             
#########################################################
#                                                       #
#      WIND DIRECTION                                   #
#                                                       #
#########################################################

  - platform: template
    sensors:
      wind_azimuth: 
        friendly_name: Wind azimuth
        unit_of_measurement: '°'
        value_template: "{% set wind = states('sensor.wind_voltage')|float %}
        {% if wind <= 0.21 %}112.5
        {% elif wind <= 0.27 %}67.5
        {% elif wind <= 0.30 %}90.0
        {% elif wind <= 0.41 %}157.5
        {% elif wind <= 0.60 %}135.0
        {% elif wind <= 0.79 %}202.5
        {% elif wind <= 0.93 %}180.0
        {% elif wind <= 1.31 %}22.5
        {% elif wind <= 1.49 %}45.0
        {% elif wind <= 1.93 %}247.5
        {% elif wind <= 2.03 %}225.0
        {% elif wind <= 2.26 %}337.5
        {% elif wind <= 2.53 %}0.0
        {% elif wind <= 2.67 %}292.5
        {% elif wind <= 2.86 %}315.0
        {% elif wind <= 3.05 %}270
        {% else %} > 3.05 %}295.5
        {%- endif %}"

  - platform: template
    sensors:
      wind_direction:
        friendly_name: Wind direction
        icon_template: "mdi:compass-outline"
        value_template: >
          {% set degrees = states('sensor.wind_azimuth')|float %}
          {% set abbr = ['N','NNE','NE','ENE','E','ESE','SE',
          'SSE','S','SSW','SW','WSW','W','WNW','NW','NNW' ] %}
          {%- set i = ((degrees / 22.25) | round(0)) | int %}
          {%- set i = 0 if i == 16 else i %}
          {{ abbr[i] }}

#########################################################
#                                                       #
#            END OF CONFIGURATION FILE                  # 
#                                                       # 
#########################################################

Nice project @bearstorm , a reference to the original from @Doublet is appreciated and polite.

Id like to make my own weather station using same rain gauge, wind speed and direction meter, but i dont have any zigbee devices and would like to use bt or wifi instead, any recomendations to use instead of CC2530?

By switching the zigbee coordinator for something on WiFi, this whole setup becomes something else.

That part i understand, but i’m not familiar to these boards/devices, i dont know what to look for, or where to look from

In the first post of this thread I have put a link to an esp home solution :nerd_face:

Now i see, missed that one first.
Something like this should be enought https://www.waveshare.com/wiki/ESP32-S3-Zero

I have updated the PTVO firmware (firmware this caused some disturbances, took this opportunity to update all the files:

#########################################################
#                                                       #
#      MQTT SENSORS - ZIGBEE WEATHER STATION           #
#      Device: 0x00124b000633d676                      #
#                                                       #
#########################################################

mqtt:
  sensor:

    #----------------------------------------------------
    # BME280 - Temperature / Humidity / Pressure
    #----------------------------------------------------

    - state_topic: "zigbee2mqtt/0x00124b000633d676"
      name: "Temperature shed"
      unique_id: tempshed
      unit_of_measurement: "°C"
      device_class: temperature
      state_class: measurement
      value_template: "{{ value_json.temperature_l1 | round(1) }}"
      json_attributes_topic: "zigbee2mqtt/0x00124b000633d676/attributes"
      icon: mdi:thermometer-lines

    - state_topic: "zigbee2mqtt/0x00124b000633d676"
      name: "Humidity shed"
      unique_id: humshed
      unit_of_measurement: "%"
      device_class: humidity
      state_class: measurement
      value_template: "{{ value_json.humidity_l1 | round(0) }}"
      json_attributes_topic: "zigbee2mqtt/0x00124b000633d676/attributes"
      icon: mdi:water-percent

    - state_topic: "zigbee2mqtt/0x00124b000633d676"
      name: "Pressure shed"
      unique_id: preshed
      unit_of_measurement: "hPa"          # FIX: was "hpa" (wrong capitalisation)
      device_class: pressure
      state_class: measurement
      value_template: "{{ value_json.pressure_l1 | float | round(0) }}"
      json_attributes_topic: "zigbee2mqtt/0x00124b000633d676/attributes"
      icon: mdi:weight

    #----------------------------------------------------
    # Wind sensors
    #----------------------------------------------------

    - state_topic: "zigbee2mqtt/0x00124b000633d676"
      name: "Wind voltage"
      unique_id: windvoltage
      unit_of_measurement: "V"            # FIX: was "v" (wrong capitalisation)
      state_class: measurement
      value_template: "{{ value_json.voltage_l8 | round(2) }}"
      json_attributes_topic: "zigbee2mqtt/0x00124b000633d676/attributes"
      icon: mdi:call-made

    # NO MQTT sensor for l6 — PTVO firmware registers it via MQTT discovery
    # as number.0x00124b000633d676_l6 (per-minute counter, reset every 60s).
    # A clean template sensor below mirrors it as sensor.wind_pulse.

    # NO MQTT sensor for l7 (rain reed) — payload value is "ON"/"OFF" string, not numeric.
    # Z2M auto-creates binary_sensor.0x00124b000633d676_l7.
    # Rain is counted by history_stats in the sensor: section below.


#########################################################
#                                                       #
#      SENSOR PLATFORM SENSORS                         #
#                                                       #
#      history_stats: counts rain reed tips per day    #
#      statistics: 2-min sliding window for wind       #
#                                                       #
#      HOW RAIN COUNTING WORKS:                        #
#      l7 is a binary reed switch (ON/OFF). Z2M        #
#      creates binary_sensor.0x00124b000633d676_l7.    #
#      history_stats counts tips (ON state) today.     #
#                                                       #
#      HOW WIND STATISTICS WORK:                       #
#      l6 is a per-minute counter reset by firmware.   #
#      Each value = pulses in the last 60 seconds.     #
#      sampling_size: 2 = last 2 readings = 2 min avg  #
#                                                       #
#########################################################

sensor:

  - platform: history_stats
    name: "Daily rain clicks"
    unique_id: dailyrainclicks
    entity_id: binary_sensor.0x00124b000633d676_l7
    state: "on"
    type: count
    start: "{{ now().replace(hour=0, minute=0, second=0) }}"
    end: "{{ now() }}"

  - platform: statistics
    name: "Wind speed 2min avg"
    unique_id: windspeed_2min_avg
    entity_id: sensor.wind_speed
    state_characteristic: mean
    max_age:
      minutes: 2
    sampling_size: 2
    precision: 1

  - platform: statistics
    name: "Wind gust"
    unique_id: wind_gust
    entity_id: sensor.wind_speed
    state_characteristic: max
    max_age:
      minutes: 2
    sampling_size: 2
    precision: 1


#########################################################
#                                                       #
#      TEMPLATE SENSORS                                 #
#                                                       #
#########################################################

template:

  #------------------------------------------------------
  # BME280 derived values
  #------------------------------------------------------

  - sensor:
      - name: "Absolute humidity shed"
        unique_id: abs_humidity_shed
        unit_of_measurement: "g/m³"
        state_class: measurement
        state: >
          {% set h = states('sensor.humidity_shed') | float(-1) %}
          {% set t = states('sensor.temperature_shed') | float(-99) %}
          {% if h < 0 or t == -99 %}
            unknown
          {% else %}
            {{ (h * 6.112 * 2.1674 * e**((t * 17.67) / (t + 243.5)) / (t + 273.15)) | round(1) }}
          {% endif %}

  - sensor:
      - name: "Dewpoint shed"
        unique_id: dewpoint_shed
        unit_of_measurement: "°C"
        device_class: temperature
        state_class: measurement
        state: >
          {% set h = states('sensor.humidity_shed') | int(0) %}
          {% set t = states('sensor.temperature_shed') | float(0) %}
          {% if h <= 0 %}
            unknown
          {% else %}
            {{ (log(h / 100) + 18.678 * t / (257.14 + t)) | round(1) }}
          {% endif %}

  #------------------------------------------------------
  # Rain
  #------------------------------------------------------

  - sensor:
      - name: "Rainfall today"
        unique_id: rainfall_today
        unit_of_measurement: "mm"
        device_class: precipitation
        state_class: total_increasing
        state: >
          {% set count = states('sensor.daily_rain_clicks') | int(0) %}
          {% set mm_per_pulse = 0.30303 %}
          {{ (count * mm_per_pulse) | round(1, 'floor') }}

  #------------------------------------------------------
  # Wind pulse (raw counter from PTVO firmware, resets every 60s)
  #------------------------------------------------------

  - sensor:
      - name: "Wind pulse"
        unique_id: wind_pulse
        unit_of_measurement: "clicks/min"
        state_class: measurement
        icon: mdi:rotate-right
        availability: >
          {{ states('number.0x00124b000633d676_l6') not in ('unknown', 'unavailable') }}
        state: >
          {{ states('number.0x00124b000633d676_l6') | int(0) }}

  #------------------------------------------------------
  # Wind speed
  #------------------------------------------------------
  - sensor:
      - name: "Wind speed"
        unique_id: windspeed
        unit_of_measurement: "m/s"
        state_class: measurement
        availability: >
          {{ states('number.0x00124b000633d676_l6') not in ('unknown', 'unavailable') }}
        state: >
          {% set count = states('number.0x00124b000633d676_l6') | int(0) %}
          {% set m_per_pulse = 0.2826 %}
          {% set interval = 60 %}
          {{ ((count / interval) * m_per_pulse) | round(2) }}

  - sensor:
      - name: "Wind speed km/h"
        unique_id: windkmh
        unit_of_measurement: "km/h"
        state_class: measurement
        availability: >
          {{ states('sensor.wind_speed') not in ('unknown', 'unavailable') }}
        state: >
          {% set mps = states('sensor.wind_speed') | float(0) %}
          {{ (mps * 3.6) | round(1) }}

  - sensor:
      - name: "Wind speed 2min avg km/h"
        unique_id: windspeed_2min_avg_kmh
        unit_of_measurement: "km/h"
        state_class: measurement
        state: >
          {% set mps = states('sensor.wind_speed_2min_avg') | float(0) %}
          {{ (mps * 3.6) | round(1) }}

  - sensor:
      - name: "Wind gust km/h"
        unique_id: wind_gust_kmh
        unit_of_measurement: "km/h"
        state_class: measurement
        icon: mdi:weather-windy-variant
        state: >
          {% set mps = states('sensor.wind_gust') | float(0) %}
          {{ (mps * 3.6) | round(1) }}

  #------------------------------------------------------
  # Wind force (text + Beaufort number)
  #------------------------------------------------------

  - sensor:
      - name: "Wind force"
        unique_id: windforce
        icon: mdi:weather-windy
        state: >
          {% set wind = states('sensor.wind_speed_2min_avg') | float(0) %}
          {% set w = wind | round(1) %}
          {% if wind <= 0.2 %}Bft 0 – Windstil, {{ w }} m/s
          {% elif wind <= 1.5 %}Bft 1 – Flauwe wind, {{ w }} m/s
          {% elif wind <= 3.3 %}Bft 2 – Zwakke wind, {{ w }} m/s
          {% elif wind <= 5.4 %}Bft 3 – Lichte bries, {{ w }} m/s
          {% elif wind <= 7.9 %}Bft 4 – Matige bries, {{ w }} m/s
          {% elif wind <= 10.7 %}Bft 5 – Frisse bries, {{ w }} m/s
          {% elif wind <= 13.8 %}Bft 6 – Krachtige wind, {{ w }} m/s
          {% elif wind <= 17.1 %}Bft 7 – Harde wind, {{ w }} m/s
          {% elif wind <= 20.7 %}Bft 8 – Stormachtig, {{ w }} m/s
          {% elif wind <= 24.4 %}Bft 9 – Storm, {{ w }} m/s
          {% elif wind <= 28.4 %}Bft 10 – Zware storm, {{ w }} m/s
          {% elif wind <= 32.6 %}Bft 11 – Zeer zware storm, {{ w }} m/s
          {% else %}Bft 12 – Orkaan, {{ w }} m/s
          {% endif %}

  - sensor:
      - name: "Beaufort"
        unique_id: beaufort
        unit_of_measurement: "Bft"
        icon: mdi:weather-windy
        state: >
          {% set wind = states('sensor.wind_speed_2min_avg') | float(0) %}
          {% if wind <= 0.2 %}0
          {% elif wind <= 1.5 %}1
          {% elif wind <= 3.3 %}2
          {% elif wind <= 5.4 %}3
          {% elif wind <= 7.9 %}4
          {% elif wind <= 10.7 %}5
          {% elif wind <= 13.8 %}6
          {% elif wind <= 17.1 %}7
          {% elif wind <= 20.7 %}8
          {% elif wind <= 24.4 %}9
          {% elif wind <= 28.4 %}10
          {% elif wind <= 32.6 %}11
          {% else %}12
          {% endif %}

  #------------------------------------------------------
  # Wind direction
  #------------------------------------------------------

  - sensor:
      - name: "Wind azimuth"
        unique_id: wind_azimuth
        unit_of_measurement: "°"
        state: >
          {% set wind = states('sensor.wind_voltage') | float(0) %}
          {% if wind <= 0.21 %}112.5
          {% elif wind <= 0.27 %}67.5
          {% elif wind <= 0.30 %}90.0
          {% elif wind <= 0.41 %}157.5
          {% elif wind <= 0.60 %}135.0
          {% elif wind <= 0.79 %}202.5
          {% elif wind <= 0.93 %}180.0
          {% elif wind <= 1.31 %}22.5
          {% elif wind <= 1.49 %}45.0
          {% elif wind <= 1.93 %}247.5
          {% elif wind <= 2.03 %}225.0
          {% elif wind <= 2.26 %}337.5
          {% elif wind <= 2.53 %}0.0
          {% elif wind <= 2.67 %}292.5
          {% elif wind <= 2.86 %}315.0
          {% elif wind <= 3.05 %}270.0
          {% else %}295.5
          {% endif %}

  - sensor:
      - name: "Wind direction"
        unique_id: wind_direction
        icon: mdi:compass-outline
        state: >
          {% set degrees = states('sensor.wind_azimuth') | float(0) %}
          {% set abbr = ['N','NNO','NO','ONO','O','OZO','ZO','ZZO','Z','ZZW','ZW','WZW','W','WNW','NW','NNW'] %}
          {% set i = ((degrees / 22.5) | round(0)) | int %}
          {% set i = 0 if i == 16 else i %}
          {{ abbr[i] }}

#########################################################
#                                                       #
#            END OF CONFIGURATION FILE                  #
#                                                       #
#########################################################