MQTT & Belchertown - mixed F & C units

69 views
Skip to first unread message

David Levine

unread,
Jan 1, 2021, 3:28:51 PM1/1/21
to weewx-user
I have a new setup and working on adding MQTT to the mix. I went with hivemq to start. What is occurring is the MQTT realtime refreshes appear to be a celcius value and not my expected/configured fahrenheit value. Am I missing a config setting/section?

Below is a snippet of debug console output and what I notice is the first message in the snippet shows temp in F which is what is expected. The 3rd message shows everything in C which is unexpected. When I first load my web page, it shows the temp, etc in F but after the first MQTT adjustment, a couple of the values switch to C, though the label stays F. 

belchertown.js?1609531535:37 MQTT: {"dateTime": "1609532099.0", "usUnits": "1.0", "rainRate_inch_per_hour": "0.0", "hourRain_in": "0.0", "rain24_in": "0.0", "dayRain_in": "0.0", "outTemp_F": "36.248", "outHumidity": "63.68", "pressure_inHg": "30.143325340375", "outTempBatteryStatus": "2.559", "UV": "0.15", "rain_in": "0.0", "windBatteryStatus": "2.559", "radiation_Wpm2": "27.0", "altimeter_inHg": "30.451898910400498", "barometer_inHg": "30.46410551847069", "cloudbase_foot": "2805.165679377027", "dewpoint_F": "25.137271010741078", "heatindex_F": "36.248", "humidex_F": "36.248"}

belchertown.js?1609531535:37 MQTT: {"dateTime": "1609532102.0", "windSpeed_mph": "0.0", "usUnits": "1.0", "rainRate_inch_per_hour": "0.0", "hourRain_in": "0.0", "rain24_in": "0.0", "dayRain_in": "0.0"}

belchertown.js?1609531535:37 MQTT: {"dateTime": "1609532103.0", "pressure_mbar": "1013.7152953417267", "outHumidity": "85.0", "inHumidity": "97.0", "outTemp_C": "2.7777777777777777", "inTemp_C": "5.222222222222221", "windSpeed_kph": "1.8024652800000003", "windGust_kph": "1.8024652800000003", "windDir": "227.0", "radiation_Wpm2": "0.0", "rain_cm": "0.0", "rainRate_mm_per_hour": "0.0", "UV": "0.0", "extraTemp1_C": "7.8999999999999995", "extraTemp2_C": "6.900000000000001", "extraHumid1": "85.0", "extraHumid2": "85.0", "rainBatteryStatus": "1.6", "windBatteryStatus": "1.66", "barometer_mbar": "1013.7152953417267", "altimeter_mbar": "1021.4013952324038", "windchill_C": "2.7777777777777777", "heatindex_C": "2.7777777777777777", "dewpoint_C": "0.5099126991358697", "inDewpoint_C": "4.785153750721902", "maxSolarRad_Wpm2": "0.0", "cloudbase_meter": "345.781455500638", "beaufort_count": "0.0", "appTemp_C": "0.5178210591074577", "humidex_C": "2.7777777777777777", "hourRain_cm": "0.0", "rain24_cm": "0.02032", "dayRain_mm": "0.20320000000000002", "usUnits": "16.0"}

The first message looks correct and the 3rd message not so much. 

Here's my MQTT config and what I added to the Belchertown/Extras section of weewx.conf:

    [[MQTT]]
        server_url = mqtt://broker.hivemq.com:1883/
        topic = weather
        unit_system = US
        binding = archive, loop
        aggregation = aggregate
        log_success = False
        log_failure = True
        
    [[Belchertown]]    
         [[[Extras]]]    
            # MQTT Websockets defaults
            mqtt_websockets_enabled = 1
            mqtt_websockets_host = broker.hivemq.com
            mqtt_websockets_port = 8000
            mqtt_websockets_ssl = 0
            mqtt_websockets_topic = weather/loop

Thanks!
David

David Levine

unread,
Jan 2, 2021, 1:11:34 PM1/2/21
to weewx-user
I did some more troubleshooting this morning. I looked at the weewx-mqtt code and saw if debug = 2, it would log the messages to the broker queue. What I see are only F values being sent to the MQTT broker such as:

Jan  2 17:30:36 raspberrypi weewx[14221] DEBUG user.mqtt: data: {'dateTime': '1609608633.0', 'usUnits': '1.0', 'rainRate_inch_per_hour': '0.0041459842519685035', 'hourRain_in': '0.0010364960629921259', 'rain24_in': '0.7630002755905513', 'dayRain_in': '0.015043897637795279', 'outTemp_F': '48.704', 'outHumidity': '65.82', 'pressure_inHg': '29.569262383375', 'outTempBatteryStatus': '2.58', 'UV': '1.13', 'rain_in': '0.0', 'windBatteryStatus': '2.58', 'radiation_Wpm2': '195.0', 'altimeter_inHg': '29.8730484820492', 'barometer_inHg': '29.87618364623033', 'cloudbase_foot': '2760.0530237211146', 'dewpoint_F': '37.791766695627096', 'heatindex_F': '46.367940000000004', 'humidex_F': '48.70400000000001'}

I am still seeing C units coming back while debugging the dev tools console when the Belchertown skin is receiving/logging the message like in my original post. Scanning the belcherown.js, with debug it is logging the incoming message so it is a head scratcher to me how one component is logging the outgoing message in F (US) while a different component is logging the incoming message in C (Metric)

David

David Levine

unread,
Jan 3, 2021, 3:44:09 PM1/3/21
to weewx-user
I wanted to close this out in case someone else runs into the same situation.

The reason for the unexpected behavior results coming back from the broker was using a public broker (HiveMQ) and what must be another user already using the weather topic. I modified the MQTT topic name in the config to be unique and all seems to be working as expected. The subscription must have been returning someone else's data, though their value were very close to mine.    I thought I tried a unique topic previously but maybe I missed updating the Belchertowm topic name. 

David
Reply all
Reply to author
Forward
0 new messages