Help with MQTT

79 views
Skip to first unread message

O S

unread,
Feb 6, 2026, 12:05:43 PM (3 days ago) Feb 6
to weewx-user
Hello all,

I have resisted installing and configuring MQTT for live data in case I totally mess things up, but, in a fit of positivity, I decided to have a go today, and it doesn't work.

I've used a mix of search engine (AI) advice, this post and the instructions on the Belchertown skin page.

I have documented what I did, and my settings, can someone take a look and see if anything is glaringly wrong?

For information, I am running this locally at http://192.168... and publicly through https://mydomain.co/weewx/belchertown using a cloudflared tunnel.

Live updates don't appear to be happening in either scenario though (local or via https), ultimately, I'd like them working ion the public site (if it needs to be one or the other).

Thank you,
Nick.

michael.k...@gmx.at

unread,
Feb 6, 2026, 12:46:05 PM (3 days ago) Feb 6
to weewx-user
The live updates are receive by a MQTT client in the browser. You need to set up WeeWX to publish your live data to a MQTT broker, which you can connect to from:

a) WeeWX for publishing
b) The client running in the Browser for subscribing

You also need to be aware that modern browsers block connectung to insecure MQTT from secure (https) sites.

A quick glance on your documentation let's me guess you're not too far away from getting live updates when you browse your site from the same network your WeeWX machine and your MQTT broker is running.

It should be possible to browse the page from your 192.168.1.x client at htttp://192.168.1.{weewx-machine}/weewx/belchertown with live updates.

What's not going to work is https://mydomain.co/weewx/belchertown with live updates.

Check:
- WeeWX logs for MQTT related messages
- mosquitto logs if WeeWX is connecting to the broker
- mosquitto logs if the mqtt client in the browser is connecting to the broker (will only work locally)
- the browser's console for error/info messages.

Getting everything to work with https://mydomain.co/weewx/belchertown is another topic, you might want to get yourself an account for a public broker or setup the cloudflare tunnel for MQTT (I tried once but failed, so tell me what you did if you'll succeed).

O S

unread,
Feb 6, 2026, 2:12:09 PM (3 days ago) Feb 6
to weewx-user
Hello Michael,

Many thanks - all a bit above my pay grade, I am afraid so excuse any silly questions.

