WeeWX 5.1.0-4 MQTTSubscribe Driver "Topic" Error

160 views
Skip to first unread message

James Michael Wall

unread,
Oct 14, 2025, 6:55:38 PM10/14/25
to weewx-user
Hello,

I am new to using WeeWX, and am having trouble getting the MQTTSubscribe driver to work properly. I am following the directions found at https://github.com/bellrichm/WeeWX-MQTTSubscribe as best as I can, but some of it is hard for me to understand. My basic understanding of WeeWX and MQTT is very limited, so I am going to do the best I can to explain my problem, provide whatever information necessary, and (hopefully) get this issue resolved so I can get my weather station working.

Here is my Hardware/Software Setup Overview:

Weather Station/MQTT Client/MQTT Publisher:

BC-Robotics 1591B Weatherboard with Raspberry Pico 2W, running MicroPython v1.26.1-2025-09-11. This device is collecting, parsing, and sending data from various weather sensors connected to it over WiFi on my local LAN using umqttsimple. This device is set up as an MQTT client, which publishes the sensor data using the topic "weatherpi" to the MQTT broker on the Raspberry Pi Zero 2W listed below. 

Weather Reciever/MQTT Server/MQTT Broker/MQTT Subscriber/WeeWX Server:

Raspberry Pi Zero 2W, running Raspberry OS "Bookworm" with WeeWX version 5.1.0-4 installed as a Debian package via the WeeWX debian repo instructions. I have installed  Mosquitto version 2.0.11, and python3-paho-mqtt 1.6.1-1. I set up Mosquitto to act as an MQTT broker on this device, subscribed to the topic "weatherpi", which is published by the Pico. I have installed the MQTTSubscribe  driver per the instructions found in the Github link above.

AFAICT, I have everything set up correctly on the Pico, and it is publishing successfully to the Mosquitto MQTT server, but when I run sudo weectl station reconfigure, after going through all the prompts, I get the following error:

