Belchertown skin works, MQTT not updating real time

326 views
Skip to first unread message

ed100

unread,
Feb 7, 2020, 5:15:46 PM2/7/20
to weewx-user
Belchertown skin is great and serves the data on website 192.168.1.200 just fine.  I just can't get MQTT to update the loops - it connects and waits.
I have read and tried several of the things mentioned on the net but no joy yet.
There are no error msgs that I have found.  What am I missing?

Connected. Waiting for data. Last Updated February 7, 2020, 3:22:00 PM

belchertown: version 1.1b8
restx: MQTT: service version is 0.19
Initializing weewx version 4.0.0b11
Using Python 3.7.3 (default, Apr  3 2019, 05:39:12) #012[GCC 8.2.0]
Platform Linux-4.19.93-v7l+-armv7l-with-debian-10.2
Raspberry rpi4
Weewx is running on 192.168.1.190 (dedicated for weather things)
webserver is running on 192.168.1.200
pi is user on both.

192.168.1.200 is NAS for all my boxes, 5 raspberrys, two ubuntu boxes, two Arduino boxes.
192.168.1.190 is setup and running out in our yard where the windspeed, winddir, rain, temp etc are measured.
Data is stored in an mariadb and served by ngnix running on 192.168.1.200.

from /etc/mosquitto/conf.d/myconfig.conf on 192.168.1.200:

persistence false

# mqtt
listener 1883
protocol mqtt

# websockets
listener 9001
protocol websockets

allow_anonymous true

acl_file /etc/mosquitto/acl

log_type all
===================================================================
from  /etc/mosquitto/acl      on 192.168.1.200:
# Allow anonymous access to the sys
topic read $SYS/#

# Allow anonymous to read weather
topic weather/#

# weewx readwrite to the loop
user pi
topic weather/#

==========================================

from weewx.conf:

    station_type = BCRobotics
    station_url = http://192.168.1.200    

    [[MQTT]]
        server_url =  mqtt://192.168.1.200:1883/
        topic = weather/loop
        unit_system = US
        binding = archive, loop
        aggregation = aggregate

    [[Belchertown]]
        skin = Belchertown
        enable = true 
        HTML_ROOT = /var/www/html/weewx/belchertown
        [[[Extras]]]
           belchertown_root_url = "http://192.168.1.200"
           theme = auto
           theme_toggle_enabled = 1
           site_title = "Banjo's Wx Home"     (Banjo is our dog, a lab -- He checks the weather on his Ipaw.)
           home_page_header = "Banjo's Wx Conditions"
           mqtt_websockets_enabled = 1
           mqtt_websockets_host = "192.168.1.200"
           mqtt_websockets_port = 9001
           mqtt_websockets_topic = "weather/loop"
           mqtt_websockets_ssl = 0
           disconnect_live_website_visitor = 900000
           log_failure = true
           log_success = true


==================================================================
sudo tail -25 /var/log/mosquitto/mosquitto.log    on 192.168.1.200
1581110894: New connection from 192.168.1.190 on port 1883.
1581110894: New client connected from 192.168.1.190 as weewx_c7c0a139 (c1, k60).
1581110894: No will message specified.
1581110894: Sending CONNACK to weewx_c7c0a139 (0, 0)
1581110894: Received PUBLISH from weewx_c7c0a139 (d0, q0, r0, m0, 'weather/loop/loop', ... (824 bytes))
1581110894: Received DISCONNECT from weewx_c7c0a139
1581110894: Client weewx_c7c0a139 disconnected.

=========================================================================
from mosquitto_sub -v -t '#'         (on 192.168.1.200)
weather/loop/loop {"dateTime": "1581110268.0", "usUnits": "1.0", "windSpeed_mph": "23.5736", "windDir": "225.0", "outTemp_F": "48.44069175713479", "rainRate_inch_per_hour": "0.0", "pressure_inHg": "29.537724517082214", "inTemp_F": "48.44069175713479", "inHumidity": "40.10936680311917", "outHumidity": "40.10936680311917", "extraTemp1_F": "29.0", "altimeter_inHg": "30.025126837815904", "appTemp_F": "30.718254859246187", "barometer_inHg": "30.032273523343694", "beaufort_count": "5.0", "cloudbase_foot": "5707.996577917219", "dewpoint_F": "25.30550681429903", "heatindex_F": "48.44069175713479", "humidex_F": "48.4406917571348", "inDewpoint_F": "25.30550681429903", "maxSolarRad_Wpm2": "337.7856265409849", "windchill_F": "40.906702199301414", "hourRain_in": "0.02794", "rain24_in": "0.44704000000000005", "dayRain_in": "0.16763999999999998"}

