weewx, Home Assistant and MQTT

59 views
Skip to first unread message

Alastair L

unread,
Feb 16, 2026, 6:44:03 AM (2 days ago) Feb 16
to weewx-user
Hi

I've been trying to get WeeWX talking to Home Assistant via MQTT with zero success and can't find anything to point me in the right direction.  Hours and hours of chats with ChatGPT have led me nowhere, well mostly round in circles.  

I'm running WeeWX version 5.1.0  (previously upgraded from V4.something) on a RPI4 and Home Assistant OS on another RPi4, both on the same home network.

I believe that the WeeWX log should show MQTT log lines if it is working, but no MQTT configurations that I have tried have worked.  

 If anyone has successfully got the two to communicate I would be very greatful if you could share the relevant MQTT entries in weewx.config.  

thanks

michael.k...@gmx.at

unread,
Feb 16, 2026, 6:59:37 AM (2 days ago) Feb 16
to weewx-user

Do you have a MQTT Broker on your local network?

The easiest setup:

- MQTT Broker on your local network

In weewx.conf configure the MQTT xtension as you need it, mine looks like that, the broker is on the same machine as weewx:

    [[MQTT]]
        server_url = mqtt://localhost:1883/
        topic = weather
        binding = loop
        aggregation = aggregate

And on the weewx side, that should be it.

I use mosquitto and have configured it for websockets with no security whatsoever inthe local LAN:

/etc/mosquitto/mosquitto.conf
persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

listener 1883 0.0.0.0
allow_anonymous true
protocol mqtt
listener 9001 0.0.0.0
protocol websockets


Greg Troxel

unread,
Feb 16, 2026, 7:18:48 AM (2 days ago) Feb 16
to Alastair L, weewx-user
It's too bad ChatGPT didn't explain to you how to ask for help! (But
seriously, thank you for not posting AI drivel and asking humans to
spend time reading it.)

You haven't explained what mqtt code you are using with weewx, including
name, version, where you got it.

You didn't include the config that you believe from reading the
documentation and examples you might find on the web as correct.

You haven't said what you have configured in home assistant and how you
have tested that, including by using mosquitto_sub and mosquitto_pub.

(As alawys, follow up on list, not to me directly. It would be rude of
me to quote private mail on the list, and I don't want to provide
offlist help as that doesn't help the next person.)



Tom Farley

unread,
Feb 16, 2026, 8:40:33 AM (2 days ago) Feb 16
to weewx...@googlegroups.com
If you are using Home Assistant (on your LAN as the MQTT Broker) requires that MQTT clients support HA’s ‘discovery’ protocol by default, have you configured HA MQTT not to require HA’s discovery protocol?
From HA website
‘''
Change MQTT Discovery Options

The MQTT discovery options can be changed by following these steps:

Go to Settings > Devices & services.
Find the MQTT integration and select it.
To open the MQTT discovery options page, select the Configure MQTT Options button.
‘’'

weewx-mqtt would need to have the support the HA’s discovery protocol or you need to configure HA MQTT not to use mqtt discovery.
I took a quick look at weewx-mqtt source (if that is what you are using) and I did not see support for the ‘discovery’ protocol.

HA requires the client use user credentials (it does not support anonymous), it will work with port 1883 or 8883 (TLS).

Good luck
> --
> You received this message because you are subscribed to the Google Groups "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/weewx-user/3036ddd0-75c5-4c20-b928-134c70a6ab0dn%40googlegroups.com.

Vince Skahan

unread,
Feb 16, 2026, 11:06:17 AM (2 days ago) Feb 16
to weewx-user
Agree with Michael's post above, although I don't even enable websockets in my setup for feeding Home Assistant.

Definitely verify with mosquitto_sub, mosquitto_pub, and checking your mosquitto and weewx logs to make sure MQTT is working first.

My setup:
  • I display weewx data in a Home Assistant dashboard without any username/passwords in MQTT by defining MQTT sensors and referencing them directly.
  • I do not use HA discovery at all.
  • No MQTT user/pass is required. 
  • No MQTT encrypted ports are required.
  • No websockets support is required.

MQTT config file is wide open since it's LAN-only and my LAN permits no incoming traffic
   listener 1883
   allow_anonymous true

MQTT docker-compose.yaml - I run the mosquitto broker in docker, 

services:
  mosquitto:
    restart: unless-stopped
    image: eclipse-mosquitto:2.0.18
    hostname: mosquitto
    container_name: mosquitto
    expose:
      - "1883"
    ports:
      - "1883:1883"
    volumes:
      - ./mosquitto.conf:/mosquitto/config/mosquitto.conf
      - /mnt/mosquitto/log:/mosquitto/log


In weewx.conf

    [[MQTT]]
        enable = true
        client_id = vp2 
        server_url = mqtt://192.168.1.69:1883/
        append_units_label = false
        binding = loop,archive
        topic = vp2
        aggregation = aggregate
        log_success = false           # set true for 'very' verbose logging
        log_failure = true



In the HA configuration.yaml file

    mqtt: !include mqtt.yaml

In the HA mqtt.yaml file

sensor:
  - name: "Gust"
    device_class: "speed"
    state_topic: "vp2/loop"
    unique_id: 4e482881-716c-4fc9-bfd1-89e0d12e139e
    unit_of_measurement: 'mph'
    value_template: "{{ value_json.windGust | float | round(0) }}"
  - name: "GustDir"
    device_class: "wind_direction"
    state_topic: "vp2/loop"
    unique_id: ae12ec9b-50d9-4b68-85f8-960984d62c61
    value_template: "{{ value_json.windGustDir | float | round(0) }}"
  - name: "Rain"
    device_class: "precipitation"
    state_topic: "vp2/loop"
    unique_id: f4918e00-e9b0-4e0b-ba03-41b5340d3775
    unit_of_measurement: 'in'
    value_template: "{{ value_json.dayRain | float | round(2) }}"
  - name: "Outside"
    device_class: "temperature"
    state_topic: "vp2/loop"
    unique_id: a027cb3d-e90a-44eb-b3ca-53292df4d174
    unit_of_measurement: '°F'
    value_template: "{{ value_json.outTemp | float | round(1) }}"


In the yaml for my dashboard....I use a 'ring-tile' to display a gauge with colorization in the outer ring based on temperature...

                  "cards": [
                    {
                      "type": "horizontal-stack",
                      "cards": [
                        {
                          "type": "custom:ring-tile",
                          "entity": "sensor.outside",
                          "scale": "ticks_with_labels",
                          "middle_element": "value_with_unit",
                          "bottom_element": "name",
                          "ring_size": 3,
                          "name": "Outside",
                          "min": 0,
                          "max": 110,
                          "max_decimals": 0,
                          "min_decimals": 0,
                          "ring_only": true,
                          "colour": {
                            "0": "ha_blue",
                            "40": "cyan",
                            "60": "lightgreen",
                            "70": "green",
                            "80": "ha_orange",
                            "90": "ha_red"
                          },
                          "card_mod": {
                            "style": "ha-card {\n  background: rgb(217,217,217);\n  border: 0px;\n}\n"
                          }
                        },


(and so on)

Alastair

unread,
Feb 16, 2026, 12:29:18 PM (2 days ago) Feb 16
to weewx...@googlegroups.com
Hi Tom and Vince 

Many thanks for your replies.  With your snippets I'm half way there, weewx is now doing what it should.  

I've still to figure out why HA refuses to do its part, but that's for another day...

thanks again 

Alastair

Reply all
Reply to author
Forward
0 new messages