Weewx Configuration

Thanks to @jgoakley Jeff for the inspiration on this!

I have a significant collection of weather and environmental sensors that all eventually report to weewx (https://weewx.com/) and so wanted to get data from that into Home Assistant. After “overthinking” this for a few hours, turns out it REALLY easy. This is still a work-in-progress, doing things like adding IDs and building some dashboards; but hopefully this will get someone else started,

weewx can be configured to generate MQTT messages - and Home Assistant can easily read those messages. I’m sure others will embellish this and show even better ways; but here are the basics:

Download Mosquitto (https://mosquitto.org/) or use a broker of your choice and get it running somewhere. I ran it on my weewx host.

Configure weewx for MQTT by downloading Matt Wall’s weewx-mqtt from here (GitHub - matthewwall/weewx-mqtt: upload data to mqtt broker) and follow the directions to install. Here’s the appropriate entries in my weewx.config

[[MQTT]]
server_url = mqtt://@localhost:1883/
retain = True

Add the MQTT integration (settings/Devices and Services) to Home Assistant and follow the documentation to configure it and point it to your broker,

Add the weewx topics to your configruation.yaml file. Here’s a snippet of mine:
mqtt:
sensor:
- state_topic: “weather/outTemp_F”
name: “Outdoor Temperature”
unit_of_measurement: ‘F’
device_class: ‘temperature’
value_template: “{{ value | round(1) }}”
icon: “mdi:thermometer”
- state_topic: “weather/windSpeed_mph”
name: “Wind Speed”
unit_of_measurement: ‘mph’
value_template: “{{ value | round(1) }}”
icon: “mdi:weather-windy-variant”
- state_topic: “weather/windGust_mph”
name: “Wind Gust”
unit_of_measurement: ‘mph’
value_template: “{{ value | round(1) }}”
icon: “mdi:weather-windy”
- state_topic: “weather/outTemp_F”
name: “Outdoor Temperature”
unit_of_measurement: ‘F’
device_class: ‘temperature’
value_template: “{{ value | round(1) }}”
icon: “mdi:thermometer”

Restart Home Assistant and look for the names of the topics as entities that you can use in Dashboards or Automations.

5 Likes

Nice, but please format the configs in your post. Others can’t copy and paste it as it stands.

Nice! I just did this over the past week as well. It’s been working great.

I avoided using MQTT for a long time and now don’t know why. It was relatively easy to get going. I loathed calling out to Weatherunderground to get my OWN sensors’ data and had had enough.

Now everything is local and not dependent on WU’s flaky availability, etc.

Do you have weewx on the same machine as HA, or a different machine?

I’m running it on a separate Raspberry Pi 3; I suppose it could run in docker on the same server; but, at least mine is using an SDR dongle to talk to 433Mhz sensors and that’s a pretty heavy load on the USB subsystem, at least on the Pi. With a Z-Wave dongle (which I don’t use - I run all my Z-Wave through my Vivint security panel) that might get “interesting”

OK - gonna have to work on that - I TRIED to do that but apparently failed.

Look for the </> button above when you edit — then put the code between the two sets of three backticks.

1 Like

delete please