WeeWX, MQTT and how to import Data

Hey Dave, thanks for this! I am still on v4.8 and seems like I should update eventually. I will update my config above as soon as I tested it. Will link yours in the meantime.

In that case here’s the full config for anyone who might find it useful. Note that I’ve commented out some entries that my setup doesn’t have, and also added some new ones for various soil sensor readings.

There’s also a few where WeeWX provides the data but it’s not coming through via MQTT, e.g. wind direction and wind gust, I need to play with that, probably by setting the retained flag on the messages if that’s where the problem lies.

Another note, for the WeeWX integration I’m using Michael Schantl’s WeeWX-MQTT, so this may also depend on which WeeWX extension you’re using to get the data into mosquitto.

# To see what the WeeWX MQTT topics are called:
#
# mosquitto_sub -v -t "weather/#" -h localhost

mqtt:
  sensor:
    # Temperature

    - name: weather_station_outtemp_c
      unique_id: uniqueid__weather_outtemp_c
      icon: mdi:thermometer
      state_topic: "weather/outTemp_degree_C"
      value_template: "{{ value | round(1) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "°C"
      device_class: temperature

    # Not terribly useful because the reading is affected by heat from the
    # electronics.
    - name: weather_station_intemp_c
      unique_id: uniqueid__weather_intemp_c
      icon: mdi:thermometer
      state_topic: "weather/inTemp_degree_C"
      value_template: "{{ value | round(1) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "°C"
      device_class: temperature

    - name: weather_station_dewpoint_c
      unique_id: uniqueid__weather_dewpoint_c
      icon: mdi:thermometer
      state_topic: "weather/dewpoint_degree_C"
      value_template: "{{ value | round(1) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "°C"
      device_class: temperature

    # Not present on this station
    #- name: weather_station_indewpoint_c
    #  unique_id: uniqueid__weather_indewpoint_c
    #  icon: mdi:thermometer
    #  state_topic: "weather/inDewpoint_degree_C"
    #  value_template: "{{ value | round(1) }}"
    #  availability_topic: "weather/connection_status"
    #  payload_available: "online"
    #  payload_not_available: "offline"
    #  unit_of_measurement: "°C"
    #  device_class: temperature

    - name: weather_station_windchill_c
      unique_id: uniqueid__weather_windchill_c
      icon: mdi:thermometer
      state_topic: "weather/windchill_degree_C"
      value_template: "{{ value | round(1) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "°C"
      device_class: temperature

    # Not present on this station
    #- name: weather_station_apptemp_c
    #  unique_id: uniqueid__weather_apptemp_c
    #  icon: mdi:thermometer
    #  state_topic: "weather/appTemp_degree_C"
    #  value_template: "{{ value | round(1) }}"
    #  availability_topic: "weather/connection_status"
    #  payload_available: "online"
    #  payload_not_available: "offline"
    #  unit_of_measurement: "°C"
    #  device_class: temperature

    - name: weather_station_heatindex_c
      unique_id: uniqueid__weather_geatindex_c
      icon: mdi:thermometer
      state_topic: "weather/heatindex_degree_C"
      value_template: "{{ value | round(1) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "°C"
      device_class: temperature

    # Not present on this station
    #- name: weather_station_humidex_c
    #  unique_id: uniqueid__weather_humindex_c
    #  icon: mdi:thermometer
    #  # Note spelling mistake in the topic.
    #  state_topic: "weather/humidex_degree_C"
    #  value_template: "{{ value | round(1) }}"
    #  availability_topic: "weather/connection_status"
    #  payload_available: "online"
    #  payload_not_available: "offline"
    #  unit_of_measurement: "°C"
    #  device_class: temperature

    # Humidity

    - name: weather_station_outhumidity
      unique_id: uniqueid__weather_outhumidity
      icon: mdi:water-percent
      state_topic: "weather/outHumidity_percent"
      value_template: "{{ value | round(1) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "%"
      device_class: humidity

    # Not present on this station
    #- name: weather_station_inhumidity
    #  unique_id: uniqueid__weather_inhumidity
    #  icon: mdi:water-percent
    #  state_topic: "weather/inHumidity_percent"
    #  value_template: "{{ value | round(1) }}"
    #  availability_topic: "weather/connection_status"
    #  payload_available: "online"
    #  payload_not_available: "offline"
    #  unit_of_measurement: "%"
    #  device_class: humidity

    # Present but gives same readings as atmospheric pressue
    #- name: weather_station_altimeter_mbar
    #  unique_id: uniqueid__weather_altimeter_atmospheric
    #  icon: mdi:gauge
    #  state_topic: "weather/altimeter_mbar"
    #  value_template: "{{ value | round(0) }}"
    #  availability_topic: "weather/connection_status"
    #  payload_available: "online"
    #  payload_not_available: "offline"
    #  unit_of_measurement: "mbar"
    #  device_class: atmospheric_pressure

    - name: weather_station_pressure_mbar
      unique_id: uniqueid__weather_pressure_atmospheric
      icon: mdi:gauge
      state_topic: "weather/pressure_mbar"
      value_template: "{{ value | round(0) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "mbar"
      device_class: atmospheric_pressure

    - name: weather_station_barometer_mbar
      unique_id: uniqueid__weather_barometer_atmospheric
      icon: mdi:gauge
      state_topic: "weather/barometer_mbar"
      value_template: "{{ value | round(0) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "mbar"
      device_class: atmospheric_pressure

    # Wind

    - name: weather_station_windspeed_kph
      unique_id: uniqueid__weather_windspeed_kph
      icon: mdi:weather-windy
      state_topic: "weather/windSpeed_km_per_hour"
      value_template: "{{ value | round(1) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "km/h"
      device_class: wind_speed

    - name: weather_station_windgust_kph
      unique_id: uniqueid__weather_windgust_kph
      icon: mdi:weather-windy-variant
      state_topic: "weather/windGust_km_per_hour"
      value_template: "{{ value | round(1) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "km/h"
      device_class: wind_speed

    - name: weather_station_winddir
      unique_id: uniqueid__weather_winddir
      icon: mdi:wind-turbine
      state_topic: "weather/windDir_degree_compass"
      value_template: "{{ value | round(0) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "°"

    # Not present on this station
    #- name: weather_station_windgustdir
    #  unique_id: uniqueid__weather_windgustdir
    #  icon: mdi:wind-turbine
    #  state_topic: "weather/windGustDir"
    #  value_template: "{{ value | round(0) }}"
    #  availability_topic: "weather/connection_status"
    #  payload_available: "online"
    #  payload_not_available: "offline"
    #  unit_of_measurement: "°"

    # Not present on this station
    #- name: weather_station_windrun_km
    #  unique_id: uniqueid__weather_windrun_km
    #  icon: mdi:wind-turbine
    #  state_topic: "weather/windrun_km"
    #  value_template: "{{ value | round(3) }}"
    #  availability_topic: "weather/connection_status"
    #  payload_available: "online"
    #  payload_not_available: "offline"
    #  unit_of_measurement: "km"
    #  device_class: distance

    - name: weather_station_rainrate_cm_per_hour
      unique_id: uniqueid__weather_rainrate_cm_per_hour
      icon: mdi:umbrella-outline
      state_topic: "weather/rainRate_cm_per_hour"
      value_template: "{{ (value | float * 10) | round(1) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "cm/h"
      device_class: precipitation_intensity

    - name: weather_station_rain_cm
      unique_id: uniqueid__weather_rain_cm
      icon: mdi:umbrella
      state_topic: "weather/rain_cm"
      value_template: "{{ (value | float * 10) | round(1) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "cm"
      device_class: precipitation
      force_update: true # important!

    # Not present on this station
    #- name: weather_station_rain24_mm
    #  unique_id: uniqueid__weather_rain24_mm
    #  icon: mdi:umbrella
    #  state_topic: "weather/rain24_cm"
    #  value_template: "{{ (value | float * 10) | round(1) }}"
    #  availability_topic: "weather/connection_status"
    #  payload_available: "online"
    #  payload_not_available: "offline"
    #  unit_of_measurement: "mm"
    #  device_class: precipitation

    # Not present on this station
    #- name: weather_station_hourrain_mm
    #  unique_id: uniqueid__weather_hourrain_mm
    #  icon: mdi:umbrella
    #  state_topic: "weather/hourRain_cm"
    #  value_template: "{{ (value | float * 10) | round(1) }}"
    #  availability_topic: "weather/connection_status"
    #  payload_available: "online"
    #  payload_not_available: "offline"
    #  unit_of_measurement: "mm"
    #  device_class: precipitation

    # Not present on this station
    #- name: weather_station_dayrain_mm
    #  unique_id: uniqueid__weather_dayrain_mm
    #  icon: mdi:umbrella
    #  state_topic: "weather/dayRain_cm"
    #  value_template: "{{ (value | float * 10) | round(1) }}"
    #  availability_topic: "weather/connection_status"
    #  payload_available: "online"
    #  payload_not_available: "offline"
    #  unit_of_measurement: "mm"
    #  device_class: precipitation

    # Not present on this station
    #- name: weather_station_weekrain_mm
    #  unique_id: uniqueid__weather_weekrain_mm
    #  icon: mdi:umbrella
    #  state_topic: "weather/weekRain_cm"
    #  value_template: "{{ (value | float * 10) | round(1) }}"
    #  availability_topic: "weather/connection_status"
    #  payload_available: "online"
    #  payload_not_available: "offline"
    #  unit_of_measurement: "mm"
    #  device_class: precipitation

    # Not present on this station
    #- name: weather_station_monthrain_mm
    #  unique_id: uniqueid__weather_monthrain_mm
    #  icon: mdi:umbrella
    #  state_topic: "weather/monthRain_cm"
    #  value_template: "{{ (value | float * 10) | round(1) }}"
    #  availability_topic: "weather/connection_status"
    #  payload_available: "online"
    #  payload_not_available: "offline"
    #  unit_of_measurement: "mm"
    #  device_class: precipitation

    - name: weather_station_evapotranspiration_mm
      unique_id: uniqueid__evapotranspiration_mm
      icon: mdi:water-opacity
      state_topic: "weather/ET_cm"
      value_template: "{{ (value | float * 10) | round(5) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "mm"
      device_class: precipitation
      force_update: true # important!

    # Solar

    - name: weather_station_radiation_wpm2
      unique_id: uniqueid__weather_radiation_irradiance
      icon: mdi:radioactive
      state_topic: "weather/radiation_watt_per_meter_squared"
      value_template: "{{ value | round(1) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "W/m²"
      device_class: irradiance

    - name: weather_station_maxsolarrad_wpm2
      unique_id: uniqueid__weather_maxsolarrad_irradiance
      icon: mdi:radioactive
      state_topic: "weather/maxSolarRad_watt_per_meter_squared"
      value_template: "{{ value | round(1) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "W/m²"
      device_class: irradiance

    - name: weather_station_cloudbase_meter
      unique_id: uniqueid__weather_cloudbase_distance
      state_topic: "weather/cloudbase_meter"
      value_template: "{{ value | round(0) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "m"
      device_class: distance

    - name: weather_station_uv
      unique_id: uniqueid__weather_uv
      icon: mdi:sunglasses
      state_topic: "weather/UV_uv_index"
      value_template: "{{ value | round(1) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: ""

    # Soil

    - name: weather_station_soiltemp1_c
      unique_id: uniqueid__weather_soiltemp1_c
      icon: mdi:thermometer
      state_topic: "weather/soilTemp1_degree_C"
      value_template: "{{ value | round(1) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "°C"
      device_class: temperature

    - name: weather_station_soilMoist1_centibar
      unique_id: uniqueid__soilMoist1_centibar
      icon: mdi:water-opacity
      state_topic: "weather/soilMoist1_centibar"
      value_template: "{{ value | round(1) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "cbar"
      device_class: precipitation

    - name: weather_station_leafWet1_count
      unique_id: uniqueid__leafWet1_count
      icon: mdi:water-opacity
      state_topic: "weather/leafWet1_count"
      value_template: "{{ value | round(0) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: ""
      device_class: precipitation

    - name: weather_station_soiltemp2_c
      unique_id: uniqueid__weather_soiltemp2_c
      icon: mdi:thermometer
      state_topic: "weather/soilTemp2_degree_C"
      value_template: "{{ value | round(1) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "°C"
      device_class: temperature

    - name: weather_station_soilMoist2_centibar
      unique_id: uniqueid__soilMoist2_centibar
      icon: mdi:water-opacity
      state_topic: "weather/soilMoist2_centibar"
      value_template: "{{ value | round(1) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: "cbar"
      device_class: precipitation

    - name: weather_station_leafWet2_count
      unique_id: uniqueid__leafWet2_count
      icon: mdi:water-opacity
      state_topic: "weather/leafWet2_count"
      value_template: "{{ value | round(0) }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      unit_of_measurement: ""
      device_class: precipitation

    # Misc

    - name: weather_station_weewx_update_datetime
      unique_id: uniqueid__weather_datetime
      icon: mdi:calendar-clock
      state_topic: "weather/dateTime_unix_epoch"
      value_template: "{{ value | int | timestamp_local() }}"
      availability_topic: "weather/connection_status"
      payload_available: "online"
      payload_not_available: "offline"
      device_class: timestamp

