Belchertown MQTT

188 views
Skip to first unread message

Ken Walker

unread,
Jun 14, 2020, 7:43:10 PM6/14/20
to weewx-user
I'm getting my data from an internal MQTT server using the wxMesh driver and all is working well.

I would like to enable the MQTT updates, but cannot get them to work.

I get a failed to connect message.  All items are on my internal network.  

I have no trouble connecting from my weewx box(Raspberry Pi) with the mosquito_sub client.

Am I missing something obvious?


I have the following in my skin.conf:

    mqtt_websockets_enabled = 1

    mqtt_websockets_host = "xx.xx.xx.xxx"

    mqtt_websockets_port = 1883

    mqtt_websockets_ssl = 0

    mqtt_websockets_topic = "weather/davis"

    disconnect_live_website_visitor = 1800000


Garry A Lockyer

unread,
Jun 14, 2020, 7:47:48 PM6/14/20
to weewx...@googlegroups.com
The websockets port probably should be 9001.  1883 is usually the MQTT broker.

Regards,

Garry Lockyer
E: Ga...@Lockyer.ca


On Jun 14, 2020, at 16:43, Ken Walker <kwal...@gmail.com> wrote:


--
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/7237fbdc-2531-477d-bc4d-cc61970f47cfo%40googlegroups.com.

Ken Walker

unread,
Jun 14, 2020, 8:08:02 PM6/14/20
to weewx...@googlegroups.com
I changed it to that.  Still doesn’t work, but the behavior is slightly different.

On the page I now get a “lost connect….” message which flashes on and off for a few seconds.  I know my broker is working on port 9001 as I have tested it from a test python script.

Ken Walker

unread,
Jun 14, 2020, 8:11:00 PM6/14/20
to weewx...@googlegroups.com
Is the implementation expecting one observation at a time returned from the broker.  I am returning from 1 - 5 observations in one json string

On Jun 14, 2020, at 7:47 PM, Garry A Lockyer <garrya...@gmail.com> wrote:

garrya...@gmail.com

unread,
Jun 14, 2020, 8:55:00 PM6/14/20
to weewx...@googlegroups.com

Here’re the settings I’m currently using successfully:

 

[[MQTT]]

        # This is to PUBLISH MQTT topics - username and password are required, on my system.

 

        server_url = mqtt://username:pass...@192.168.1.140:1883/

        topic = weather/OsoyoosLakeNorthEast

        unit_system = METRIC

        binding = archive, loop

        aggregation = aggregate

 

            # This is to SUBSCRIBE to MQTT topics - a username and password are not required – at least not on my system.

 

            mqtt_websockets_enabled = 1

            mqtt_websockets_host = "192.168.1.140”

            mqtt_websockets_topic = "weather/OsoyoosLakeNorthEast/loop"

            mqtt_websockets_port = 9001

            disconnect_live_website_visitor = 1800000

 

The “aggregation” option above controls publishing one variable at a time, or publishing them all in a single connection (an aggregate).

 

Regards,

 

Garry

Ken Walker

unread,
Jun 14, 2020, 10:40:55 PM6/14/20
to weewx...@googlegroups.com
Thanks.  I don’t want to publish since I’m already getting data from MQTT.  My subscribe settings are the same as yours(other than host and topic obviously).  But it does not work.

I’m perplexed :)

Garry A Lockyer

