openHabian on a raspi3b+, latest update of everything, RegEx and JSONPath transformation 2.5.7
This is about integrating 4 (MagicHome) Led controller on Tasmota into my system. Ok, I lied. They are integrated and work as expected but now my otherwise rather clean log gets spammed with ‘Executing the JSONPATH failed’ warnings.
I followed MQTT 2.5 M1+ How to implement the equivalent to MQTT1 REGEX filters on this. I’ve seen some people report success while others had no such luck. I seemingly belong to both groups.
4 identical controllers, flashed the same day with the same tasmota, configured identically in the things file and with 3 of them the regex filtering fails, but it works for one. That’s puzzling me.
Here are the details:
Bridge mqtt:broker:mqBroker [ host="192.168.50.1",secure=false, username="oh", password="secret", qos=1 ]
{
Thing topic ullu1 "ullu1" {
Channels:
Type switch : power "power"
[stateTopic="tasmota/ullu1/stat/RESULT",
transformationPattern="REGEX:(.*POWER.*)∩JSONPATH:$.POWER",
commandTopic="tasmota/ullu1/cmnd/POWER"]
Type dimmer : brightness "brightness"
[stateTopic="tasmota/ullu1/stat/RESULT",
transformationPattern="REGEX:(.*Dimmer.*)∩JSONPATH:$.Dimmer",
commandTopic="tasmota/ullu1/cmnd/Dimmer", min=0, max=100, step=1]
Type switch : fade "fade"
[stateTopic="tasmota/ullu1/stat/RESULT",
transformationPattern="REGEX:(.*Fade.*)∩JSONPATH:$.Fade",
commandTopic="tasmota/ullu1/cmnd/Fade"]
Type dimmer : fadeTime "fadeTime"
[stateTopic="tasmota/ullu1/stat/RESULT",
transformationPattern="REGEX:(.*Speed.*)∩JSONPATH:$.Speed",
commandTopic="tasmota/ullu1/cmnd/Speed", min=0, max=6, step=1]
Type colorHSB : color "color"
[stateTopic="tasmota/ullu1/RESULT",
transformationPattern="REGEX:(.*HSBColor.*)∩JSONPATH:$.HSBColor",
commandTopic="tasmota/ullu1/cmnd/HSBColor" ]
}
Thing topic ullu2 "ullu2" {
Channels:
Type switch : power "power"
[stateTopic="tasmota/ullu2/stat/RESULT",
transformationPattern="REGEX:(.*POWER.*)∩JSONPATH:$.POWER",
commandTopic="tasmota/ullu2/cmnd/POWER"]
Type dimmer : brightness "brightness"
[stateTopic="tasmota/ullu2/stat/RESULT",
transformationPattern="REGEX:(.*Dimmer.*)∩JSONPATH:$.Dimmer",
commandTopic="tasmota/ullu2/cmnd/Dimmer", min=0, max=100, step=1]
Type switch : fade "fade"
[stateTopic="tasmota/ullu2/stat/RESULT",
transformationPattern="REGEX:(.*Fade.*)∩JSONPATH:$.Fade",
commandTopic="tasmota/ullu2/cmnd/Fade"]
Type dimmer : fadeTime "fadeTime"
[stateTopic="tasmota/ullu2/stat/RESULT",
transformationPattern="REGEX:(.*Speed.*)∩JSONPATH:$.Speed",
commandTopic="tasmota/ullu2/cmnd/Speed", min=0, max=6, step=1]
Type colorHSB : color "color"
[stateTopic="tasmota/ullu2/RESULT",
transformationPattern="REGEX:(.*HSBColor.*)∩JSONPATH:$.HSBColor",
commandTopic="tasmota/ullu2/cmnd/HSBColor" ]
}
Thing topic ullu3 "ullu3" {
Channels:
Type switch : power "power"
[stateTopic="tasmota/ullu3/stat/RESULT",
transformationPattern="REGEX:(.*POWER.*)∩JSONPATH:$.POWER",
commandTopic="tasmota/ullu3/cmnd/POWER"]
Type dimmer : brightness "brightness"
[stateTopic="tasmota/ullu3/stat/RESULT",
transformationPattern="REGEX:(.*Dimmer.*)∩JSONPATH:$.Dimmer",
commandTopic="tasmota/ullu3/cmnd/Dimmer", min=0, max=100, step=1]
Type switch : fade "fade"
[stateTopic="tasmota/ullu3/stat/RESULT",
transformationPattern="REGEX:(.*Fade.*)∩JSONPATH:$.Fade",
commandTopic="tasmota/ullu3/cmnd/Fade"]
Type dimmer : fadeTime "fadeTime"
[stateTopic="tasmota/ullu3/stat/RESULT",
transformationPattern="REGEX:(.*Speed.*)∩JSONPATH:$.Speed",
commandTopic="tasmota/ullu3/cmnd/Speed", min=0, max=6, step=1]
Type colorHSB : color "color"
[stateTopic="tasmota/ullu3/RESULT",
transformationPattern="REGEX:(.*HSBColor.*)∩JSONPATH:$.HSBColor",
commandTopic="tasmota/ullu3/cmnd/HSBColor" ]
}
Thing topic ullu4 "ullu4" {
Channels:
Type switch : power "power"
[stateTopic="tasmota/ullu4/stat/RESULT",
transformationPattern="REGEX:(.*POWER.*)∩JSONPATH:$.POWER",
commandTopic="tasmota/ullu4/cmnd/POWER"]
Type dimmer : brightness "brightness"
[stateTopic="tasmota/ullu4/stat/RESULT",
transformationPattern="REGEX:(.*Dimmer.*)∩JSONPATH:$.Dimmer",
commandTopic="tasmota/ullu4/cmnd/Dimmer", min=0, max=100, step=1]
Type switch : fade "fade"
[stateTopic="tasmota/ullu4/stat/RESULT",
transformationPattern="REGEX:(.*Fade.*)∩JSONPATH:$.Fade",
commandTopic="tasmota/ullu4/cmnd/Fade"]
Type dimmer : fadeTime "fadeTime"
[stateTopic="tasmota/ullu4/stat/RESULT",
transformationPattern="REGEX:(.*Speed.*)∩JSONPATH:$.Speed",
commandTopic="tasmota/ullu4/cmnd/Speed", min=0, max=6, step=1]
Type colorHSB : color "color"
[stateTopic="tasmota/ullu4/RESULT",
transformationPattern="REGEX:(.*HSBColor.*)∩JSONPATH:$.HSBColor",
commandTopic="tasmota/ullu4/cmnd/HSBColor" ]
}
}
The 4 thing definitions are copies of each other with only the name changed.
So now I do the ‘critical interaction’ for all four of them, one by one from the command line:
[dp@star ~]$ mosquitto_pub -h kranich.intern -u dp -P secret -t 'tasmota/ullu1/cmnd/Speed' -m '1'
[dp@star ~]$ mosquitto_pub -h kranich.intern -u dp -P secret -t 'tasmota/ullu2/cmnd/Speed' -m '2'
[dp@star ~]$ mosquitto_pub -h kranich.intern -u dp -P secret -t 'tasmota/ullu3/cmnd/Speed' -m '3'
[dp@star ~]$ mosquitto_pub -h kranich.intern -u dp -P secret -t 'tasmota/ullu4/cmnd/Speed' -m '4'
You will notice how I use the value of the parameter to match the surname of the thing in order to help clarify which action gives which results. Valid values for that parameter go from 0 to 40.
Now, how does that chat look on the mqtt bus?
30.07.2020 19:55:16 tasmota/ullu1/cmnd/Speed 1
30.07.2020 19:55:16 tasmota/ullu1/stat/RESULT {"Speed":1}
30.07.2020 19:55:28 tasmota/ullu2/cmnd/Speed 2
30.07.2020 19:55:28 tasmota/ullu2/stat/RESULT {"Speed":2}
30.07.2020 19:55:38 tasmota/ullu3/cmnd/Speed 3
30.07.2020 19:55:38 tasmota/ullu3/stat/RESULT {"Speed":3}
30.07.2020 19:55:46 tasmota/ullu4/cmnd/Speed 4
30.07.2020 19:55:46 tasmota/ullu4/stat/RESULT {"Speed":4}
4 very similar pairs of lines, the first line the message I sent, each of the tasmotae receives it, sets the new value and finally reports success with the new setting on the RESULT path.
That’s the naughty bit cause tasmota reports all sorts of name/value pairs and lists of them or singles under the same path. Speed and Fade are reported as singles while POWER, Dimmer and HSBColor are reported in a list next to each other.
But that is well known and for that the regex and jsonpath expression are chained together in the things file above.
So how does all that reflect on the openhab.log?
'
2020-07-30 19:55:16.162 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.Dimmer' in '{"Speed":1}'
2020-07-30 19:55:16.166 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.POWER' in '{"Speed":1}'
2020-07-30 19:55:28.709 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.POWER' in '{"Speed":2}'
2020-07-30 19:55:28.713 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.Dimmer' in '{"Speed":2}'
2020-07-30 19:55:46.458 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.POWER' in '{"Speed":4}'
2020-07-30 19:55:46.460 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.Dimmer' in '{"Speed":4}'
4 commands. 1, 2, 4 lead to an error that’s reported in the log. What happened to #3 and made her fail to fail?
That’s sort of unfair, isn’t it - the others found a way to drop out and she has to work?
And another bit: Why no warnings from fade and color?
Glad for any pointers,
best regards