You're probably overthinking. It's really very simple.   You don't need SSL 
if you're just going to run on your LAN.  You likely don't even need to 
password protect it either if you are LAN only.

See the example starting at line 72 of 
https://github.com/vinceskahan/weewx-odds-and-ends/blob/master/install-belchertown-websockets
 
for the minimal mosquitto MQTT server setup that works for me.

On Friday, August 2, 2024 at 10:56:59 AM UTC-7 M&M wrote:

> I've read a bunch about MQTT, Belchertown, and Weewx so I thought I would 
> able to get this working.  From the pages I read on github and such, it 
> didn't seem like it took a lot of configuration to mosquitto to get it 
> working.  From the links I posted above that I followed, it didn't seem 
> that I needed to have SSL certs working yet to get it working locally.  I 
> figured I would do that first before venturing out to get this working on a 
> website.  So I'll go back and see what I can configure to get the certs 
> added to my conf files.
>
> Do you have any websites that you suggest to use to get this working?  I 
> feel like I'm close.
>
> On Friday, August 2, 2024 at 8:41:28 AM UTC-4 gary....@gmail.com wrote:
>
>> I see you haven't done much research.
>> If you want to understand this and get the Belchertown skin to work, you 
>> need to do some.
>> A default mosquitto.conf isn't going to work as you want.
>> You will likely need SSL certs in order to have websockets work via the 
>> internet vs local LAN.
>> You should have writing to mosquitto password protected, but 
>> allow anonymous reading.
>>
>> When MQTT/Websockets works, it is great. Getting there requires a passing 
>> familiarity with the care and feeding of mosquitto.
>>
>> On Thursday, August 1, 2024 at 11:38:28 PM UTC-4 M&M wrote:
>>
>>> Where can I find out if I have acl?
>>>
>>> My mosquitto.conf file looks a bit different.  I didn't change any of it 
>>> after it was installed besides the two listener lines.  It looks like this:
>>>
>>> pi@raspberrypi:~ $ more /etc/mosquitto/mosquitto.conf
>>> # Place your local configuration in /etc/mosquitto/conf.d/
>>> #
>>> # A full description of the configuration file is at
>>> # /usr/share/doc/mosquitto/examples/mosquitto.conf.example
>>>
>>> pid_file /run/mosquitto/mosquitto.pid
>>>
>>> persistence true
>>> persistence_location /var/lib/mosquitto/
>>>
>>> log_dest file /var/log/mosquitto/mosquitto.log
>>>
>>> include_dir /etc/mosquitto/conf.d
>>>
>>> listener 1883
>>> listener 9001
>>> protocol websockets
>>>
>>> On Thursday, August 1, 2024 at 9:38:48 AM UTC-4 gary....@gmail.com 
>>> wrote:
>>>
>>>> Do you have an acl and does it resemble this?
>>>> # Allow anonymous access to the sys
>>>> topic read $SYS/#
>>>>  
>>>> # Allow anonymous to read weather
>>>> topic read weather/#
>>>> topic read tester/#
>>>>  
>>>> # weewx readwrite to the loop
>>>> user weewx
>>>> topic weather/#
>>>> topic tester/#
>>>>
>>>> Did you create a password for the weewx user (not the linux user, the 
>>>> mqtt user)?
>>>>
>>>> Does your mosquitto conf file resemble this?
>>>> persistence false
>>>> allow_anonymous true
>>>> password_file /etc/mosquitto/pwfile
>>>> acl_file /etc/mosquitto/acl
>>>> # Insecure mqtt to localhost only, and secure mqtt
>>>> listener 1883
>>>> listener 8883
>>>> certfile /etc/mosquitto/certs/cert.pem
>>>> cafile /etc/mosquitto/certs/chain.pem
>>>> keyfile /etc/mosquitto/certs/privkey.pem
>>>> protocol mqtt
>>>>  
>>>> # websockets
>>>> listener 8080
>>>> certfile /etc/mosquitto/certs/cert.pem
>>>> cafile /etc/mosquitto/certs/chain.pem
>>>> keyfile /etc/mosquitto/certs/privkey.pem
>>>> protocol websockets
>>>> On Wednesday, July 31, 2024 at 11:47:46 PM UTC-4 M&M wrote:
>>>>
>>>>> I checked mosquitto.conf and it has "listener 1883" in it.  I also 
>>>>> disabled my pihole and checked that my raspberry pi is listening on port 
>>>>> 1883.  
>>>>>
>>>>> On Friday, July 26, 2024 at 11:23:25 PM UTC-4 M&M wrote:
>>>>>
>>>>>> I checked journalctl and now I'm seeing this error:
>>>>>>
>>>>>> Jul 26 23:16:30 raspberrypi weewxd[1141]: ERROR 
>>>>>> user.ambientweatherapi: AmbientAPI get_devices() returned empty dict
>>>>>> Jul 26 23:16:30 raspberrypi weewxd.py[1141]: ambientweatherapi driver 
>>>>>> encountered an error.
>>>>>> Jul 26 23:16:30 raspberrypi weewxd[1141]: ERROR 
>>>>>> user.ambientweatherapi: ambientweatherapi driver encountered an error.
>>>>>> Jul 26 23:16:30 raspberrypi weewxd.py[1141]: Error caught was: 
>>>>>> AmbientAPI get_devices() returned empty dict
>>>>>> Jul 26 23:16:30 raspberrypi weewxd[1141]: ERROR 
>>>>>> user.ambientweatherapi: Error caught was: AmbientAPI get_devices() 
>>>>>> returned 
>>>>>> empty dict
>>>>>> Jul 26 23:16:30 raspberrypi weewxd.py[1141]: ambientweatherapi driver 
>>>>>> had an error sending data to weewx.
>>>>>> Jul 26 23:16:30 raspberrypi weewxd[1141]: ERROR 
>>>>>> user.ambientweatherapi: ambientweatherapi driver had an error sending 
>>>>>> data 
>>>>>> to weewx.
>>>>>> Jul 26 23:16:30 raspberrypi weewxd.py[1141]: Error caught was: 
>>>>>> Previous error occured, skipping packet build.
>>>>>> Jul 26 23:16:30 raspberrypi weewxd[1141]: ERROR 
>>>>>> user.ambientweatherapi: Error caught was: Previous error occured, 
>>>>>> skipping 
>>>>>> packet build.
>>>>>>
>>>>>> On Friday, July 26, 2024 at 11:20:51 PM UTC-4 M&M wrote:
>>>>>>
>>>>>>> Making some progress.  I am back to having weewx running and I now 
>>>>>>> have mosquito running as well.  I was able to test that service by 
>>>>>>> mosquitto_sub and mosquitto_pub which worked by sending "hello world".  
>>>>>>> However when I check my local Belchertown page, it now says this at the 
>>>>>>> top:
>>>>>>>
>>>>>>> Failed connecting to the weather station. Please try again later! 
>>>>>>> Last Updated 26 July 2024, 23:10:00
>>>>>>>
>>>>>>> On Friday, July 26, 2024 at 2:02:17 PM UTC-4 M&M wrote:
>>>>>>>
>>>>>>>> Oh thats right!  I edited the /etc/default/locales file.  I changed 
>>>>>>>> it from en_GB.UTF-8 to en_US.UTF-8 since I was trying to fix the time 
>>>>>>>> in 
>>>>>>>> Belchertown skin to show a 12h time format.  I believe I fixed it and 
>>>>>>>> for 
>>>>>>>> some reason, i decided to edit the locales file.  I'll change that 
>>>>>>>> back 
>>>>>>>> when I get to that system.
>>>>>>>>
>>>>>>>> Thanks.  I believe that is what will fix it.
>>>>>>>>
>>>>>>>> On Friday, July 26, 2024 at 12:17:42 PM UTC-4 vince wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>> https://stackoverflow.com/questions/14547631/python-locale-error-unsupported-locale-settling
>>>>>>>>>
>>>>>>>>> Have you messed with system locale at the os level or edited it in 
>>>>>>>>> some weewx or mqtt config file ? There have been some skeletal 
>>>>>>>>> reports 
>>>>>>>>> about this over the years but I've never really understood the 
>>>>>>>>> explanations.
>>>>>>>>>
>>>>>>>>> On Friday, July 26, 2024 at 3:41:42 AM UTC-7 Mark Jenks wrote:
>>>>>>>>>
>>>>>>>>>> Make sure MQTT is running correctly. You can test it via CLI.    
>>>>>>>>>>  This page goes into configuring a cert, you can stop reading at 
>>>>>>>>>> that point.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> https://medium.com/gravio-edge-iot-platform/how-to-set-up-a-mosquitto-mqtt-broker-securely-using-client-certificates-82b2aaaef9c8
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Thursday, July 25, 2024 at 10:27:54 PM UTC-5 M&M wrote:
>>>>>>>>>>
>>>>>>>>>>> Also I tried commenting out all of the MQTT lines in weewx.conf 
>>>>>>>>>>> so that I could get the service running again but it isn't running 
>>>>>>>>>>> at all.  
>>>>>>>>>>> Giving me the same error as I posted above.
>>>>>>>>>>>
>>>>>>>>>>> On Thursday, July 25, 2024 at 11:11:15 PM UTC-4 M&M wrote:
>>>>>>>>>>>
>>>>>>>>>>>> I'm getting closer.  Mosquito service is running but weewx 
>>>>>>>>>>>> gives me the follow error in journalctl:
>>>>>>>>>>>>
>>>>>>>>>>>> Jul 25 22:59:55 raspberrypi weewxd[25852]: INFO __main__: 
>>>>>>>>>>>> Terminating weewx version 5.0.2
>>>>>>>>>>>> Jul 25 22:59:55 raspberrypi systemd[1]: weewx.service: 
>>>>>>>>>>>> Succeeded.
>>>>>>>>>>>> Jul 25 22:59:55 raspberrypi systemd[1]: Stopped WeeWX.
>>>>>>>>>>>> Jul 25 22:59:55 raspberrypi systemd[1]: weewx.service: Consumed 
>>>>>>>>>>>> 3h 44min 13.462s CPU time.
>>>>>>>>>>>> Jul 25 23:00:51 raspberrypi systemd[1]: Started WeeWX.
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]: INFO __main__: 
>>>>>>>>>>>> Initializing weewxd version 5.0.2
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]: INFO __main__: 
>>>>>>>>>>>> Command line: /usr/share/weewx/weewxd.py /etc/weewx/weewx.conf
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]: Traceback (most 
>>>>>>>>>>>> recent call last):
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]:   File 
>>>>>>>>>>>> "/usr/share/weewx/weewxd.py", line 265, in <module>
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]:     main()
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]:   File 
>>>>>>>>>>>> "/usr/share/weewx/weewxd.py", line 107, in main
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]:     weewx_root, 
>>>>>>>>>>>> user_module = weeutil.startup.initialize(config_dict)
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]:   File 
>>>>>>>>>>>> "/usr/share/weewx/weeutil/startup.py", line 67, in initialize
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]:     
>>>>>>>>>>>> importlib.import_module('user.extensions')
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]:   File 
>>>>>>>>>>>> "/usr/lib/python3.9/importlib/__init__.py", line 127, in 
>>>>>>>>>>>> import_module
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]:     return 
>>>>>>>>>>>> _bootstrap._gcd_import(name[level:], package, level)
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]:   File "<frozen 
>>>>>>>>>>>> importlib._bootstrap>", line 1030, in _gcd_import
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]:   File "<frozen 
>>>>>>>>>>>> importlib._bootstrap>", line 1007, in _find_and_load
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]:   File "<frozen 
>>>>>>>>>>>> importlib._bootstrap>", line 986, in _find_and_load_unlocked
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]:   File "<frozen 
>>>>>>>>>>>> importlib._bootstrap>", line 680, in _load_unlocked
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]:   File "<frozen 
>>>>>>>>>>>> importlib._bootstrap_external>", line 790, in exec_module
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]:   File "<frozen 
>>>>>>>>>>>> importlib._bootstrap>", line 228, in _call_with_frames_removed
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]:   File 
>>>>>>>>>>>> "/etc/weewx/bin/user/extensions.py", line 18, in <module>
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]:     
>>>>>>>>>>>> locale.setlocale(locale.LC_ALL, '')
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]:   File 
>>>>>>>>>>>> "/usr/lib/python3.9/locale.py", line 610, in setlocale
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]:     return 
>>>>>>>>>>>> _setlocale(category, locale)
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi weewxd[28347]: locale.Error: 
>>>>>>>>>>>> unsupported locale setting
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi systemd[1]: weewx.service: Main 
>>>>>>>>>>>> process exited, code=exited, status=1/FAILURE
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi systemd[1]: weewx.service: Failed 
>>>>>>>>>>>> with result 'exit-code'.
>>>>>>>>>>>> Jul 25 23:00:53 raspberrypi systemd[1]: weewx.service: Consumed 
>>>>>>>>>>>> 2.050s CPU time.
>>>>>>>>>>>>
>>>>>>>>>>>> On Thursday, July 25, 2024 at 1:47:21 PM UTC-4 vince wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Pat's docs are authoritative for Belchertown and the MQTT 
>>>>>>>>>>>>> stuff looks ok to me.  Just follow that.
>>>>>>>>>>>>>
>>>>>>>>>>>>> https://github.com/weewx/weewx/wiki/mqtt has Tom's 
>>>>>>>>>>>>> instructions for installing the MQTT extension.  You can check it 
>>>>>>>>>>>>> at least 
>>>>>>>>>>>>> minimally by running "weectl extension list" and it should show 
>>>>>>>>>>>>> up in the 
>>>>>>>>>>>>> list of installed extensions.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Your config file stuff for weewx that you posted looked ok to 
>>>>>>>>>>>>> me.
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Thursday, July 25, 2024 at 9:54:13 AM UTC-7 M&M wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> That is correct that I have the MQTT installed as an 
>>>>>>>>>>>>>> extension for weewx which is running on the pi.  I checked for a 
>>>>>>>>>>>>>> mqtt.service and I'm not seeing one on there.  I'm also not 
>>>>>>>>>>>>>> seeing a 
>>>>>>>>>>>>>> mosquitto_sub or pub installed so I think I must have missed 
>>>>>>>>>>>>>> anothe page to 
>>>>>>>>>>>>>> get this installed and working.  From searching around right 
>>>>>>>>>>>>>> now, it looks 
>>>>>>>>>>>>>> like I need to follow this page:  
>>>>>>>>>>>>>> https://obrienlabs.net/how-to-setup-your-own-mqtt-broker/
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I'm hoping to get this on a website that doesn't cost 
>>>>>>>>>>>>>> anything but one step at a time.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Am I on the right track?  
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Wednesday, July 24, 2024 at 10:50:45 PM UTC-4 vince wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Connection refused generally means the remote computer is 
>>>>>>>>>>>>>>> not accepting incoming connections on that port.   It looks to 
>>>>>>>>>>>>>>> me like you 
>>>>>>>>>>>>>>> are trying to connect to the MQTT server on the same pi ?   Did 
>>>>>>>>>>>>>>> you enable 
>>>>>>>>>>>>>>> and start the MQTT server ?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Did you test it with mosquitto_sub and mosquitto_pub to know 
>>>>>>>>>>>>>>> that the MQTT server is working ok ?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> The authoritative belchertown docs are at 
>>>>>>>>>>>>>>> https://github.com/poblabs/weewx-belchertown?tab=readme-ov-file#mqtt-and-mqtt-websockets-optional
>>>>>>>>>>>>>>>  
>>>>>>>>>>>>>>> if you haven't gone through them already.  Note that it has a 
>>>>>>>>>>>>>>> prerequisite 
>>>>>>>>>>>>>>> to install the MQTT extension which itself has prerequisite 
>>>>>>>>>>>>>>> python modules.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Test with mosquitto_sub/pub first to know your MQTT server 
>>>>>>>>>>>>>>> is working as desired, then do the weewx part.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Wednesday, July 24, 2024 at 7:30:33 PM UTC-7 M&M wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Somewhat of a new user here to Weewx.  I am running it on a 
>>>>>>>>>>>>>>>> Raspberry Pi Zero W (192.168.0.196) and also installed the 
>>>>>>>>>>>>>>>> Belchertown 
>>>>>>>>>>>>>>>> skin.  I followed these steps (
>>>>>>>>>>>>>>>> https://www.wxforum.net/index.php?topic=43377.0) to 
>>>>>>>>>>>>>>>> install and configure MQTT but I'm running into some errors.  
>>>>>>>>>>>>>>>> Here is what 
>>>>>>>>>>>>>>>> part of my weewx.conf file looks like for the MQTT stuff:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>     [[MQTT]]
>>>>>>>>>>>>>>>>         server_url = mqtt://
>>>>>>>>>>>>>>>> random_username:random_...@192.168.0.196:1883 
>>>>>>>>>>>>>>>> <http://random_username:random_password@192.168.0.196:1883>
>>>>>>>>>>>>>>>>         unit_system = US
>>>>>>>>>>>>>>>>         topic = weather
>>>>>>>>>>>>>>>>         binding = archive, loop
>>>>>>>>>>>>>>>>         aggregation = aggregate
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>     [[Belchertown]]
>>>>>>>>>>>>>>>>         skin = Belchertown
>>>>>>>>>>>>>>>>         HTML_ROOT = /var/www/html/weewx/belchertown
>>>>>>>>>>>>>>>>         enable = true
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>         [[[Extras]]]
>>>>>>>>>>>>>>>>             #--- MQTT Websockets (for Real Time Streaming) 
>>>>>>>>>>>>>>>> Options ---
>>>>>>>>>>>>>>>>             mqtt_websockets_enabled = 1
>>>>>>>>>>>>>>>>             mqtt_websockets_host = 192.168.0.x
>>>>>>>>>>>>>>>>             mqtt_websockets_port = 9001
>>>>>>>>>>>>>>>>             mqtt_websockets_ssl = 0
>>>>>>>>>>>>>>>>             mqtt_websockets_topic = weather/loop
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I also added user.mqtt.MQTT to restful_services at the end 
>>>>>>>>>>>>>>>> of the file.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> The error I'm seeing in journalctl is:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Jul 24 22:16:40 raspberrypi weewxd[25776]: ERROR user.mqtt: 
>>>>>>>>>>>>>>>> Failed to connect to MQTT server (mqtt://
>>>>>>>>>>>>>>>> random_username:x...@192.168.0.196:1883 
>>>>>>>>>>>>>>>> <http://random_username:xxx@192.168.0.196:1883>): [Errno 
>>>>>>>>>>>>>>>> 111] Connection refused
>>>>>>>>>>>>>>>> Jul 24 22:16:40 raspberrypi weewxd[25776]: ERROR 
>>>>>>>>>>>>>>>> weewx.restx: MQTT: Failed to publish record 2024-07-24 
>>>>>>>>>>>>>>>> 22:15:00 EDT 
>>>>>>>>>>>>>>>> (1721873700): MQTT client not available
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Any ideas what I'm missing?
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/81877241-40e9-426e-ae14-1d2d709008ecn%40googlegroups.com.

Reply via email to