=====================================================================================
from sudo tail -f /var/log/syslog   (on 192.168.1.190)

Feb  7 15:18:23 raspberrypi weewx[10773] INFO weewx.restx: MQTT: Published record 2020-02-07 15:18:00 CST (1581110280)
Feb  7 15:18:24 raspberrypi weewx[10773] INFO weewx.cheetahgenerator: Generated 10 files for report Belchertown in 0.93 seconds
Feb  7 15:18:24 raspberrypi weewx[10773] INFO weewx.reportengine: Copied 2 files to /var/www/html/weewx/belchertown
Feb  7 15:18:28 raspberrypi weewx[10773] INFO weewx.restx: MQTT: Published record 2020-02-07 15:18:23 CST (1581110303)
Feb  7 15:18:29 raspberrypi weewx[10773] INFO weeutil.rsyncupload: rsync'd 18 files (765,224 bytes) in 0.45 seconds
Feb  7 15:18:34 raspberrypi weewx[10773] INFO weewx.restx: MQTT: Published record 2020-02-07 15:18:28 CST (1581110308)
Feb  7 15:18:39 raspberrypi weewx[10773] INFO weewx.restx: MQTT: Published record 2020-02-07 15:18:33 CST (1581110313)
Feb  7 15:18:44 raspberrypi weewx[10773] INFO weewx.restx: MQTT: Published record 2020-02-07 15:18:39 CST (1581110319)
=======================================================================================================================================
from sudo netstat -tulpn | grep 1883      on 192.168.1.200:
tcp        0      0 0.0.0.0:1883            0.0.0.0:*               LISTEN      567/mosquitto       
tcp6       0      0 :::1883                 :::*                    LISTEN      567/mosquitto

tcp        0      0 0.0.0.0:1883            0.0.0.0:*               LISTEN      589/mosquitto       
tcp6       0      0 :::1883                 :::*                    LISTEN      589/mosquitto

vince

unread,
Feb 7, 2020, 6:20:51 PM2/7/20
to weewx-user
On Friday, February 7, 2020 at 2:15:46 PM UTC-8, ed100 wrote:
Belchertown skin is great and serves the data on website 192.168.1.200 just fine.  I just can't get MQTT to update the loops - it connects and waits.
I have read and tried several of the things mentioned on the net but no joy yet.
There are no error msgs that I have found.  What am I missing?



Suspect your weewx.conf file is wrong, but you didn't provide the Belchertown sections of that for us to look like.

I suspect your MQTT section's server_url is the problem.   Try making that http://x.x.x.x:1883 and see if magic happens.


This is what I use on my pi4 which works fine.   MQTT on localhost (the weewx box) and the Belchertown section pointing to its ip address (since the browser on my laptop connects to 'that' ip)

    [[MQTT]]
        server_url = http://localhost:1883
        topic = weather
        binding = archive, loop
        aggregation = aggregate
        log_success = false

    [[Belchertown]]
        skin = Belchertown
        HTML_ROOT = public_html/belchertown
        enable = true

        [[[Extras]]]

            #--------------- General Options (optional)  ------------------------------

            check_for_updates = 0                   # default = 1
            belchertown_debug = 0                   # default = 0
            show_last_updated_alert = 1             # enable alert below
            last_updated_alert_threshold = 1800     # secs before calling data stale if websockets = disabled

            #--------------- MQTT Websockets (optional) -------------------------------

            mqtt_websockets_enabled = 1                     # default = 0
            mqtt_websockets_host = 192.168.1.177            # default = ""
            mqtt_websockets_port = 9001                     # default = 8080
            mqtt_websockets_topic = weather/loop            # default = ""

            #--------------- Forecast Options (optional) ------------------------------

            forecast_enabled = 1                                   # default = 0
            darksky_secret_key = my_darksky_key_omitted_here
            forecast_alert_enabled = 1                             # default = 0

            #--------------- Earthquake Options (optional) ----------------------------

            earthquake_enabled = 1    # default = 0




ed100

unread,
Feb 7, 2020, 7:06:09 PM2/7/20
to weewx-user
Thanks for quick reply, it looks like your setup is what I am trying, I just don't have forecasts yet. Is the info below what you wanted or  did you want to look at something else or additional?
Tried:  server_url = http://localhost:1883 and   server_url =  http://192.168.1.200:1883. Both connected but got same result. Waiting for data.   


    [[Belchertown]]
        skin = Belchertown
        enable = true 
        HTML_ROOT = /var/www/html/weewx/belchertown
        [[[Extras]]]
           belchertown_root_url = "http://192.168.1.200"
           theme = auto
           theme_toggle_enabled = 1
           site_title = "Banjo's Wx Home"     (Banjo is our dog, a lab -- He checks the weather on his Ipaw.)
           home_page_header = "Banjo's Wx Conditions"
           mqtt_websockets_enabled = 1
           mqtt_websockets_host = "192.168.1.200"
           mqtt_websockets_port = 9001
           mqtt_websockets_topic = "weather/loop"
           mqtt_websockets_ssl = 0
           disconnect_live_website_visitor = 900000
           log_failure = true
           log_success = true


