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
On Monday, November 29, 2021 at 5:38:37 PM UTC-5 vince wrote:
> On Monday, November 29, 2021 at 2:05:05 PM UTC-8 [email protected] wrote:
>
>> I removed the function and it looks better. Last debug going into
>> mqtt_publish:
>>
>> 11/29/2021, 4:17:17 PMnode: mqtt_payload
>> <http://localhost:1880/#>application/18/device/2cf7f12122500013/rx
>> : msg.payload : string[87]
>> string[87]
>> { "CO2_Value_PPM": 399, "measurementId": 4100, "type": "report_telemetry"
>> }
>> <http://localhost:1880/#>
>>
>> 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 :-)
>
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/weewx-user/868df705-d733-4b5b-9968-60603a13bdafn%40googlegroups.com.