template:
  - binary_sensor:
      - name: weather_station_weewx_connected
        unique_id: uniqueid__weather_connected
        icon: mdi:calendar-sync-outline
        state: >
          {%- set seconds = (now() - states.sensor.weather_station_weewx_update_datetime.last_changed).total_seconds() -%}
          {{ seconds < 120 }}
        availability: >
          {{ has_value('sensor.weather_station_weewx_update_datetime') }}
        device_class: connectivity

I just noticed, from a comment on Matthew Wall’s WeeWX-MQTT, that you may be using that instead of Michael Schantl’s one. So the naming difference may be due to the different code base… both of them are a bit of a headache, they were written for now out-of-date versions of WeeWX and paho-mqtt and it looks like neither are taking updates. I went with the MS version rather than the MW version because it was easier to get going with WeeWX 5.x and HA, but it doesn’t seem to honour the persistence flag, possibly because the version of paho-mqtt it’s using is too old to support it.

In the interests of sacrifice for the communal good :upside_down_face: I’ve uninstalled the MS WeeWX-MQTT and instead installed the MW WeeWX-MQTT, which exposes the missing topics. So you need a different HA YAML config depending on whether you use the MS WeeWX-MQTT or the MW WeeWX-MQTT.

For those just joining us, there are two things called WeeWX-MQTT, one by Michael Schantl (MS), one by Matthew Wall (MW). Both date from about the same time and haven’t been updated for awhile, which means they’re tied to old versions of the paho-mqtt library so you’ll need to pip install paho-mqtt==$old_version, as well as change the install command from wee_extension --install to weectl extension install for WeeWX 5.x.