unread,
Jun 14, 2020, 11:39:15 PM6/14/20
to weewx...@googlegroups.com
Seems to me you have to publish MQTT data (under [StdRESTful][[MQTT]] so that you can later retrieve the data in [StdReport][[Belchertown]][[[Extras]]].  I suppose it’s possible to have one instance of weewx publish data and another instance subscribe to it, but there has to be at least one publisher somewhere.

I can’t explain the “lost connection “ message.  If I turn off MQTT publishing, I get a “Failed connecting...” message after a minute or so.

Regards,

Garry Lockyer
E: Ga...@Lockyer.ca


On Jun 14, 2020, at 19:40, Ken Walker <kwal...@gmail.com> wrote:

Thanks.  I don’t want to publish since I’m already getting data from MQTT.  My subscribe settings are the same as yours(other than host and topic obviously).  But it does not work.

Pat

unread,
Jun 15, 2020, 9:47:46 AM6/15/20
to weewx-user
Belchertown expects the weather data to be in the same format as the weewx mqtt extension. If you're not publishing from the weewx mqtt extension, then you'll need to have your publisher emulate that extension's output. (rough example below, not all observations need to be in the same packet)

Your mqtt broker needs to have websockets enabled as well. Then you'll set your skin to connect to the websocket port to get the data. 

MQTT: {"dateTime": "1592228732.0", "usUnits": "1.0", "outTemp_F": "65.9", "rain_in": "0.0", "rainRate_inch_per_hour": "0.0", "barometer_inHg": "30.514", "radiation_Wpm2": "691.0", "inTemp_F": "75.5", "inHumidity": "36.0", "outHumidity": "53.0", "windSpeed_mph": "5.0", "windGust_mph": "5.0", "UV": "4.1", "forecastRule": "9.0", "txBatteryStatus": "0.0", "consBatteryVoltage_volt": "4.71", "windDir": "11.0", "windGustDir": "11.0", "pressure_inHg": "30.05007732814778", "altimeter_inHg": "30.522342546117084", "windchill_F": "65.9", "heatindex_F": "65.9", "dewpoint_F": "48.27895673606349", "inDewpoint_F": "46.66006121573143", "appTemp_F": "62.71298653227457", "maxSolarRad_Wpm2": "725.56944104572", "cloudbase_foot": "4434.782559985571", "humidex_F": "67.42878362134785", "hourRain_in": "0.0", "rain24_in": "0.0", "dayRain_in": "0.0", "windSpeed10_mph": "2.0", "stormRain_in": "0.0", "monthRain_in": "1.07", "yearRain_in": "14.82", "dayET": "0.023", "monthET": "2.04", "yearET": "14.19", "leafWet4": "0.0", "insideAlarm": "0.0", "rainAlarm": "0.0", "outsideAlarm1": "0.0", "outsideAlarm2": "0.0", "extraAlarm1": "0.0", "extraAlarm2": "0.0", "extraAlarm3": "0.0", "extraAlarm4": "0.0", "extraAlarm5": "0.0", "extraAlarm6": "0.0", "extraAlarm7": "0.0", "extraAlarm8": "0.0", "soilLeafAlarm1": "0.0", "soilLeafAlarm2": "0.0", "soilLeafAlarm3": "0.0", "soilLeafAlarm4": "0.0", "forecastIcon": "6.0", "sunrise": "1592212752.0", "sunset": "1592268288.0"}



On Sunday, June 14, 2020 at 11:39:15 PM UTC-4, Garry A Lockyer wrote:
Seems to me you have to publish MQTT data (under [StdRESTful][[MQTT]] so that you can later retrieve the data in [StdReport][[Belchertown]][[[Extras]]].  I suppose it’s possible to have one instance of weewx publish data and another instance subscribe to it, but there has to be at least one publisher somewhere.

I can’t explain the “lost connection “ message.  If I turn off MQTT publishing, I get a “Failed connecting...” message after a minute or so.

Regards,

Garry Lockyer

On Jun 14, 2020, at 19:40, Ken Walker <kwal...@gmail.com> wrote:

Thanks.  I don’t want to publish since I’m already getting data from MQTT.  My subscribe settings are the same as yours(other than host and topic obviously).  But it does not work.

I’m perplexed :)

On Jun 14, 2020, at 8:54 PM, garrya...@gmail.com wrote:

Here’re the settings I’m currently using successfully:
 
[[MQTT]]
        # This is to PUBLISH MQTT topics - username and password are required, on my system.
 
To unsubscribe from this group and stop receiving emails from it, send an email to weewx...@googlegroups.com.
-- 
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...@googlegroups.com.
-- 
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...@googlegroups.com.

-- 
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...@googlegroups.com.

--
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...@googlegroups.com.

Ken Walker

unread,
Jun 15, 2020, 12:39:28 PM6/15/20
to weewx...@googlegroups.com
OK, now I get it.  Thanks Garry and Pat.

Almost there.

I have added the MQTT extension and can verify that data is being published to my mqtt broker by using the command line to subscribe to the topic.

The web page now says “Connected. Waiting for data….” , but does appear to update.  I have the following in the skin.conf:
# MQTT Websockets defaults
    mqtt_websockets_enabled = 1
    mqtt_websockets_host = "10.0.1.32"
    mqtt_websockets_port = 9001
    mqtt_websockets_ssl = 0
    mqtt_websockets_topic = "frogs"
    disconnect_live_website_visitor = 1800000

mqtt_websocets_topic is same as the [[MQTT]] topic in weewx.conf.  BTW, I’m just using the “frogs” topic as a test

Here is a sample message  being posted to “frogs”:
{"usUnits": "1.0", "dateTime": "1592238928.0", "rainRate_inch_per_hour": "0.0", "hourRain_in": "0.0", "rain24_in": "0.0", "dayRain_in": "0.0", "extraTemp1_F": "89.4", "barometer_inHg": "29.9"}

This must be being posted to a subtopic.  I can only see these messages with:
   mosquitto_sub -h 10.0.1.32 -t frogs/#


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/b7fba27b-626f-4300-9f2e-5377814eb08ao%40googlegroups.com.

Garry A Lockyer

unread,
Jun 15, 2020, 12:43:20 PM6/15/20
to weewx...@googlegroups.com
Try setting websockets topic to frogs/loop.

Regards,

Garry Lockyer

On Jun 15, 2020, at 09:39, Ken Walker <kwal...@gmail.com> wrote:

OK, now I get it.  Thanks Garry and Pat.

Ken Walker

unread,
Jun 15, 2020, 12:56:24 PM6/15/20
to weewx...@googlegroups.com
That did it.  

Thank you, Thank you, Thank you.



Reply all
Reply to author
Forward
0 new messages