When you say there is a client running in the browser, is this something I need to install (I haven't), or would it be there already, I am assuming the latter. Regarding your comment about the no-go with the WAN site, is this fixable with a public broker or just not at all?

I've run some tests and updated that document here.

Thanks again,
Nick.

Vince Skahan

unread,
Feb 6, 2026, 2:15:41 PM (3 days ago) Feb 6
to weewx-user
If there's a comprehensive HOWTO for how to 'securely' set up a cloudflare tunnel back to a LAN-hosted weewx+belchertown that would permit realtime updates to work from both LAN and WAN, I sure have never seen one.  That would be a great thing to get written, validated, and into the wiki.  This has been coming up for 5+ years.

FWIW - I don't let 'anything' talk to my LAN, even through a tunnel.  I don't want that risk.  Too many bots.

Anyway -  the websockets connection is between your browser and the remote MQTT broker, so whatever ip address you use has to be reachable from the web browser computer.  If you use a FQDN rather than an ip address, that has to be resolvable 'and' reachable from the web browser computer.

LAN-only is not hard.  Lots of people have done so.  Many posts here and in Pat's Belchertown github page.

WAN-only is not much harder.  Set up a small VM on AWS Lightsail or the like. Set up the webserver https-only and install the MQTT broker there.  Have your LAN weewx rsync data to it and also publish MQTT to the MQTT broker.  Use 'its' FQDN in all your settings for Belchertown.  Basically connect to your Internet site for realtime updates from both LAN and WAN.

Of course that means $$$ for the VM and the time/effort to keeping 'that' up securely as it will be under bot attack instantly after it boots up.  The AWS consoles are pretty good about letting you lock that down so only https and the secure websockets ports are open.  That'll reduce your attack services.  Damn bots.  Ugh.  A minimal nginx + mosquitto VM takes almost zero maintenance if that's all it does and if you lock it down correctly.  I think I ssh into my nginx-only site about monthly to see if the auto-updates for the os require a reboot, but it's not zero sustaining labor.

michael.k...@gmx.at

unread,
Feb 6, 2026, 2:30:24 PM (3 days ago) Feb 6
to weewx-user
The client in the browser usually is a piece of Javascript code that is provided by the skin. 

O S

unread,
Feb 6, 2026, 2:34:33 PM (3 days ago) Feb 6
to weewx-user
Hello Vince, OK - thanks for your comments there and I do get most of it!

Well. let's help some clever soul produces a how-to for WAN.

The MQTT service appears to have broken weewx, I see:

Feb 06 19:25:04 weewx-pi systemd[1]: weewx.service: Main process exited, code=exited, status=1/FAILURE
Feb 06 19:25:04 weewx-pi systemd[1]: weewx.service: Failed with result 'exit-code'.

.... in the service status, so i have stopped it for now with:

sudo service mosquitto stop
sudo systemctl stop mosquitto.service

Thanks,
Nick.

O S

unread,
Feb 6, 2026, 2:38:07 PM (3 days ago) Feb 6
to weewx-user
OK, it's broken it - how do I get rid of the MQTT thing now? I knew I shouldn't have messed with things!

O S

unread,
Feb 6, 2026, 2:40:40 PM (3 days ago) Feb 6
to weewx-user
If I run a report, I get:

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/report_cmd.py", line 93, in run_reports
    weectllib.report_actions.run_reports(config_dict,
  File "/usr/share/weewx/weectllib/report_actions.py", line 84, in run_reports
    engine = weewx.engine.DummyEngine(config_dict)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/weewx/weewx/engine.py", line 89, in __init__
    self.loadServices(config_dict)
  File "/usr/share/weewx/weewx/engine.py", line 157, in loadServices
    obj = weeutil.weeutil.get_object(svc)(self, config_dict)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/weewx/weeutil/weeutil.py", line 1404, in get_object
    module = importlib.import_module(module_name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/etc/weewx/bin/user/mqtt.py", line 109, in <module>
    import paho.mqtt.client as mqtt
ModuleNotFoundError: No module named 'paho'

O S

unread,
Feb 6, 2026, 3:00:02 PM (3 days ago) Feb 6
to weewx-user
OK, I think I have uninstalled everything but still getting that same error - HELP!

Michael Serowik

unread,
Feb 6, 2026, 3:04:29 PM (3 days ago) Feb 6
to weewx...@googlegroups.com
i used this guide to get mine up and running  


--
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/42a6d1af-2fa7-4471-9271-604b0bea7c8fn%40googlegroups.com.

O S

unread,
Feb 6, 2026, 3:08:06 PM (3 days ago) Feb 6
to weewx-user
Thanks, Michael - that's interesting but no time to do that now, so just need to fix this error to get things working again.

Thanks for pointing that out though, I'm sure others will be interested in that.

All the best,
Nick.

O S

unread,
Feb 6, 2026, 3:20:05 PM (3 days ago) Feb 6
to weewx-user
OK, I have fixed it with:

sudo apt install python3-paho-mqtt

I have no idea how that fixed it though... I'm leaving things alone now.

Vince Skahan

unread,
Feb 8, 2026, 3:05:43 PM (21 hours ago) Feb 8
to weewx-user
Did you succeed for both goals ?   Live data working on your LAN ?   Live data accessible from Internet ?

If so, how did you get the latter working specifically so others can try it ?   Looking for more than "I installed this".  Looking for actual instructions others might be able to follow and also succeed....

(answering 'fixed' or 'got it but I have not idea how' does not help the next person trying to do the same thing....)

gary....@gmail.com

unread,
10:24 AM (1 hour ago) 10:24 AM
to weewx-user
I do not access my website locally via IP address (LAN) and also from the Internet differently.
Why? As mentioned earlier, cert mismatch and the secure/insecure mix rejection.
Quick and easy for 'live' pages using MQTT
Reply all
Reply to author
Forward
0 new messages