In terms of which one to go with, MW-WeeWX-MQTT is slightly more configurable than MS-WeeWX-MQTT, as well as exposing a few more topics (actually synthetic topics like rainfall in the last 24 hours). For that one the paho-mqtt version needed is 1.6.1, so pip install paho-mqtt==1.6.1.

Here’s the final updated config, currently set up for MW WeeWX-MQTT but with comments indicating what to change for MS WeeWX-MQTT, there are also comments for other sensors/topics that have special considerations. This also includes soil/leaf sensors if you have those.

Tested to work with WeeWX 5.x up to the latest release, 5.1.0, with credit to @ThomDietrich whose work this is based on.

# To see what the WeeWX MQTT topics are called:
#
# mosquitto_sub -v -t "weather/#" -h localhost
#
# Michael Schantl's WeeWX-MQTT provides "weather/connection_status" but
# Matthew Wall's WeeWX-MQTT doesn't, or at least its status is always
# reported as "offline" so the availability check is commented out for
# this version.

mqtt:
  sensor:
    # Temperature

    # MW also makes this available as outTemp_C
    - name: weather_station_outtemp_c
      unique_id: uniqueid__weather_outtemp_c
      icon: mdi:thermometer
      state_topic: "weather/outTemp_degree_C"
      value_template: "{{ value | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "°C"
      device_class: temperature

    # MW has inTemp_C, MS has inTemp_degree_C.
    # Not terribly useful because the reading is affected by heat from the
    # electronics.
    - name: weather_station_intemp_c
      unique_id: uniqueid__weather_intemp_c
      icon: mdi:thermometer
      state_topic: "weather/inTemp_C"
      value_template: "{{ value | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "°C"
      device_class: temperature

    - name: weather_station_dewpoint_c
      unique_id: uniqueid__weather_dewpoint_c
      icon: mdi:thermometer
      state_topic: "weather/dewpoint_degree_C"
      value_template: "{{ value | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "°C"
      device_class: temperature

    # Not present on this station
    #- name: weather_station_indewpoint_c
    #  unique_id: uniqueid__weather_indewpoint_c
    #  icon: mdi:thermometer
    #  state_topic: "weather/inDewpoint_degree_C"
    #  value_template: "{{ value | round(1) }}"
    #  availability_topic: "weather/connection_status"
    #  payload_available: "online"
    #  payload_not_available: "offline"
    #  unit_of_measurement: "°C"
    #  device_class: temperature

    # MW also makes this available as windchill_C.
    - name: weather_station_windchill_c
      unique_id: uniqueid__weather_windchill_c
      icon: mdi:thermometer
      state_topic: "weather/windchill_degree_C"
      value_template: "{{ value | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "°C"
      device_class: temperature

    # Present in MW, not present in MS.
    - name: weather_station_apptemp_c
      unique_id: uniqueid__weather_apptemp_c
      icon: mdi:thermometer
      state_topic: "weather/appTemp_C"
      value_template: "{{ value | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "°C"
      device_class: temperature

    - name: weather_station_heatindex_c
      unique_id: uniqueid__weather_geatindex_c
      icon: mdi:thermometer
      state_topic: "weather/heatindex_degree_C"
      value_template: "{{ value | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "°C"
      device_class: temperature

    # Present in MW, not present in MS.
    - name: weather_station_humidex_c
      unique_id: uniqueid__weather_humindex_c
      icon: mdi:thermometer
      # Note spelling mistake in the topic.
      state_topic: "weather/humidex_degree_C"
      value_template: "{{ value | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "°C"
      device_class: temperature

    # Humidity

    # MW also makes this available as outHumidity.
    - name: weather_station_outhumidity
      unique_id: uniqueid__weather_outhumidity
      icon: mdi:water-percent
      state_topic: "weather/outHumidity_percent"
      value_template: "{{ value | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "%"
      device_class: humidity

    # Not present on this station
    #- name: weather_station_inhumidity
    #  unique_id: uniqueid__weather_inhumidity
    #  icon: mdi:water-percent
    #  state_topic: "weather/inHumidity_percent"
    #  value_template: "{{ value | round(1) }}"
    #  availability_topic: "weather/connection_status"
    #  payload_available: "online"
    #  payload_not_available: "offline"
    #  unit_of_measurement: "%"
    #  device_class: humidity

    # Present but gives same readings as atmospheric pressue
    #- name: weather_station_altimeter_mbar
    #  unique_id: uniqueid__weather_altimeter_atmospheric
    #  icon: mdi:gauge
    #  state_topic: "weather/altimeter_mbar"
    #  value_template: "{{ value | round(0) }}"
    #  availability_topic: "weather/connection_status"
    #  payload_available: "online"
    #  payload_not_available: "offline"
    #  unit_of_measurement: "mbar"
    #  device_class: atmospheric_pressure

    - name: weather_station_pressure_mbar
      unique_id: uniqueid__weather_pressure_atmospheric
      icon: mdi:gauge
      state_topic: "weather/pressure_mbar"
      value_template: "{{ value | round(0) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "mbar"
      device_class: atmospheric_pressure

    - name: weather_station_barometer_mbar
      unique_id: uniqueid__weather_barometer_atmospheric
      icon: mdi:gauge
      state_topic: "weather/barometer_mbar"
      value_template: "{{ value | round(0) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "mbar"
      device_class: atmospheric_pressure

    # Wind

    # MW also makes this available as windSpeed_kph.
    - name: weather_station_windspeed_kph
      unique_id: uniqueid__weather_windspeed_kph
      icon: mdi:weather-windy
      state_topic: "weather/windSpeed_km_per_hour"
      value_template: "{{ value | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "km/h"
      device_class: wind_speed

    - name: weather_station_windgust_kph
      unique_id: uniqueid__weather_windgust_kph
      icon: mdi:weather-windy-variant
      # windGust_kph in MW, windGust_km_per_hour in MS
      # state_topic: "weather/windGust_km_per_hour"
      state_topic: "weather/windGust_kph"
      value_template: "{{ value | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "km/h"
      device_class: wind_speed

    - name: weather_station_winddir
      unique_id: uniqueid__weather_winddir
      icon: mdi:wind-turbine
      state_topic: "weather/windDir_degree_compass"
      value_template: "{{ value | round(0) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "°"

    # Present in MW, not present in MS.
    - name: weather_station_windgustdir
      unique_id: uniqueid__weather_windgustdir
      icon: mdi:wind-turbine
      state_topic: "weather/windGustDir"
      value_template: "{{ value | round(0) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "°"

    # Present in MW, not present in MS.
    - name: weather_station_windrun_km
      unique_id: uniqueid__weather_windrun_km
      icon: mdi:wind-turbine
      state_topic: "weather/windrun_km"
      value_template: "{{ value | round(3) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "km"
      device_class: distance

    - name: weather_station_rainrate_cm_per_hour
      unique_id: uniqueid__weather_rainrate_cm_per_hour
      icon: mdi:umbrella-outline
      state_topic: "weather/rainRate_cm_per_hour"
      value_template: "{{ (value | float * 10) | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "cm/h"
      device_class: precipitation_intensity

    - name: weather_station_rain_cm
      unique_id: uniqueid__weather_rain_cm
      icon: mdi:umbrella
      state_topic: "weather/rain_cm"
      value_template: "{{ (value | float * 10) | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "cm"
      device_class: precipitation
      force_update: true # important!

    # Present in MW, not present in MS.
    - name: weather_station_rain24_mm
      unique_id: uniqueid__weather_rain24_mm
      icon: mdi:umbrella
      state_topic: "weather/rain24_cm"
      value_template: "{{ (value | float * 10) | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "mm"
      device_class: precipitation

    # Present in MW, not present in MS.
    - name: weather_station_hourrain_mm
      unique_id: uniqueid__weather_hourrain_mm
      icon: mdi:umbrella
      state_topic: "weather/hourRain_cm"
      value_template: "{{ (value | float * 10) | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "mm"
      device_class: precipitation

    # Present in MW, not present in MS.
    - name: weather_station_dayrain_mm
      unique_id: uniqueid__weather_dayrain_mm
      icon: mdi:umbrella
      state_topic: "weather/dayRain_cm"
      value_template: "{{ (value | float * 10) | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "mm"
      device_class: precipitation

    # Not present on this station
    #- name: weather_station_weekrain_mm
    #  unique_id: uniqueid__weather_weekrain_mm
    #  icon: mdi:umbrella
    #  state_topic: "weather/weekRain_cm"
    #  value_template: "{{ (value | float * 10) | round(1) }}"
    #  availability_topic: "weather/connection_status"
    #  payload_available: "online"
    #  payload_not_available: "offline"
    #  unit_of_measurement: "mm"
    #  device_class: precipitation

    # Not present on this station
    #- name: weather_station_monthrain_mm
    #  unique_id: uniqueid__weather_monthrain_mm
    #  icon: mdi:umbrella
    #  state_topic: "weather/monthRain_cm"
    #  value_template: "{{ (value | float * 10) | round(1) }}"
    #  availability_topic: "weather/connection_status"
    #  payload_available: "online"
    #  payload_not_available: "offline"
    #  unit_of_measurement: "mm"
    #  device_class: precipitation

    - name: weather_station_evapotranspiration_mm
      unique_id: uniqueid__evapotranspiration_mm
      icon: mdi:water-opacity
      state_topic: "weather/ET_cm"
      value_template: "{{ (value | float * 10) | round(5) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "mm"
      device_class: precipitation
      force_update: true # important!

    # Solar

    # MW also makes this available as radiation_Wpm2
    - name: weather_station_radiation_wpm2
      unique_id: uniqueid__weather_radiation_irradiance
      icon: mdi:radioactive
      state_topic: "weather/radiation_watt_per_meter_squared"
      value_template: "{{ value | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "W/m²"
      device_class: irradiance

    # MW also makes this available as maxSolarRad_Wpm2
    - name: weather_station_maxsolarrad_wpm2
      unique_id: uniqueid__weather_maxsolarrad_irradiance
      icon: mdi:radioactive
      state_topic: "weather/maxSolarRad_watt_per_meter_squared"
      value_template: "{{ value | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "W/m²"
      device_class: irradiance

    - name: weather_station_cloudbase_meter
      unique_id: uniqueid__weather_cloudbase_distance
      state_topic: "weather/cloudbase_meter"
      value_template: "{{ value | round(0) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "m"
      device_class: distance

    # MW also makes this available as UV.
    - name: weather_station_uv
      unique_id: uniqueid__weather_uv
      icon: mdi:sunglasses
      state_topic: "weather/UV_uv_index"
      value_template: "{{ value | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: ""

    # Soil

    # MW has soilTemp1_C, MS has soilTemp1_degree_C.
    - name: weather_station_soiltemp1_c
      unique_id: uniqueid__weather_soiltemp1_c
      icon: mdi:thermometer
      state_topic: "weather/soilTemp1_C"
      value_template: "{{ value | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "°C"
      device_class: temperature

    - name: weather_station_soilMoist1_centibar
      unique_id: uniqueid__soilMoist1_centibar
      icon: mdi:water-opacity
      state_topic: "weather/soilMoist1_centibar"
      value_template: "{{ value | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "cbar"
      device_class: precipitation

    # There's also a matching leafTemp1_C but this is just a copy of
    # soilTemp1_C.
    - name: weather_station_leafWet1_count
      unique_id: uniqueid__leafWet1_count
      icon: mdi:water-opacity
      state_topic: "weather/leafWet1_count"
      value_template: "{{ value | round(0) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: ""
      device_class: precipitation

    # MW has soilTemp2_C, MS has soilTemp2_degree_C.
    - name: weather_station_soiltemp2_c
      unique_id: uniqueid__weather_soiltemp2_c
      icon: mdi:thermometer
      state_topic: "weather/soilTemp2_C"
      value_template: "{{ value | round(1) }}"
      availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
    # unit_of_measurement: "°C"
      device_class: temperature

    - name: weather_station_soilMoist2_centibar
      unique_id: uniqueid__soilMoist2_centibar
      icon: mdi:water-opacity
      state_topic: "weather/soilMoist2_centibar"
      value_template: "{{ value | round(1) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: "cbar"
      device_class: precipitation

    # There's also a matching leafTemp2_C but this is just a copy of
    # soilTemp2_C.
    - name: weather_station_leafWet2_count
      unique_id: uniqueid__leafWet2_count
      icon: mdi:water-opacity
      state_topic: "weather/leafWet2_count"
      value_template: "{{ value | round(0) }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      unit_of_measurement: ""
      device_class: precipitation

    # Misc

    - name: weather_station_weewx_update_datetime
      unique_id: uniqueid__weather_datetime
      icon: mdi:calendar-clock
      state_topic: "weather/dateTime_unix_epoch"
      value_template: "{{ value | int | timestamp_local() }}"
    # availability_topic: "weather/connection_status"
    # payload_available: "online"
    # payload_not_available: "offline"
      device_class: timestamp

