Author Topic: How to WeeWX - Belchertown skin with MQTT - Part I  (Read 1379 times)

0 Members and 1 Guest are viewing this topic.

Offline gszlag

  • Forecaster
  • *****
  • Posts: 318
  • ..have you calibrated your barometer today?
    • Michael's Bay - Manitoulin Island weather
How to WeeWX - Belchertown skin with MQTT - Part I
« on: January 27, 2022, 07:41:51 PM »
How to WeeWX - Belchertown skin with MQTT

If you like the look of this weather website https://belchertownweather.com/ then you can install it on your own WeeWx system. This “template” or “skin” as WeeWX calls it, was developed by Pat O’Brian.

Pat’s comprehensive readme is better than most and you should follow it closely.:
https://github.com/poblabs/weewx-belchertown#readme

I’ve installed all kinds of templates and this one is a bit higher on the difficulty scale. However, having gone through the process, I think I can save a weewx/linux user with even a modicum of computing skills (I can relate to that!) some time and avoid some minefields along the way.

Installation:

1. you need a working weewx installation (hopefully you have installed or upgraded to a recent version).

2. download and install the latest version of belchertown skin:
https://github.com/poblabs/weewx-belchertown/releases/tag/weewx-belchertown-1.2

3. download and install Matthew Wall’s weewx mqtt extension:
https://github.com/weewx/weewx/wiki/mqtt

..if you are running WeeWX version 4.x or higher on a recent linux distribution, you should be running under python3 rather than python2 (now discontinued/deprecated).

4. Install MQTT. Although you can use a public MQTT broker or a local install  - the developer of the Belchertown skin seemed to prefer a local install of MQTT(mosquitto).  You can install it from your linux distribution package manager or from the command line. Depending on your linux distribution, MQTT might be available as a snap package. For testing purposes, you will need the mosquitto client too.

TIP:  If you want to make the skin available on the internet, things get more complicated.  You will want to use a public MQTT broker if your web host allows it. Ask the web host if you can run MQTT on their system. In my case - it was not allowed. You can either move to another web host or buy an additional  plan from a more MQTT-friendly web host. There is a workaround if you want to stick with your web host - you can make your local MQTT broker update your web site by using rsync.

5. Configure MQTT and the Belchertown skin by editing weewx.conf:. Here is a working configuration example:

    [[MQTT]]
        server_url = mqtt://user:password@localhost:1883
        unit_system = METRIC
        topic = weather
        binding = archive, loop
        aggregation = aggregate

Notes: If you are following Pat O'Brien's instructions to set up MQTT, you will need to enter a user name and password in the server_url line above.
(you can make up any user name that you want).

[[Belchertown]]
        skin = Belchertown
        HTML_ROOT = /var/www/html/weewx/belchertown
             [[[Extras]]]
            site_title = "insert  your website title here"
            forecast_enabled = 1
            forecast_units = ca
            forecast_provider = aeris
            forecast_api_id = xxxxxxx
            forecast_api_secret = xxxxxx
            earthquake_enabled = 1
            earthquake_server = USGS
            mqtt_websockets_enabled = 1
            mqtt_websockets_host = 192.168.1.x
            mqtt_websockets_port = 9001
            mqtt_websockets_topic = weather/loop
            mqtt_websockets_ssl = 0

Notes:

 - if you want weather forecasts, you will need to follow Pat’s instruction to setup an account at aeris and obtain the api_id and api_secret codes to get Aeris weather forecasts.
- the mqtt_websockets_host is the IP address of the machine where you installed MQTT.
- although some users set the HTML-ROOT directory as /var/www/html/weewx. I recommend it to be in a separate directory: /var/www/html/weewx/belchertown. It will make things a bit cleaner if you will be rsyncing to your web host.

TIP: Do not modify the skin.conf file in the /etc/weewx/skins/belchertown directory. If you do, you will lose all of your modifications when you upgrade the skin. Any skin modifications should be made in the weewx.conf file as in the [[[Extras]]] example above. Don’t copy everything from the belchertown skin.conf to weewx.conf  - just copy only the lines that you want to modify. The lines in weewx.conf will always take precedence over the skin.conf lines.

6. Unlike the default WeeWX Seasons skin, clicking on a index.html in a browser is not going to get you very far. Try clicking on “graphs” and you will be looking at a page with file names on it. You need to install a web server software package. I chose nginx because it is lightweight which is important if you are running WeeWX on a smaller computer like a raspberry pi. You can install it using your linux distribution’s package manager or on the command line.

7. Now let’s fire this skin up!. Give it a try by entering localhost/weewx/belchertown/index.html in your browser. In my case “localhost” did not work for me and you might have to specify the IP address of your machine, ie: 192.168.1.20/weewx/belchertown/index.html.

8. Hopefully it is working. Within 30 seconds or so you should see a “Connected to weather station live” message next to that neat sonar “ping”.

Congratulations! You have successfully installed the Belchertown skin and MQTT is working.

9. You can add extra graphs too:
https://github.com/poblabs/weewx-belchertown/wiki/Belchertown-Charts-Documentation#belchertown-charts

10. Fine tuning. Although I set the Belchertown skin to use metric , readings for wind speed did not look right. Either the units did not show km/hour or the numbers were off – I can’t recall. Since I was originally using meters/sec I had to change it to km/hr in the [[[[Groups]]]] section in weewx.conf.

11. Ready to tackle getting this skin onto the web?

Continued in Part II:
https://www.wxforum.net/index.php?topic=43427.0
« Last Edit: February 14, 2022, 12:55:25 PM by gszlag »
Ambient Weather WS-2000
Ecowitt GW1000/GW1100
Ecowitt WS68: Anemometer, UV/solar
Ecowitt WH40: Rain gauge
Ecowitt WH57 Lightning sensor
Ecowitt WH32E: Outside T & H sensor
Stratus Rain Gauge (manual)
Raspberry Pi 3B+ (WeeWX/CumulusMX)
Raspberry Pi Zero 2W (WeeWX/MQTT/Belchertown)
---
http://weather.glenns.ca (pwsdashboard - live)
http://weewx.glenns.ca
http://glenns.ca/cumulusmx2/index.htm
---
Uploading to: AWN, ecowitt.net, Weather Underground, PWSweather.com, AWEKAS, Windy.com, WOW

 

anything