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

On Saturday, November 27, 2021 at 5:36:51 PM UTC-5 vince wrote:

> 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
>
>
> On Saturday, November 27, 2021 at 2:26:46 PM UTC-8 storm...@gmail.com 
> wrote:
>
>>  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
>>
>> On Saturday, November 27, 2021 at 5:15:24 PM UTC-5 bgra...@umw.edu wrote:
>>
>>> 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
>>>
>>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/e308dcf5-f417-4fde-ad50-18cbeec21ab1n%40googlegroups.com.
Weex.conf file section on MQTT-subscribe:
# 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 = 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 #admin    #None

    # password for broker authentication.
    # Default is None.
    password = None  #admin    #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 
from 192.168.1.10
    [[topics]]
        # Units for MQTT payloads without unit value.
        # Valid values: US, METRIC, METRICWX
        # Default is: US
        unit_system = US

        [[[application/18/device/2cf7f12122500013/rx]]]

        #value sent from RAK7244

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


        #[[[SECOND/REPLACE_ME]]]

=====================================================================
Chirpstack Data from:  
http://192.168.1.10:8080/#/organizations/1/applications/18/devices/2cf7f12122500013/data

Applications/CO2app/Devices/CO2device

applicationID:"18"
applicationName:"CO2app"
deviceName:"CO2device"
devEUI:"2cf7f12122500013"
rxInfo:

frequency:903900000
modulation:"LORA"

    bandwidth:125
    spreadingFactor:10
    codeRate:"4/5"
    polarizationInversion:false

adr:true
dr:0
fCnt:220
fPort:2
data:"AQQQaJsGAAqz"

err:0
        CO2_Value_PPM:433
        measurementId:4100
        type:"report_telemetry"
    payload:"010410689B06000AB3"
    valid:true

tags:
        confirmedUplink:true
        devAddr:"015aef68"
        publishedAt:"2021-11-28T15:40:51.518878067Z"
================================================================

Data from weewx.log (debug):

Nov 28 10:40:51 n4mrv weewx[5956] DEBUG user.MQTTSubscribe: (Service) 
MessageCallbackProvider data-> incoming topic: 
application/18/device/2cf7f12122500013/rx, QOS: 0, retain: 0, payload: 
b'{"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}}'
Nov 28 10:40:51 n4mrv weewx[5956] ERROR user.MQTTSubscribe: (Service) 
MessageCallbackProvider on_message_json failed with <class 
'user.MQTTSubscribe.ConversionError'> and reason Failed converting field 
applicationName with value CO2app using 'lambda x: to_float(x)' with reason 
could not convert string to float: 'CO2app'..
Nov 28 10:40:51 n4mrv weewx[5956] ERROR user.MQTTSubscribe: (Service) **** 
MessageCallbackProvider Ignoring 
topic=application/18/device/2cf7f12122500013/rx and 
payload=b'{"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}}'
Nov 28 10:40:51 n4mrv weewx[5956] 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: 'CO2app'#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 applicationName with value CO2app using 'lambda x: 
to_float(x)' with reason could not convert string to float: 'CO2app'.

Reply via email to