template:
  - binary_sensor:
      - name: weather_station_weewx_connected
        unique_id: uniqueid__weather_connected
        icon: mdi:calendar-sync-outline
        state: >
          {%- set seconds = (now() - states.sensor.weather_station_weewx_update_datetime.last_changed).total_seconds() -%}
          {{ seconds < 120 }}
        availability: >
          {{ has_value('sensor.weather_station_weewx_update_datetime') }}
        device_class: connectivity

homeassistant:
  customize:
    sensor.weather_station_outtemp_c:
      friendly_name: "Temperature"
    sensor.weather_station_intemp_c:
      friendly_name: "Temperature (indoors)"
    sensor.weather_station_dewpoint_c:
      friendly_name: "Dew Point"
    sensor.weather_station_windchill_c:
      friendly_name: "Wind Chill"
    sensor.weather_station_apptemp_c:
      friendly_name: "Apparent Temperature"
    sensor.weather_station_heatindex_c:
      friendly_name: "Heat Index"
    sensor.weather_station_humidex_c:
      friendly_name: "Humidity Index"
    sensor.weather_station_outhumidity:
      friendly_name: "Humidity"
    sensor.weather_station_pressure_mbar:
      friendly_name: "Pressure"
    sensor.weather_station_barometer_mbar:
      friendly_name: "Barometer"
    sensor.weather_station_windspeed_kph:
      friendly_name: "Wind Speed"
    sensor.weather_station_windgust_kph:
      friendly_name: "Wind Gust"
    sensor.weather_station_winddir:
      friendly_name: "Wind Direction"
    sensor.weather_station_windgustdir:
      friendly_name: "Wind Gust Direction"
    sensor.weather_station_windrun_km:
      friendly_name: "Wind Run"
    weather_station_rainrate_cm_per_hour:
      friendly_name: "Rain Rate"
    sensor.weather_station_rain_cm:
      friendly_name: "Rain"
    sensor.weather_station_rain24_mm:
      friendly_name: "Rain (24 hours)"
    sensor.weather_station_hourrain_mm:
      friendly_name: "Rain (hour)"
    sensor.weather_station_dayrain_mm:
      friendly_name: "Rain (day)"
    sensor.weather_station_evapotranspiration_mm:
      friendly_name: "Evapotranspiration"
    weather_station_radiation_wpm2:
      friendly_name: "Solar Radiation"
    sensor.weather_station_maxsolarrad_wpm2:
      friendly_name: "Solar Radiation (max)"
    sensor.weather_station_cloudbase_meter:
      friendly_name: "Cloud Base"
    sensor.weather_station_uv:
      friendly_name: "UV Index"
    sensor.weather_station_soiltemp1_c:
      friendly_name: "Soil Temperature 1"
    sensor.weather_station_soilMoist1_centibar:
      friendly_name: "Soil Moisture 1"
    weather_station_leafWet1_count:
      friendly_name: "Leaf Wetness 1"
    sensor.weather_station_soiltemp2_c:
      friendly_name: "Soil Temperature 2"
    sensor.weather_station_soilMoist2_centibar:
      friendly_name: "Soil Moisture 2"
    sensor.weather_station_leafWet2_count:
      friendly_name: "Leaf Wetness 2"
2 Likes

Amazing work. Thanks Dave!