Tasmota - Sonoff - SDS011 cannot transform PM2.5

jsonpath
Tags: #<Tag:0x00007f1e68ea9b00>
(John Barnes) #1

Raspberry Pi 3 B+
Openhab 2.4

I’ve been looking for days trying to reach a solution to this problem, finally gave in! (plus i’m only a month in to Openhab)

I’ve flashed a Sonoff Basic with Tasmota and connected a SDS011 via serial and MQTT is reporting:
{“Time”:“2019-05-14T21:23:38”,“SDS0X1”:{“PM2.5”:2.9,“PM10”:4.7}}

I’m using Paper UI to add the thing and using JSONPATH to transform for the value.

It works fine for PM10 using the below transformation:
JSONPATH:$.SDS0X1.PM10

However when I try and transform for the PM2.5 it fails.
Transformation:
JSONPATH:$.SDS0X1.PM2.5

Log Viewer:
2019-05-14 22:46:09.504 [WARN ] [l.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path ‘$.SDS0X1.PM2.5’ in ‘{“Time”:“2019-05-14T22:46:09”,“SDS0X1”:{“PM2.5”:3.6,“PM10”:5.9}}’

I suspect its the decimal point in ‘2.5’

I’ve looked for how to remove the decimal in Tasmota and cannot work that one out, looked for how to handle decimals in JSONPATH with no joy.

Any suggestions would be much appreciated.

Thanks

John

0 Likes

(Rich Koshak) #2

Perhaps adding an escape before the .

JSONPATH:$.SDS0X1.PM2\.5
0 Likes

(John Barnes) #3

Thanks for getting back. Unfortunately we have the same error:
2019-05-15 09:45:38.116 [WARN ] [l.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path ‘$.SDS0X1.PM2.5’ in ‘{“Time”:“2019-05-15T09:45:37”,“SDS0X1”:{“PM2.5”:2.0,“PM10”:9.1}}’

Thanks

John

0 Likes

(Rich Koshak) #4

There might be a bug or limitation in handling keys with a dot. But regex should work here as an alternative.

Regex(.*PM2\.5\":(.*),.*)
0 Likes

(John Barnes) #5

Its still not playing ball. error as follows:
2019-05-15 17:50:29.520 [WARN ] [l.generic.ChannelStateTransformation] - Transformation service REGEX(.PM2.5" for pattern (.),.*) not found!

0 Likes

(Rich Koshak) #6

It looks like you are missing a * after the first .. You might need to escape the : with \:.

Please post your exact configuration if it still shows an error.

0 Likes

(John Barnes) #7

Thanks for the help.
Its still not working, for some reason the log entry doesn’t show all the char’s
the latest log for Regex(.PM2.5":(.),.):
2019-05-15 18:29:00.718 [WARN ] [l.generic.ChannelStateTransformation] - Transformation service REGEX(.PM2.5"\ for pattern (.),.
) not found!

Config:
the sensor is connected via serial into a sonoff with Tasmota.

MQTT.fx is reporting the following:
tele/AirQual/SENSOR
{“Time”:“2019-05-15T18:37:21”,“SDS0X1”:{“PM2.5”:2.3,“PM10”:6.3}}

The Thing is set up as generic MQTT and the channel is set up as TEXT (and I’ve tried Number) and as follows:

(This works fine with JSONPATH:$.SDS0X1.PM10)

If i remove the transformation i get the full results in the item.

However if i use JSONPATH:$.SDS0X1.PM2.5 or Regex(.PM2.5":(.),.) or Regex(.PM2.5":(.),.) it fails.

Thanks

John

0 Likes

(Rich Koshak) #8

If you are using the MQTT binding, you have to use the proper syntax for transforms.

REGEX:.*PM2\.5\"\:(.*),.*

The syntax for MQTT2 is different from what other bindings use.

That : still might cause some problems too. If it does, replace the \: with . and it should still work.

0 Likes

(John Barnes) #9

Thanks very much, its working fine now. as per the solution above. I didn’t know MQTT 2 Binding affects Regex as well. Some more reading needed!

0 Likes

(Rich Koshak) #10

The “standard” format for transformations everywhere else is <transform name>(<argument>) where <transform name> is the name of the transfomation add-on (e.g. REGEX, JSONPATH, MAP) and <argument> is the argument (e.g. mymap.map, $.SDS0X1.PM10, .PM2.5":(.),.*, etc).

For the MQTT2 binding, the developer decided to do his own thing and use a colon instead of the ().

<transform name>:<argument>
0 Likes