Getting LoRa data from server into weewx

490 views
Skip to first unread message

bgra...@umw.edu

unread,
Nov 27, 2021, 5:15:24 PM11/27/21
to weewx-user
Hello,
I'm running a RAK7244 LoRaWAN server/gateway on a local network to which my weewx server is connected. Weeex is the latest stable on Ubuntu with extended db.

A CO2 sensor is sending data to the LoRa server. I have node-red on my weewx server with a flow  connecting to the RAK7244. I want to have the CO2 data put into the co2 slot that is available on the weewx db.

I have installed the weewx extension Mosquitto-subscribe and attempted to configure weewx.conf as:
#################################################
# Options for 'MQTTSubscribeService'
[MQTTSubscribeService]
    # This section is for the MQTTSubscribe service.
        # Turn the service on and off.
    # Default is: true
    # Only used by the service.
    enable = true    # false
    
    # The MQTT server.
    # Default is localhost.
    host = localhost  #192.168.1.10    #localhost
    
    # The port to connect to.
    # Default is 1883.
    port = 1883
    
    # Maximum period in seconds allowed between communications with the broker.
    # Default is 60.
    keepalive = 60
    
    # username for broker authentication.
    # Default is None.
    username = None
    
    # password for broker authentication.
    # Default is None.
    password = None 
    
    # The binding, loop or archive.
    # Default is: loop
    # Only used by the service.
    binding = loop
    
    # The message handler to use
    [[message_callback]]
        # The format of the MQTT payload.
        # Currently support: individual, json, keyword
        # Must be specified.
        type = json    #REPLACE_ME
    
    # The application/18/device/2cf7f12122500013/rx  topics to subscribe to.
    [[topics]]
        # Units for MQTT payloads without unit value.
        # Valid values: US, METRIC, METRICWX
        # Default is: US
        unit_system = US
        
        [[[first/topic]]]

#value sent from RAK7244

[[[[CO2_Value_PPM]]]]
        #weewx db name
name = co2
ignore = false
                contains total = True
conversion type = float
                
        #[[[SECOND/REPLACE_ME]]]
################################################

The message (data) every 60 minutes coming from the node-red function is:

{"CO2_Value_PPM":401} 

I may have too many things going here but, as I'm not a programmer, I'm stuck trying to figure out the problem. The node-red flow is connected on both ends (RAK7244-->weewx) but I don't see any data reaching the db.

Thanks in advance if anyone can help on this.
Cheers'
Bob

storm...@gmail.com

unread,
Nov 27, 2021, 5:26:46 PM11/27/21
to weewx-user
 I believe you need to add the topic you subscribing to in [[[first/topic]]]. 

Example:

##########################################################################################
  #              Acurite-5n1 Sensors
  #              SDR # 1 
  #              433 MHz
  ##########################################################################################       

        
        [[[Acurite-Tower/8785/]]]
           
           [[[[temperature_F]]]]
            name = extraTemp7
            ignore = False
            contains_total = False
            conversion_type = float
            units = degree_F

vince

unread,
Nov 27, 2021, 5:36:51 PM11/27/21
to weewx-user
My example:

[MQTTSubscribeService]
    enable = True
    host = 192.168.1.171
    port = 1883
    keepalive = 60
    username = None
    password = None
    binding = loop
    [[message_callback]]
        type = json
    [[topics]]
        unit_system = US
        #
        #--- these are emitted every 5 minutes ---
        # mosquitto_sub -t BaseballRoomConditions -h nuc2
        #     {"dateTime": 1621715702, "extraTemp1": 63.16, "extraTemp2": 63.5, "pi": 100.28}
        #
        [[[BaseballRoomConditions]]]    <=== the topic to subscribe to
            [[[[dateTime]]]]            <=== the element in that topic
                ignore = True           <=== optionally ignore this item within the topic
            [[[[extraTemp1]]]]
                name = extraTemp1       <=== db element to map the item to
                units = degree_F        <=== its units
            [[[[extraTemp2]]]]
                name = extraTemp2
                units = degree_F
            [[[[pi]]]]
                ignore = True


