MQTT Tasmota Vindriktning - JSONPARSE

Tasmota sends me following MQTT payload for the Vindriktning-sensor: {“Time”:“2021-12-19T18:16:56”,“VINDRIKTNING”:{“PM2.5”:16}}

In my Openhab Thing I would like to parse the PM2.5 value with JSONPATH (in transformationPattern)

The expression JSONPATH:$.VINDRIKTNING.PM2.5 fails however since there is a point in the PM2.5 field.

Is there a way to escape a point-char when parsing the response with JSONPATH?

Try

JSONPATH:$.VINDRIKTNING."PM2.5"

With tasmota you can also ask it to brake out of the JSON in tasmota console enter setoption4 1

Putting double quotes around the PM2.5 part does work. This makes JSONPATH look for quotes in the name.

Invalid path ‘$.VINDRIKTNING.“PM2.5”’ in ‘{“Time”:“2021-12-19T20:44:28”,“VINDRIKTNING”:{“PM2.5”:9}}’

ps: SetOption4 seems to have no effect on the messages that Tasmota sends out on my system (10.1.0)

try to use

$[VINDRIKTNING][PM2.5]

because the documentaion siad JSONPath is based ib GitHub - json-path/JsonPath: Java JsonPath implementation

I think you need the ` in bracket notation

$['VINDRIKTNING']['PM2.5']

2 Likes

Perfect. This notation work without any problem. Thank you very much.

Hi,
I also just try to add the Vindriktning sensor to OH.
Flashed, Tasmota works fine.
I also add a OH item in the rules, after saving the rules (with the working jsonpath -part, thx to denominator!), I get one line:
2022-03-20 14:28:00.397 [vent.ItemStateChangedEvent] - Climate_Vind_01_particles changed from NULL to 6

=> So, working correct.

“6” is the correct value, see also in the Tasmota frontend.

But (surely) stupid question (nearly one year nothing done with MQTT and OH),
how I will get updates?
Have I to create a “trigger”, can this be done on the Tasmota-console (send every minute a mqtt-message out) or in OH ?

A default installation of Tasmota will publish an update on the tele topic every 300 seconds (5 minutes).

Oh yes, I should wait :wink:

Can I change this, using the command prompt from Tasmota ?

Yes

teleperiod X

Where X is the number of seconds between updates.