vince

unread,
Feb 7, 2020, 7:32:11 PM2/7/20
to weewx-user
On Friday, February 7, 2020 at 4:06:09 PM UTC-8, ed100 wrote:
Thanks for quick reply, it looks like your setup is what I am trying, I just don't have forecasts yet. Is the info below what you wanted or  did you want to look at something else or additional?
Tried:  server_url = http://localhost:1883 and   server_url =  http://192.168.1.200:1883. Both connected but got same result. Waiting for data.   


Think we're going to need to wait for others on this one.

I tried my Vagrant VM with latest weewx b11 and latest belchertown under python3 (over stretch64 debian) and it just works with the websockets pointing to either the vagrant vm itself, or alternately at the ip address of a pi4 that I have that is working separately with a slightly older beta of weewx.  Has to be something in your config.

Do you have a firewall blocking 1883 or 9001 perhaps ?
 

vince

unread,
Feb 7, 2020, 7:33:37 PM2/7/20
to weewx-user
one other thought - does you Mosquitto server enable websockets ?

My conf.d files are:

root@stretch64pkg:/etc/mosquitto/conf.d# cat 1883.conf
# local listener on the LAN is wide open
allow_anonymous true
listener 1883
protocol mqtt

root@stretch64pkg:/etc/mosquitto/conf.d# cat 9001.conf
# local listener on the LAN is wide open
allow_anonymous true
listener 9001
protocol websockets

ed100

unread,
Feb 7, 2020, 7:47:16 PM2/7/20
to weewx-user
I think that the netstat command shows the prots are open and I don't have any firewalls. 
I have the protocals in  /etc/mosquitto/conf.d/myconfig.conf on 192.168.1.200


On Friday, February 7, 2020 at 4:15:46 PM UTC-6, ed100 wrote:

Brice Ruth

unread,
Feb 7, 2020, 9:03:03 PM2/7/20
to weewx...@googlegroups.com
It’s your topic. You put in weather/loop, and you want just weather. The MQTT plugin adds /loop. You need that in the belchertown config for the websocket, but not the MQTT config.

You can see evidence in your MQTT log, it receives messages to weather/loop/loop.

Cheers.

--
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 on the web visit https://groups.google.com/d/msgid/weewx-user/3109ae06-895c-4432-b41e-3aaa4188b404%40googlegroups.com.
--
Brice Ruth, FCD
Software Engineer, Madison WI

vince

unread,
Feb 7, 2020, 9:47:46 PM2/7/20
to weewx-user
On Friday, February 7, 2020 at 6:03:03 PM UTC-8, Brice Ruth wrote:
It’s your topic. You put in weather/loop, and you want just weather. The MQTT plugin adds /loop. You need that in the belchertown config for the websocket, but not the MQTT config.

You can see evidence in your MQTT log, it receives messages to weather/loop/loop.



Good eyes !!!!!!!

 

ed100

unread,
Feb 8, 2020, 8:51:42 AM2/8/20
to weewx-user
Updating fine now, temp looks fine, wind can't tell, it is dead calm. Thanks to Brice for the needed change. Following are my working settings:

    [[MQTT]]
        server_url =  http://192.168.1.200:1883
        topic = "weather"
        unit_system = US
        binding = archive, loop
        aggregation = aggregate
 
    [[Belchertown]]
        skin = Belchertown
        enable = true 
        HTML_ROOT = /var/www/html/weewx/belchertown
        [[[Extras]]]
           belchertown_root_url = "http://192.168.1.200"
           theme = auto
           theme_toggle_enabled = 1
           site_title = "Banjo's Wx Home"
           home_page_header = "Banjo's Wx Conditions"
           mqtt_websockets_enabled = 1
           mqtt_websockets_host = 192.168.1.200
           mqtt_websockets_port = 9001
           mqtt_websockets_topic = "weather/loop"
           mqtt_websockets_ssl = 0
           disconnect_live_website_visitor = 900000
           

On Friday, February 7, 2020 at 4:15:46 PM UTC-6, ed100 wrote:

ed100

