qingping air monitor lite and mqtt and parsing json ...

49 views
Skip to first unread message

Dr__Bob

unread,
Nov 26, 2025, 1:24:29 PM (2 days ago) Nov 26
to weewx-user
Hi Guys (and Gals, of course!),

I have a Qingping AirMonitor Lite that can be set up to emit MQTT messages.  Great!  It took a while with many trials and errors, but it is now functioning, and mosquitto_sub shows a typical message:
qingping/MAC/up {"type":"17","id":1756,"need_ack":0,"mac":"MAC","timestamp":1764173842,"sensorData":[{"timestamp":{"value":1764173700},"temperature":{"value":22.56},"humidity":{"value":45.07},"co2":{"value":635},"pm25":{"value":1},"pm10":{"value":3},"battery":{"value":100}}]}

The topic is "qingping/MAC/up" and the message is clearly formatted as json.  So, now to get the relevant data points (pm25, pm10, co2 at a minimum) into weewx.  It looks to me like Rich Bell's  WeeWX-MQTTSubscribe could work, but I'm stymied by the (too?) many layers of the json.  Why the Qingping folks didn't just code the message as {"type":"17","pm25":1,"co2":635 ...} I don't know.  Anyway, type=17 is what I need to parse.  There are other types, but they just contain configuration data (such as wifi SSID, etc).  I *think* I need something along the lines of:

[MQTTSubscribeService]    
    [[message_callback]]
        # The 'type' of the message content.
        type = json
    [[topics]]
        # The WeeWX unit_system of the incoming data.
        unit_system = METRIC
        # The topic(s) of interest.
        [[[qingping/MAC/up]]]
            # This identifies a field, 'type', whose value is appended to every field in the current MQTT message.
            # For additional information see, https://github.com/bellrichm/WeeWX-MQTTSubscribe/wiki/Configuring-additional-options#msg_id_field
            msg_id_field = type
          [[[[sensorData_17]]]]

But then I don't know how to continue.  Do I just keep "punching" down and do something like
             [[[[[pm25]]]]]
               [[[[[[value]]]]]]]
                  name = pm2_5
or something similar or something completely different?

TIA!!!!
Bob

vince

unread,
Nov 26, 2025, 3:05:14 PM (2 days ago) Nov 26
to weewx-user

bell...@gmail.com

unread,
Nov 26, 2025, 7:24:16 PM (2 days ago) Nov 26
to weewx-user

Expanding a bit on what Vince wrote:

A more readable version of your MQTT payload is

{

    “type”: “17”,

The sensor data is an array, so you want to follow this example

https://github.com/bellrichm/WeeWX-MQTTSubscribe/wiki/json-example#json-message-with-array


You might also want to learn about running MQTTSubscribe stand-alone. Specifically in simulator mode, https://github.com/bellrichm/WeeWX-MQTTSubscribe/wiki/Simulator-mode. This will allow you to run MQTTSubscribe without impact your production WeeWX installation. This should make it easier to figure out the necessary MQTTSubscribe configuration.

rich

Robert Clare

unread,
Nov 26, 2025, 9:38:22 PM (2 days ago) Nov 26
to weewx...@googlegroups.com
Thanks,

By the time I got this from you, Rich, I had already figured out from Vince’s email that I was dealing with an array (with one element) of nested data points.  So I did:

[MQTTSubscribeService]
    enable = true 
    stop_on_validation_errors = true
    binding = archive
    host = localhost
    log = false
    port = 1883
[[topics]]
        unit_system = US
         [[[message]]]
                type = json
        [[[qingping/mac/up]]]
            subscribe = True
            ignore = true
            [[[[sensorData]]]]
                ignore = False   
               [[[[[subfields]]]]] 
                 [[[[[[data]]]]]]
                  [[[[data_co2_value]]]]
                    ignore=false
                    name = co2
                  [[[[data_pm25_value]]]]
                    ignore=false
                    name = pm2_5
                  [[[[data_pm10_value]]]]
                    ignore=false
                    name = pm10_0
This seems to work, as simulate mode gives me stuff like this in the log file:

2025-11-26 18:10:09 DEBUG (Service) MessageCallbackProvider data-> incoming topic: qingping/mac/up, QOS: 0, retain: 0, payload: b'{"type":"17","id":2979,"need_ack":0,"mac":"mac","timestamp":1764209379,"sensorData":[{"timestamp":{"value":1764208800},"temperature":{"value":24.9},"humidity":{"value":40.85},"co2":{"value":640},"pm25":{"value":0},"pm10":{"value":0},"battery":{"value":100}}]}'
2025-11-26 18:10:09 DEBUG (Service) TopicManager data-> incoming qingping/mac/up: co2: 640.0, pm2_5: 0.0, pm10_0: 0.0

2025-11-26 18:14:59 DEBUG (Service) TopicManager data-> outgoing qingping/mac/up: co2: 640.0, dateTime: 1764209409.6722662, pm2_5: 0.0, pm10_0: 0.0, usUnits: 1
2025-11-26 18:14:59 DEBUG (Service) TopicManager data-> outgoing accumulated qingping/mac/up: co2: 640.0, dateTime: 1764209700.0, pm2_5: 0.0, pm10_0: 0.0, usUnits: 1
2025-11-26 18:14:59 DEBUG (Service) data-> final record is 2025-11-26 18:15:00 PST (1764209700): co2: 640.0, dateTime:  a1764209700.0, interval: 15.0, pm2_5: 0.0, pm10_0: 0.0, usUnits: 1
2025-11-26 18:14:59 INFO (Service) Archive Record 6 of 10 is: 2025-11-26 18:15:00 PST (1764209700) co2: 640.0, dateTime: 1764209700.0, interval: 15.0, pm2_5: 0.0, pm10_0: 0.0, usUnits: 1

So, it’s picking up the mqtt messages and parsing them correctly, spitting out archive records!  Thank you Vince and Rich for your help.

Next up:  moving to the extended schema, since I’ve been running the old wview version, but now I’ll need pm2_5, pm10_0 and co2 at least.

Cheers,
Bob

On Nov 26, 2025, at 16:24, bell...@gmail.com <bell...@gmail.com> wrote:


--
You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/kRAJrKTyKDs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/weewx-user/f364fe08-e313-42ba-b75a-df0cd8653db1n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages