I have a question regarding JSONPATH transformation pattern applied in a MQTT Thing definition.
This is the enviroment I’m referring to:
my.things file
Bridge mqtt:broker:mymqtt [
host="x.x.x.x",
port="1883",
secure=false,
qos=0,
clientID="openhab2",
keep_alive_time=30000,
reconnect_time=60000,
username="xxxxxx",
password="xxxxxx"
]
{
Thing topic homeRouterInfo "Router" @ "MQTT" {
Channels:
Type string : DEVSSTATUS "Presenza Dev" [
stateTopic="RTR/RTRINFO",
transformationPattern="JSONPATH:$.devs"
]
}
}
my.items file
String presDevCheck "Stato globale presenza device" { channel="mqtt:topic:homeRouterInfo:DEVSSTATUS" }`
my.rules file
rule "Risposta presenza device"
when
Item presDevCheck changed
then
val String dev1 = transform("JSONPATH", "$.iPhonex1", presDevCheck.state)
val String dev2 = transform("JSONPATH", "$.iPhonex2", presDevCheck.state)
end
Given the following json published by the topic RTR/RTRINFO:
{"wanstatus": "up", "tx_bw": 1.4698666666666667, "devs": {"iPhonex1": "OFF", "iPhonex2": "OFF"}, "rx_bw": 0.7141333333333333, "wanuptime": "1 day, 12:16, 31 secs", "version": "chkrouterV4", "wanip": "x.x.x.x", "elapsed": 0.1884160041809082, "updateint": 15}`
value of item presDevCheck is the following:
{iPhonex1=OFF, iPhonex2=OFF}
I would have expected colons in place of equal signs:
{iPhonex1:OFF, iPhonex2:OFF}
so that the above rule could work properly, assigning the string OFF
to both dev1 and dev2.
Instead the the rule assigns the string {iPhoneRG=OFF, iPhoneAB=OFF}
to both dev1 and dev2.
I know how to correct the rule so that it could work right, but my question is if the above depicted behavior is correct for the jsonpath transformation pattern applied in the thing definition or not.