unread,
Feb 8, 2020, 9:49:28 AM2/8/20
to weewx-user
Data updating, but slight problem, the graphic showing winddir and windspeed is not right.  The pointer showing winddir is right but the text shows,for example, 117&#176. the winddir is 117 degrees, but not showing windspeed as 3 which is what shows just to the right.  I have no idea how that text is generated. Is it explained on some website or what should I do to fix it.  When I first refresh the page, it is correct but then MQTT updates and it go wrong.
Thanks for everyones help, getting close to all ok.


On Friday, February 7, 2020 at 4:15:46 PM UTC-6, ed100 wrote:

Pat

unread,
Feb 8, 2020, 1:06:19 PM2/8/20
to weewx-user
Which version of the skin are you using? If you upgrade to the 1.1 development version, that weird text is fixed. 

ed100

unread,
Feb 8, 2020, 1:57:35 PM2/8/20
to weewx-user
Not sure what version I was using but I downloaded the latest development on Feb 5. I just downloaded the 1.1 dev, installed and that fixed the problem.

Now going to try to get a windrose chart if I can figure out where to put what.

Thanks so much for you help.  This group is sure nice and helpful.


On Friday, February 7, 2020 at 4:15:46 PM UTC-6, ed100 wrote:

Fabio

unread,
Feb 17, 2020, 10:21:21 AM2/17/20
to weewx-user
Hello, I installed Belchertown skin with mqtt update and all work fine!
I just find a error when updating data in real time for wind speed and direction that are  different in the chart graphic showing wind direction and windspeed.
I'm afraid that the data that arrives with mqtt in real time are greater than historical wind and direction graph
Can you help me to resolve this fix? 
Thanks in advance

ed100

unread,
Feb 17, 2020, 11:06:50 AM2/17/20
to weewx-user
fabio:

The way I understand, MQTT updates the homepage when there is a loop.  The charts below  are updated when the archive is run.  If you mouse over the wind you can see the difference in time between the chart and the time at the top of the page.  Don't know if this helps at all, I am just learning this stuff.

You can also look at the values is in the database to see if they are right.  If you start weewx by hand without a daemon you can watch the loop values scroll by. they start with loop, the lines that start rec are the archive ones.


On Friday, February 7, 2020 at 4:15:46 PM UTC-6, ed100 wrote:

Fabio

unread,
Feb 17, 2020, 12:01:58 PM2/17/20
to weewx-user
thank you for your reply, I started weewx by hand and the values of data are different between database and the data showing on browser.  
for example these are the data that come to me from the log and the data that 's correctly written to the database archive:

LOOP:....windDir: 225.0, windGust: 4.91745222225, windGustDir: 225.0, windrun: 0.160934800001, windSpeed: 2.68224666668, windSpeed10: 2.68224666668, yearET: 0.0, yearRain: 396.600000099

while I received via browser for example for windspeed: 6.2 knots 
almost double for the real value.

my configuration for mqtt is this one: 
   [[MQTT]]
        server_url = mqtt://admin:admin23@localhost:1883/
topic = "weather"
        unit_system = METRIC
binding = archive, loop
        aggregation = aggregate


        [[[Extras]]]
            .....
    mqtt_websockets_enabled = 1
    mqtt_websockets_port = 9001
    mqtt_websockets_topic = "weather/loop"

I can't understand where is the issue.
thanks in advance for your support

Andrew Milner

unread,
Feb 17, 2020, 12:19:50 PM2/17/20
to weewx-user
the LOOP data is not written to the weewx database, and the REC data is the AVERAGE of the LOOP data during the archive period - so you are most unlikely to have corresponding values for LOOP and REC wind data

ed100

unread,
Feb 17, 2020, 3:54:30 PM2/17/20
to weewx-user
Andrew:  Isn't the data in the REC what is written to the archive table?

I have MQTT updating my homepage every 10 sec. archive table gets new data every 5 minutes.



On Friday, February 7, 2020 at 4:15:46 PM UTC-6, ed100 wrote:

Andrew Milner

unread,
Feb 17, 2020, 11:20:18 PM2/17/20
to weewx-user
yes, you are correct - the REC is written to the archive table, but the data in the REC is the average of the LOOP data over the archive period.(if software generation is used).

Fabio

unread,
Feb 19, 2020, 4:47:45 AM2/19/20
to weewx-user
I fixed my issue modifying the unit_system in METRICWX

ed100

unread,
Feb 19, 2020, 7:57:54 AM2/19/20
to weewx-user
Fabio:

You can change the update freq to 10 sec by:
    loop_interval = 10 in your weewx.conf in your driver section. look at [Simulator] section to see example


On Friday, February 7, 2020 at 4:15:46 PM UTC-6, ed100 wrote:
Reply all
Reply to author
Forward
0 new messages