bgra...@umw.edu

unread,
Nov 28, 2021, 11:21:43 AM11/28/21
to weewx-user
Thanks for coming back so soon with help Storm and Vince.
I am attaching three things in a .txt file rather than pasting in as the format seems messy and I'm not sure how to make it easier to read.

1.  My modified section of weewx.conf . Among other things, there seems to be a problem with float.

2.  The data sent from the LoRa server when I subscribe to applications/18/devices/2cf7f12122500013/rx  (using MQTT-explorer). Lots of unneeded things  but it contains the CO2_Value_PPM data.

3.  A listing of weewx.log in debug mode showing the problems (I hope). The data seems to be getting there but is not being parsed out for what I need.

Hopefully this will give you an idea of what's going on.  Thanks again for your help.
Bob

MQTTerror.txt

bell...@gmail.com

unread,
Nov 28, 2021, 12:22:22 PM11/28/21
to weewx-user

Bob,
Since you have a lot of fields that you want to ignore, try setting the ignore flag to true at the 'topic' level. Also I don’t think you want to set contains_total.  So you would end up with something like this, 
    [[topics]]
        [[[application/18/device/2cf7f12122500013/rx]]]
            ignore = true
    [[[[CO2_Value_PPM]]]]
        name = co2
                        ignore = false

Since the data is published so infrequently, once you get the basic configuration working, you might want to look into the expires_after option. This will cache the value between publications. For additional information see, https://github.com/bellrichm/WeeWX-MQTTSubscribe/wiki/Configuring-additional-options#expires_after

rich

vince

unread,
Nov 28, 2021, 1:04:45 PM11/28/21
to weewx-user
That's rather hard to read. Can you do a more simple test with mosquitto_sub and show us what it returns ?

mosquitto_sub -t YOUR_MQTT_TOPIC -h YOUR_MQTT_HOST

You might need to install the mosquitto mqtt client package on whatever you're using for your weewx server.

bell...@gmail.com