Traceback (most recent call last):
  File "/usr/share/weewx/weectl.py", line 75, in <module>
    main()
  File "/usr/share/weewx/weectl.py", line 67, in main
    namespace.func(namespace)
  File "/usr/share/weewx/weectllib/__init__.py", line 90, in dispatch
    namespace.action_func(config_dict, namespace)
  File "/usr/share/weewx/weectllib/station_cmd.py", line 311, in reconfigure_station
    weectllib.station_actions.station_reconfigure(config_dict=config_dict,
  File "/usr/share/weewx/weectllib/station_actions.py", line 164, in station_reconfigure
    config_config(config_dict,
  File "/usr/share/weewx/weectllib/station_actions.py", line 207, in config_config
    config_driver(config_dict, driver=driver, no_prompt=no_prompt)
  File "/usr/share/weewx/weectllib/station_actions.py", line 466, in config_driver
    settings = weecfg.prompt_for_driver_settings(final_driver,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/weewx/weecfg/__init__.py", line 520, in prompt_for_driver_settings
    settings = editor.prompt_for_settings()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/etc/weewx/bin/user/MQTTSubscribe.py", line 2424, in prompt_for_settings
    if len(self.existing_options['topics']) > 1:
           ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/configobj/__init__.py", line 554, in __getitem__
    val = dict.__getitem__(self, key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'topics'.

In following the directions given in the top of the weewx-user group with regard to posting, I am attaching my weewx.conf file, and system log from the RP Zero using the following command: journalctl -xe | grep weewx to this post. The other information requested is listed above. If you need anything else, please let me know, I am happy to help.

weewx-20251014-1405.conf.txt
WeeWX Log 20251014 1401.txt

James Michael Wall

unread,
Oct 14, 2025, 7:28:06 PM10/14/25
to weewx-user
Also,

Sorry, I forgot to provide WeeWX status, FWIW:

$ systemctl status weewx
× weewx.service - WeeWX
     Loaded: loaded (/lib/systemd/system/weewx.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2025-10-14 16:24:18 PDT; 2s ago
   Duration: 903ms
       Docs: https://weewx.com/docs
    Process: 4176 ExecStart=weewxd /etc/weewx/weewx.conf (code=exited, status=4)
   Main PID: 4176 (code=exited, status=4)
        CPU: 904ms

Oct 14 16:24:18 Zero2W-1 weewxd[4176]: CRITICAL weewx.engine:     ****             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 14 16:24:18 Zero2W-1 weewxd[4176]: CRITICAL weewx.engine:     ****    File "/etc/weewx/bin/user/MQTTSubscribe.py", line 2011, in __init__
Oct 14 16:24:18 Zero2W-1 weewxd[4176]: CRITICAL weewx.engine:     ****      super().__init__(service_dict, logger)
Oct 14 16:24:18 Zero2W-1 weewxd[4176]: CRITICAL weewx.engine:     ****    File "/etc/weewx/bin/user/MQTTSubscribe.py", line 1751, in __init__
Oct 14 16:24:18 Zero2W-1 weewxd[4176]: CRITICAL weewx.engine:     ****      raise ValueError("[[topics]] is required.")
Oct 14 16:24:18 Zero2W-1 weewxd[4176]: CRITICAL weewx.engine:     ****  ValueError: [[topics]] is required.
Oct 14 16:24:18 Zero2W-1 weewxd[4176]: CRITICAL __main__: Unable to load driver: [[topics]] is required.
Oct 14 16:24:18 Zero2W-1 weewxd[4176]: CRITICAL __main__:     ****  Exiting...
Oct 14 16:24:18 Zero2W-1 systemd[1]: weewx.service: Main process exited, code=exited, status=4/NOPERMISSION
Oct 14 16:24:18 Zero2W-1 systemd[1]: weewx.service: Failed with result 'exit-code'.

vince

unread,
Oct 14, 2025, 7:49:43 PM10/14/25
to weewx-user
Your weewx.conf section looks incomplete/incorrect. You are missing all the configuration info you need to add.

If you look at the examples in https://github.com/bellrichm/WeeWX-MQTTSubscribe/tree/master/exampleConfigs they should give you the basic format needed although you’ll need to figure out your custom mapping of data to weewx database fields.


James Michael Wall

unread,
Oct 17, 2025, 3:06:14 PM10/17/25
to weewx-user
So, I must be doing something wrong, not sure what though. I am attaching my updated weewx.conf file, and the error that it generated.
weewx.conf
WeeWX Error Log.txt

vince

unread,
Oct 17, 2025, 4:05:35 PM10/17/25
to weewx-user
Read the web pages top to bottom a couple times (link).  They are there for a reason.  You might need to read it top to bottom a couple times. Invest the time.  Do what it says.

Rather than randomly trying to hit a good configuration, definitely do the configuration and testing steps starting at (link) and do what the documentation says.  That will output a validly formatted template file you can edit to match your setup and test. Pay particular attention to the comments in the template file it'll generate.

Rich's driver/service is a little unusual in that it seems to have an installer to even do the right thing to put it into place, but I haven't tried that personally. 

James Michael Wall

unread,
Oct 17, 2025, 8:06:34 PM10/17/25
to weewx-user
I have read these steps over several times already, followed them, and am still getting errors, that's why I'm here asking for help. FWIW, I'm not a NOOB, I did RTFM, I currently have 18 devices (PC's and SBC's), all running either Debian or Raspberry Pi OS, and have been using Linux exclusively since 1993, when I started using it while in college - perhaps I'm getting old, and it's starting to show ;-).

Here are the steps I have taken to attempt to get this working:

I uninstalled the MQTTSubscribe driver that I had installed earlier by running sudo weectl extension uninstall MQTTSubscribe, to "start fresh".
I then performed each of the steps, starting from the beginning, found at https://github.com/bellrichm/WeeWX-MQTTSubscribe/?tab=readme-ov-file#weewx-mqttsubscribe

Please note that during following these steps, I had to run weectl extension install https://github.com/bellrichm/WeeWX-MQTTSubscribe/archive/refs/tags/v3.zip as sudo, because otherwise it denied me because of permissions, and yes, I have followed all the instructions found here: https://github.com/weewx/weewx/wiki/Understanding-permissions#working-with-permissions-in-a-unix-environment. I also read here: https://groups.google.com/g/weewx-user/c/dPWhlQQgwWk. I'm "fairly sure" that I have the correct permissions to my user account, since I can edit /etc/weewx/weewx.conf without sudo, and can start weewx as my user on this device:

myusername@Zero2W-1:~ $ systemctl restart weewx
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to restart 'weewx.service'.
Authenticating as: ,,, (myusername)
Password:
==== AUTHENTICATION COMPLETE ====

Other than that one thing, everything else seemed to be going good until I got to this point: https://github.com/bellrichm/WeeWX-MQTTSubscribe?tab=readme-ov-file#validate-and-test-the-configuration, and the validation ran fine, but the simulate just kept running, producing no errors, all I get is a blinking cursor for about 20 seconds, then the cursor stops blinking.

At that point, I did a CTRL-C and got this:

python3 $USER_ROOT/MQTTSubscribe.py simulate $RUN_MODE --conf mqttsubscribe.template.conf
^CTraceback (most recent call last):
  File "/etc/weewx//bin/user/MQTTSubscribe.py", line 3397, in <module>
    main()
  File "/etc/weewx//bin/user/MQTTSubscribe.py", line 3390, in main
    simulator.run()
  File "/etc/weewx//bin/user/MQTTSubscribe.py", line 3136, in run
    self.simulate_driver_packet(driver)
  File "/etc/weewx//bin/user/MQTTSubscribe.py", line 3047, in simulate_driver_packet
    for packet in driver.genLoopPackets():
  File "/etc/weewx//bin/user/MQTTSubscribe.py", line 2342, in genLoopPackets
    data = self._handle_empty_queue()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/etc/weewx//bin/user/MQTTSubscribe.py", line 2385, in _handle_empty_queue
    time.sleep(self.wait_before_retry)
KeyboardInterrupt

I have attached the "newly" generated MQTTSubscribeDriver configuration template, that was produced by following the instructions, with the only the user and password info changed, maybe you can see what is going wrong, or what I'm missing here. Also, I am in including the Micro Python code snippet from my Raspberry Pico 2W (The device I am publishing the sensor data via MQTT from, via WiFi) to show my data mapping, which is all being sent to a single topic (weatherpi), on the Raspberry Pi Zero2W-1 device which has the Mosquitto server installed and working, along with the paho-mqtt client, which I installed from the Raspberry Pi OS repo, using sudo apt install python3-paho-mqtt. I'm pretty sure that everything is working up to receiving the information to the Zero2W-1:

sudo tail -f /var/log/mosquitto/mosquitto.log
1760745310: New connection from 192.168.1.106:60569 on port 1883.
1760745310: New client connected from 192.168.1.106:60569 as pico2w (p2, c1, k0, u'myusername').
1760745310: No will message specified.
1760745310: Sending CONNACK to pico2w (0, 0)
1760745326: Received PUBLISH from pico2w (d0, q0, r0, m0, 'weatherpi', ... (132 bytes))
1760745342: Received PUBLISH from pico2w (d0, q0, r0, m0, 'weatherpi', ... (132 bytes))
1760745358: Received PUBLISH from pico2w (d0, q0, r0, m0, 'weatherpi', ... (132 bytes))

Here is the last output from WeeWX with the "newly generated" configuration in place:

systemctl status weewx
× weewx.service - WeeWX
     Loaded: loaded (/lib/systemd/system/weewx.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Fri 2025-10-17 15:34:37 PDT; 22min ago
   Duration: 1.065s
       Docs: https://weewx.com/docs
    Process: 8805 ExecStart=weewxd /etc/weewx/weewx.conf (code=exited, status=4)
   Main PID: 8805 (code=exited, status=4)
        CPU: 1.063s

Oct 17 15:34:37 Zero2W-1 weewxd[8805]: CRITICAL weewx.engine:     ****    File "/etc/weewx/bin/user/MQTTSubscribe.py", line 2011, in __init>
Oct 17 15:34:37 Zero2W-1 weewxd[8805]: CRITICAL weewx.engine:     ****      super().__init__(service_dict, logger)
Oct 17 15:34:37 Zero2W-1 weewxd[8805]: CRITICAL weewx.engine:     ****    File "/etc/weewx/bin/user/MQTTSubscribe.py", line 1751, in __init>
Oct 17 15:34:37 Zero2W-1 weewxd[8805]: CRITICAL weewx.engine:     ****      raise ValueError("[[topics]] is required.")
Oct 17 15:34:37 Zero2W-1 weewxd[8805]: CRITICAL weewx.engine:     ****  ValueError: [[topics]] is required.
Oct 17 15:34:37 Zero2W-1 weewxd[8805]: CRITICAL __main__: Unable to load driver: [[topics]] is required.
Oct 17 15:34:37 Zero2W-1 weewxd[8805]: CRITICAL __main__:     ****  Exiting...
Oct 17 15:34:37 Zero2W-1 systemd[1]: weewx.service: Main process exited, code=exited, status=4/NOPERMISSION
Oct 17 15:34:37 Zero2W-1 systemd[1]: weewx.service: Failed with result 'exit-code'.
Oct 17 15:34:37 Zero2W-1 systemd[1]: weewx.service: Consumed 1.063s CPU time.

At this point, I'm pretty sure (AFAICT) I just need to figure out how to get the data from there into WeeWX, using the MQTTSubscribeDriver. I'm sorry that there is so much info in this post, I'm just trying to convey what is in front of me, and get help to fix the problem. Please forgive my lack of knowledge here, this is my first experience with WeeWX. If you need anything else, please don't hesitate to ask, I am happy to help in any way I can - this is driving me bonkers!
mqttsubscribe.template.conf
MicropythonCodeSnippetMQTT.py

vince

unread,
Oct 17, 2025, 8:26:16 PM10/17/25
to weewx-user
Lets see your current weewx.conf please.  The error code pretty clearly indicates that you have only a partial MQTTSubscribeDriver section in weewx.conf.

I'm wondering if you the two commands in 'Stop Weewx' section and then restarting weewx right under there.   Your weewx.conf file should have a big MQTTSubscribe block containing what was in your generated template right under the [Station] block very near the top of weewx.conf

My working test VM weewx.conf looks like this at top of file.  Your content will vary, but it should look the same structurally if you followed all the steps.

debug = 1
log_success = True
log_failure = True
version = 5.2.0

[Station]
    location = WeeWX station
    latitude = 0.0
    longitude = 0.0
    station_type = MQTTSubscribeDriver
    rain_year_start = 1
    week_start = 6

[MQTTSubscribeDriver]
    stop_on_validation_errors = true
    driver = user.MQTTSubscribe
    host = 192.168.1.69
    port = 1883
    keepalive = 60
    username = None
    password = None
    binding = loop

    [[topics]]
        unit_system = US

        [[[GW1200]]]                     # my topic name
            subscribe = True
            ignore = True                # ignore elements by default

            [[[[message]]]]
                type = keyword
                keyword_delimiter = &    # ecowitt uses an odd delimeter

            [[[[tempinf]]]]              # element within the MQTT topic payload
                name = inTemp            # map field to weewx db element name
                ignore = False           # do not ignore this field

            #--- and so on for other elements I want to use ----


I might add that your template doesn't map your data elements to weewx db elements, so you'll almost certainly need to add those mappings for each item in your MQTT payload, but first lets get the driver working and hearing the subscribed payload before worrying that last thing.

vince

unread,
Oct 17, 2025, 8:33:04 PM10/17/25
to weewx-user
Oops. Typo. Wondering if you ‘skipped doing the two commands in’….

bell...@gmail.com

unread,
Oct 18, 2025, 7:53:28 AM10/18/25
to weewx-user
I ran you snippet through the validation and simulation steps (https://github.com/bellrichm/WeeWX-MQTTSubscribe/blob/master/README.md#validate-and-test-the-configuration). After changing the userid/password, all worked for me.


Make sure debug=1 in the WeeWX configuration file and restart WeeWX. Then attach the log from startup to the error. Make sure that there is no sensitive information in the log.
rich
Reply all
Reply to author
Forward
0 new messages