unread,
Nov 28, 2021, 1:41:56 PM11/28/21
to weewx-user
I looked more closely at the payload format and I don't think that format is currently supported. specifically the 'nested array'..
"object":{"err":0,"messages":[{"CO2_Value_PPM":433,"measurementId":4100,"type":"report_telemetry"}]
Busy time of the year, so not sure when I'll have time to delve into a solution.
rich

storm...@gmail.com

unread,
Nov 28, 2021, 1:51:17 PM11/28/21
to weewx-user
Since you are using Node Red, a possible solution is to use a Change Node and delete the payload that you don't want to include in weewx.

vince

unread,
Nov 28, 2021, 2:07:59 PM11/28/21
to weewx-user
Agree.  Pre-process it to a format that works with weewx.

Again, can you give us a vanilla "mosquitto_sub -t whatever -h the_host" output so we can see what you have a little more clearly ?   Piping it to " |  jq . " sometimes helps show the nesting and structure a little better for the eyes.

bell...@gmail.com

unread,
Nov 28, 2021, 2:21:01 PM11/28/21
to weewx-user
From the log extract, this what I see as the payload

{
    "applicationID": "18",
    "applicationName": "CO2app",
    "deviceName": "CO2device",
    "devEUI": "2cf7f12122500013",
    "txInfo": {
        "frequency": 903900000,
        "dr": 0
    },
    "adr": true,
    "fCnt": 220,
    "fPort": 2,
    "data": "AQQQaJsGAAqz",
    "object": {
        "err": 0,
        "messages": [
            {
                "CO2_Value_PPM": 433,
                "measurementId": 4100,
                "type": "report_telemetry"
            }
        ],
        "payload": "010410689B06000AB3",
        "valid": true
    }
}

bgra...@umw.edu

unread,
Nov 28, 2021, 3:50:53 PM11/28/21
to weewx-user
Thanks for the replies. Here is where I am.

bg@n4mrv:~$ mosquitto_sub -t application/18/device/2cf7f12122500013/rx -h 192.168.1.10 | jq .
{
  "applicationID": "18",
  "applicationName": "CO2app",
  "deviceName": "CO2device",
  "devEUI": "2cf7f12122500013",
  "txInfo": {
    "frequency": 905300000,
    "dr": 0
  },
  "adr": true,
  "fCnt": 226,
  "fPort": 2,
  "data": "AQQQsI8GAF5I",
  "object": {
    "err": 0,
    "messages": [
      {
        "CO2_Value_PPM": 430,
        "measurementId": 4100,
        "type": "report_telemetry"
      }
    ],
    "payload": "010410B08F06005E48",
    "valid": true
  }
}


I was using node-red but thought it was conflicting with something else on Mosquitto-subscribe-weewx so I turned it off. I wasn't sure how to connect weewx to the output of n-r.

When setting the CO2 sensor up with emoncms (another server) a kind and knowledgeable soul gave me the following code for a function in n-r:
```
// Test to see if CO2 measurement is present in uplink // Assumption is msg.payload.object.messages[] array is always present // if not then we need to test in different way // why do we do this to ensure we don't send rubbish to emoncms if ("CO2_Value_PPM" in msg.payload.object.messages[0]){ msg = {payload:{"CO2_Value_PPM":msg.payload.object.messages[0].CO2_Value_PPM}}; return msg; }
```
This cut down the extra data and produced something like:  "CO2_Value_PPM: 430" other data was omitted.
You may have an idea about connecting n-r.
Cheers,
Bob

storm...@gmail.com

unread,
Nov 28, 2021, 6:56:50 PM11/28/21
to weewx-user

Below is how I got my MQTT broker in Node-Red setup to publish topics.  Almost every tab has some topic being published.

Node Red tower flow.png


Here is how I have my MQTT service configured (only one topic shown) on a second RPI.

[MQTTSubscribeService]

    # This section is for the MQTTSubscribe service.
    
    # Turn the service on and off.
    # Default is: true
    # Only used by the service.
    enable = true
    
    # The MQTT server.
    # Default is localhost.
    host = 192.168.1.240 ## Node-Red Broker
    
    # The port to connect to.
    # Default is 1883.
    port = 1883
    
    # Maximum period in seconds allowed between communications with the broker.
    # Default is 60.
    keepalive = 60
    
    # username for broker authentication.
    # Default is None.
    username = None
    
    # password for broker authentication.
    # Default is None.
    password = None
    
    # The binding, loop or archive.
    # Default is: loop
    # Only used by the service.
    binding = loop
    
    # The message handler to use

    [[message_callback]]
        # The format of the MQTT payload.
        # Currently support: individual, json, keyword
        # Must be specified.
        type = json
    
    # The topics to subscribe to.
    [[topics]]
        
        # Units for MQTT payloads without unit value.
        # Valid values: US, METRIC, METRICWX
        # Default is: US
        unit_system = US
        
        # With the exception of wind data, by default a packet is created for every MQTT message received.
        # When this is true, MQTTSubscribe attempts to collect observations across messages into a packet.
        # Default is False.
        # This is experimental and may be removed.
        collect_observations = True

        # With the exception of wind data, by default a queue is created for every MQTT topic.
        # When this is true, MQTTSubsribe uses a single queue for all non wind data.
        # This is useful when 'collect_observations = True'.
        # Default is False.
        # This is experimental and may be removed.
        single_queue = True

[[[Acurite-Tower/8785/]]] ## Topic to subscribe to in the Node-Red Broker

           [[[[temperature_F]]]] ## Object within the Topic
            name = extraTemp7 ##Weewx Database Field
            ignore = False
            contains_total = False
            conversion_type = float
            units = degree_F
           
           [[[[humidity]]]] ## Object within the Topic
            name = extraHumid7 ##Weewx Database Field
            ignore = False
            contains_total = False
            conversion_type = float   
   
           [[[[battery_ok]]]] ## Object within the Topic
            name = batteryStatus7  ##Weewx Database Field
            ignore = False
            contains_total = False

bell...@gmail.com

unread,
Nov 28, 2021, 7:09:31 PM11/28/21
to weewx-user
OK, assuming (and you know what happens when one assumes) that your payload is:
{
   "CO2_Value_PPM": 430
}

And yout topic is:
application/18/device/2cf7f12122500013/rx

Then this should work:
    [[topics]]
        [[[application/18/device/2cf7f12122500013/rx]]]
    [[[[CO2_Value_PPM]]]]
        name = co2

If it doesn't, post the debug log.
rich

bgra...@umw.edu

unread,
Nov 29, 2021, 11:51:30 AM11/29/21
to weewx-user
Storm et al.,
I have attempted to setup my node-red and weewx.conf according to your email. I'm still getting errors which I have attached.  My weewx.conf file:
##############################################################################
# Options for 'MQTTSubscribeService'
[MQTTSubscribeService]
        enable = true    # false
    # The MQTT server.
    
    host = 192.168.1.10    [this is the LoRa server, N-R is running on the weewx machine 192.168.1.119. Should N-R be on the LoRa server?]
       port = 1883
       keepalive = 60
        username = None #admin    #None
       password = None  #admin    #None
        binding = loop

       [[message_callback]]
        
        type = json    #REPLACE_ME

    # The application/18/device/2cf7f12122500013/rx  topics to subscribe to.
    [[topics]]
                unit_system = US
        [[[application/18/device/2cf7f12122500013/rx]]]

        #data  sent from RAK7244
        #ignore = true
                [[[[CO2_Value_PPM]]]]
        #weewx db field name
                name = co2
                ignore = false
                contains total = false
                conversion type = float
                #units = ppm
        #[[[SECOND/REPLACE_ME]]]

The function in N-R seems to be putting out the correct data "CO2_Value_PPM: 404" but something isn't connecting properly.
Even though N-R (on weewx machine) says it's sending the parsed data, it seems to getting the whole data set. Should I be running
N-R on the LoRa server where the data is coming from? 
Sorry for the naive questions but I'm really not a programmer (but learning!)
Much appreciated for the help from everyone!
Cheers,
Bob


lastDebug.txt

bell...@gmail.com

unread,
Nov 29, 2021, 12:53:42 PM11/29/21
to weewx-user
Bob,
You are right that the topic that you have configured for MQTTSubscribe is still getting extra data. This is what I pulled from the log you just posted
{
    "applicationID": "18",
    "applicationName": "CO2app",
    "deviceName": "CO2device",
    "devEUI": "2cf7f12122500013",
    "txInfo": {
        "frequency": 904900000,
        "dr": 0
    },
    "adr": true,
    "fCnt": 247,
    "fPort": 2,
    "data": "AQQQICoGAPuQ",
    "object": {
        "err": 0,
        "messages": [
            {
                "CO2_Value_PPM": 404,
                "measurementId": 4100,
                "type": "report_telemetry"
            }
        ],
        "payload": "010410202A0600FB90",
        "valid": true
    }
}
I'm not going to be any help on the publishing end, so I'll leave that to the experts.
Once you get that straightened out, if you have any problems with MQTTSubscribe I'll be available.
rich

vince

unread,
Nov 29, 2021, 1:02:27 PM11/29/21
to weewx-user
Looks like you're not stripping the original received payload down to the minimalist subset before publishing it into MQTT.

Add a debug item before+after your stripping function and see if it's actually stripping anything.  I suspect not.  Likely a typo.

if ("CO2_Value_PPM" in msg.payload.object.messages[0]){ msg = {payload:{"CO2_Value_PPM":msg.payload.object.messages[0].CO2_Value_PPM}}; return msg;

Either that or you are emitting the result to a different MQTT topic than the one you have configured in your weewx.conf and your weewx.conf is still looking at the 'before stripping' original topic, not the 'after stripping down' actual subset you want to subscribe to.

vince

unread,
Nov 29, 2021, 2:25:49 PM11/29/21
to weewx-user
I took a few minutes to relearn node-red a bit and got it to work by injecting your starting json and emitting mqtt to a mosquitto broker on the same node.  Works fine here.

I've attached the flows and details for the various nodes as images and the whole thing as a json you can try yourself.   The key seems to be setting "format JSON string" in the json node.


json-node-details.png
mqtt-out-details.png
flows.json
flows.png
change-node-details.png

bgra...@umw.edu

unread,
Nov 29, 2021, 4:12:27 PM11/29/21
to weewx-user
Thanks, Vince, for all this extra work! I'm still having problems but feel we are close since you got it to work by injecting my data.
I wasn't sure how to feed your flow but here is what I have:

2021-11-29.pngf
The debug messages (from right hand area of screen) are as follows:

11/29/2021, 3:15:52 PMnode: 7effad75.c88c64      ******** [from the CO2_from RAK7244]
application/18/device/2cf7f12122500013/rx : msg.payload : Object
object
applicationID: "18"
applicationName: "CO2app"
deviceName: "CO2device"
devEUI: "2cf7f12122500013"
txInfo: object
frequency: 904700000
dr: 0
adr: true
fCnt: 251
fPort: 2
data: "AAcAZAA8ANvo"
object: object

11/29/2021, 3:16:03 PMnode: 7effad75.c88c64    **** [also from the CO2_from RAK7244; not sure why another came (?)]
application/18/device/2cf7f12122500013/rx : msg.payload : Object
object
applicationID: "18"
applicationName: "CO2app"
deviceName: "CO2device"
devEUI: "2cf7f12122500013"
txInfo: object
adr: true
fCnt: 252
fPort: 2
data: "AQQQwDkGAIBO"
object: object

11/29/2021, 3:16:03 PMnode: 71dff607.6d0c88     ****[from the CO2_Value_PPM output--this looks correct]
msg.payload : Object
{ CO2_Value_PPM: 408 }

11/29/2021, 3:16:03 PMnode: 2056fe20.5f0b7a   ****[from the json output--it stops after this]
msg : error
"TypeError: Cannot read property 'messages' of undefined"

I wasn't sure what the "topic" should be which you had listed in publish_to_mqtt so I changed mytopic to application/18/device/2cf7f12122500013/rx
Is this correct or should it be CO2_Value_PPM?

Should I remove my function as it seems to cause a conflict with yours? I was using this in my other setup
with emoncms and it seems to be working there but may not be the correct form to feed your  process.

Please take your time on this, there is no big rush for me. Many thanks!
Bob

vince

unread,
Nov 29, 2021, 4:28:14 PM11/29/21
to weewx-user
  • You can call the mqtt topic you publish to anything you want, just make sure weewx subscribes to that topic of course.
  • You might want to name your debug nodes explicitly but that's just nice to have for viewing the debug output
Basically go as simple as possible first before adding in the mqtt publish at the end.
  • I'd suggest detaching your function node (for now) and see if the simple variant I did works for you first.
  • You could also detach the mqtt publish node (for now) until your debug node output looks correct.
Go with stuff-comes-in, convert-to-json, grab-the-desired-subset, and see what the debug nodes show you in/between/after each element.

Step through it.

bgra...@umw.edu

unread,
Nov 29, 2021, 5:05:05 PM11/29/21
to weewx-user
I removed the function and it looks better. Last debug going into mqtt_publish:

11/29/2021, 4:17:17 PMnode: mqtt_payloadapplication/18/device/2cf7f12122500013/rx : msg.payload : string[87]
string[87]
{ "CO2_Value_PPM": 399, "measurementId": 4100, "type": "report_telemetry" }

However, weewx still doesn't seem to like it. I'll try changing topics to "mytopic" and see what happens.
Now heading for the aspirin bottle and will check results later. Have a good evening!

vince

unread,
Nov 29, 2021, 5:38:37 PM11/29/21
to weewx-user
On Monday, November 29, 2021 at 2:05:05 PM UTC-8 bgra...@umw.edu wrote:
I removed the function and it looks better. Last debug going into mqtt_publish:

11/29/2021, 4:17:17 PMnode: mqtt_payloadapplication/18/device/2cf7f12122500013/rx : msg.payload : string[87]
string[87]
{ "CO2_Value_PPM": 399, "measurementId": 4100, "type": "report_telemetry" }

However, weewx still doesn't seem to like it. I'll try changing topics to "mytopic" and see what happens.

Sigh - just set the topic in weewx.conf to whatever you are publishing via node-red, and reset weewx.
Until you do that, it's not going to work.

It does not matter what topic you publish to, just keep your naming consistent and theoretically relevant so you can figure it out a year from now when you want to decipher what the heck you did :-)

bgra...@umw.edu

unread,
Nov 29, 2021, 7:53:46 PM11/29/21
to weewx-user
Last post of the day, I promise!
I think the node-red flow is working the way it should and reporting the parsed message as in my last post.

weewx.conf configuration (changed topic to "mytopic" in the flow and in weewx).

[MQTTSubscribeService]
    # This section is for the MQTTSubscribe service.
    enable = true    # false

    # The MQTT server.
    # Default is localhost.
    host = localhost
        port = 1883
        keepalive = 60

        username = None #admin    #None
       password = None  #admin    #None
      binding = loop

       [[message_callback]]
                type = json    #REPLACE_ME

    #  mytopic  is the topic to subscribe to.
    [[topics]]
       
        unit_system = US

        [[[mytopic]]]

        #data  sent from RAK7244
        #ignore = true
                [[[[CO2_Value_PPM]]]]
        #weewx db field name
                name = co2
                ignore = false
                contains total = false
                conversion type = float
                #units = ppm
        #[[[SECOND/REPLACE_ME]]]

This is the weewx.log debug info:

Nov 29 19:20:58 n4mrv weewx[17143] DEBUG user.MQTTSubscribe: (Service) MessageCallbackProvider data-> incoming topic: mytopic, QOS: 0, retain: 0, payload: b'{\n    "CO2_Value_PPM": 419,\n    "measurementId": 4100,\n    "type": "report_telemetry"\n}'
Nov 29 19:20:58 n4mrv weewx[17143] ERROR user.MQTTSubscribe: (Service) MessageCallbackProvider on_message_json failed with <class 'user.MQTTSubscribe.ConversionError'> and reason Failed converting field type with value report_telemetry using 'lambda x: to_float(x)' with reason could not convert string to float: 'report_telemetry'..
Nov 29 19:20:58 n4mrv weewx[17143] ERROR user.MQTTSubscribe: (Service) **** MessageCallbackProvider Ignoring topic=mytopic and payload=b'{\n    "CO2_Value_PPM": 419,\n    "measurementId": 4100,\n    "type": "report_telemetry"\n}'
Nov 29 19:20:58 n4mrv weewx[17143] ERROR user.MQTTSubscribe: (Service) **** MessageCallbackProvider Traceback (most recent call last):#012  File "/home/weewx/bin/user/MQTTSubscribe.py", line 1263, in _convert_value#012    return conversion_func['compiled'](value)#012  File "<string>", line 1, in <lambda>#012  File "/home/weewx/bin/weeutil/weeutil.py", line 1276, in to_float#012    return float(x) if x is not None else None#012ValueError: could not convert string to float: 'report_telemetry'#012#012During handling of the above exception, another exception occurred:#012#012Traceback (most recent call last):#012  File "/home/weewx/bin/user/MQTTSubscribe.py", line 1427, in _on_message_json#012    (fieldname, value) = self._update_data(fields, fields_conversion_func, lookup_key, data_flattened[key], unit_system)#012  File "/home/weewx/bin/user/MQTTSubscribe.py", line 1230, in _update_data#012    value = self._convert_value(fields, default_field_conversion_func, orig_name, orig_value)#012  File "/home/weewx/bin/user/MQTTSubscribe.py", line 1268, in _convert_value#012    raise ConversionError("Failed converting field %s with value %s using '%s' with reason %s." \#012user.MQTTSubscribe.ConversionError: Failed converting field type with value report_telemetry using 'lambda x: to_float(x)' with reason could not convert string to float: 'report_telemetry'.
Nov 29 19:20:59 n4mrv weewx[17143] DEBUG user.purple: new_loop_packet(Event type: <class 'weewx.NEW_LOOP_PACKET'> | packet: {'dateTime': 1638231660, 'usUnits': 1, 'barometer': 30.091, 'inTemp': 79.0, 'inHumidity': 27.0, 'outTemp': 33.7, 'windSpeed': 0.0, 'windSpeed10': 0.0, 'windDir': 0, 'extraTemp1': 72.0, 'soilTemp1': 51.0, 'soilTemp2': 97.0, 'soilTemp4': 47.0, 'leafTemp1': 51.0, 'leafTemp2': 97.0, 'outHumidity': 74.0, 'rainRate': 0.0, 'UV': 0.0, 'radiation': 0.0, 'stormRain': 0.0, 'dayRain': 0.0, 'monthRain': 0.6, 'yearRain': 41.65, 'dayET': 0.051, 'monthET': 1.15, 'yearET': 24.95, 'leafWet4': 0.0, 'insideAlarm': 0, 'rainAlarm': 0, 'outsideAlarm1': 0, 'outsideAlarm2': 0, 'extraAlarm1': 0, 'extraAlarm2': 0, 'extraAlarm3': 0, 'extraAlarm4': 0, 'extraAlarm5': 0, 'extraAlarm6': 0, 'extraAlarm7': 0, 'extraAlarm8': 0, 'soilLeafAlarm1': 0, 'soilLeafAlarm2': 0, 'soilLeafAlarm3': 0, 'soilLeafAlarm4': 0, 'txBatteryStatus': 0, 'consBatteryVoltage': 4.72, 'forecastIcon': 6, 'forecastRule': 44, 'sunrise': 1638187560, 'sunset': 1638222720, 'rain': 0.0, 'windGust': 0.0, 'windGustDir': None})
Nov 29 19:20:59 n4mrv weewx[17143] DEBUG user.purple: new_loop_packet: self.cfg.concentrations: Concentrations(timestamp=1638231655, pm1_0=4.425, pm10_0=6.5649999999999995, pm2_5_cf_1=5.39, pm2_5_cf_1_b=7.39, current_temp_f=42, current_humidity=45)
Nov 29 19:20:59 n4mrv weewx[17143] DEBUG user.purple: Time of reading being inserted: 2021-11-29 19:20:55 EST (1638231655)
Nov 29 19:20:59 n4mrv weewx[17143] DEBUG user.purple: Inserted packet[pm1_0]: 4.425000 into packet.
Nov 29 19:20:59 n4mrv weewx[17143] DEBUG user.purple: Inserted packet[pm2_5]: 4.534270 into packet.
Nov 29 19:20:59 n4mrv weewx[17143] DEBUG user.purple: Inserted packet[pm10_0]: 6.565000 into packet.
Nov 29 19:20:59 n4mrv weewx[17143] DEBUG user.MQTTSubscribe: (Service) data-> final packet is 2021-11-29 19:21:00 EST (1638231660): barometer: 30.091, consBatteryVoltage: 4.72, dateTime: 1638231660, dayET: 0.051, dayRain: 0.0, extraAlarm1: 0, extraAlarm2: 0, extraAlarm3: 0, extraAlarm4: 0, extraAlarm5: 0, extraAlarm6: 0, extraAlarm7: 0, extraAlarm8: 0, extraTemp1: 72.0, forecastIcon: 6, forecastRule: 44, inHumidity: 27.0, insideAlarm: 0, inTemp: 79.0, leafTemp1: 51.0, leafTemp2: 97.0, leafWet4: 0.0, monthET: 1.15, monthRain: 0.6, outHumidity: 74.0, outsideAlarm1: 0, outsideAlarm2: 0, outTemp: 33.7, pm1_0: 4.425, pm10_0: 6.5649999999999995, pm2_5: 4.53427, pm2_5_aqi: 18.75, pm2_5_aqi_color: 32768, radiation: 0.0, rain: 0.0, rainAlarm: 0, rainRate: 0.0, soilLeafAlarm1: 0, soilLeafAlarm2: 0, soilLeafAlarm3: 0, soilLeafAlarm4: 0, soilTemp1: 51.0, soilTemp2: 97.0, soilTemp4: 47.0, stormRain: 0.0, sunrise: 1638187560, sunset: 1638222720, txBatteryStatus: 0, usUnits: 1, UV: 0.0, windDir: 0, windGust: 0.0, windGustDir: None, windSpeed: 0.0, windSpeed10: 0.0, yearET: 24.95, yearRain: 41.65

It seems that there is something wrong with the format coming into weewx from the flow. It may be confused by the other two elements "measurementId": 4100, and "type": "report_telemetry" which cause the whole thing to fail. Is it possible to have weewx ignore these elements and only process the  "CO2_Value_PPM": 419 ? I'm not sure what "float" does but mayve that's a problem...?
Thanks again and I'll have another look tomorrow.
Cheers,
Bob

vince

unread,
Nov 29, 2021, 9:02:39 PM11/29/21
to weewx-user
==> ValueError: could not convert string to float: 'report_telemetry'

Still think you're providing more info to weewx than just the one element you want.   It's hard to convert "true" to a float.

You need to ignore report_telemetry and measurementID via your weewx.conf, as we gave you numerous examples earlier in this thread.

bell...@gmail.com

unread,
Nov 29, 2021, 9:05:54 PM11/29/21
to weewx-user
Bob,
You are correct. The extra data is causing the problem. Due to a poor early design decision, MQTTSubscribe defaults to converting everything to float. Obviously, 'report_telemetry' cannot be converted to float. The following configuration should work. It ignores all but 'CO2_Value_PPM'.
    [[topics]]
        [[[mytopic]]]
            ignore = true
            [[[[CO2_Value_PPM]]]]
                name = co2
                ignore = false
If that doesn't work, let me know and I can give a different configuration.
rich

storm...@gmail.com

unread,
Nov 29, 2021, 9:20:28 PM11/29/21
to weewx-user
 "Is it possible to have weewx ignore these elements and only process the  "CO2_Value_PPM": 419 ?"  Yes, Rich provided the possible solution.

 "I'm not sure what "float" does but mayve that's a problem...?"  A float is a real number.  It is trying to convert  'report_telemetry' which is a string to a real number causing the failure.

vince

unread,
Nov 30, 2021, 12:15:33 AM11/30/21
to weewx-user
I'd go with something like......

[[topics]]
    [[[mytopic]]]
       [[[[CO2_Value_PPM]]]]
       name = co2
       contains total = false
       conversion type = float
       [[[[measurementID]]]]
       ignore = true
       [[[[report_telemetry]]]]
       ignore = true

Define the topic to subscribe to.
Do not ignore the one element therein that you want.
Ignore the elements you don't want.

bgra...@umw.edu

unread,
Nov 30, 2021, 3:21:03 PM11/30/21
to weewx-user
I'm very happy to say that I have three successful (hourly) readings of CO2 in the weewx db, thanks to everyone who has been patient and helpful with an 81-year-old retired librarian attempting to do something that was beyond his reach. 
                        [I just heard a cumulative sigh of relief circle the globe]
In the end, my main problem was adjusting the elements in weewx.conf with a combination of some of the last suggestions. I found that the sensor, once every 24 hours, sends out a different string of data with battery information which doesn't include any CO2 data. My next step is setting up a display of the data with a graph on my main page. 

Many thanks again to everyone who helped solve my problem. I now have another window into the ills that plague our planet....

Cheers,
Bob

Colin Larsen

unread,
Nov 30, 2021, 5:38:43 PM11/30/21
to weewx-user
Good work Bob, well done getting it sorted :)

Cheers
Colin

--
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/a777ce3b-7e97-411c-b800-093641163d6en%40googlegroups.com.

storm...@gmail.com

unread,
Nov 30, 2021, 6:16:10 PM11/30/21
to weewx-user
Glad you have it working now.  What type of CO2 sensor are you using?
Reply all
Reply to author
Forward
0 new messages