JSONPATH transformations on nodejs-poolController not working via MQTT

I am having an issue obtaining a specific value from an item that gets its value via MQTT from nodejs poolController. Most of the items work with no issue as seen below. When I come to the status items, for example, the values are shown as follows. If you see below the two items that report status report back with a JSON type string. I have tried a few different ways to get the value of “desc” specifically but nothing I have tried works. If I am reading the documentation correctly, it seems that all I would need at the end of my existing JSON transform line is to append .desc to get that specific value but it doesn’t seem to do anything. No change I make to the things file as shown below does anything as if the transform is not being recognized. I have confirmed that JSONPATH is installed.

This is the section from my mqtt.things file.

Thing mqtt:topic:aquarite (mqtt:broker:mosquitto) @ "Pool Controller" {
Channels:
Type string : power "Aquartie Chlorinator Power [%s]" [ stateTopic="nixie-singlebody/state/chlorinators/1/aquaritet15", commandTopic="nixie-singlebody/state/chlorinators/1/aquaritet15", transformationPattern="JSONPATH:$.isOn" ]
Type number : output "AquaRite Output [%s]" [ stateTopic="nixie-singlebody/state/chlorinators/1/aquaritet15/currentOutput", commandTopic="nixie-singlebody/state/chlorinators/1/aquaritet15/currentOutput", transformationPattern="JSONPATH:$.currentOutput" ]
Type number : setpoint "AquaRite Output [%s]" [ stateTopic="nixie-singlebody/state/chlorinators/1/aquaritet15/poolSetpoint", commandTopic="nixie-singlebody/state/chlorinators/1/aquaritet15/poolSetpoint", transformationPattern="JSONPATH:$.poolSetpoint" ]
Type string : status "AquaRite Output [%s]" [ stateTopic="nixie-singlebody/state/chlorinators/1/aquaritet15/status", commandTopic="nixie-singlebody/state/chlorinators/1/aquaritet15/status", transformationPattern="JSONPATH:$.status.desc" ]
Type string : superchlorinate "AquaRite Output [%s]" [ stateTopic="nixie-singlebody/state/chlorinators/1/aquaritet15/superChlor", commandTopic="nixie-singlebody/state/chlorinators/1/aquaritet15/superChlor" , transformationPattern="JSONPATH:$.superChlor" ]
Type number : superchlorinatehours "AquaRite SuperChlorinate Hours [%s]" [ stateTopic="nixie-singlebody/state/chlorinators/1/aquaritet15/superChlorHours", commandTopic="nixie-singlebody/state/chlorinators/1/aquaritet15/superChlorHours", transformationPattern="JSONPATH:$.superChlorHours" ]
Type number : saltlevel "AquaRite Salt Level [%s]" [ stateTopic="nixie-singlebody/state/chlorinators/1/aquaritet15/saltLevel", commandTopic="nixie-singlebody/state/chlorinators/1/aquaritet15/saltLevel", transformationPattern="JSONPATH:$.saltLevel" ]
Type number : targetoutput "AquaRite Target Output [%s]" [ stateTopic="nixie-singlebody/state/chlorinators/1/aquaritet15/targetOutput", commandTopic="nixie-singlebody/state/chlorinators/1/aquaritet15/targetOutput" , transformationPattern="JSONPATH:$.targetOutput" ]
}

Here is the section of my mqtt.items.

String AquaRiteT15Chlorinator_Power "Aquartie Chlorinator Power [%s]" <pool> (gAquaRite) {channel="mqtt:topic:aquarite:power"}

Number AquaRiteT15Chlorinator_CurrentOutput "AquaRite Current Output [%s]" <pool> (gAquaRite) {channel="mqtt:topic:aquarite:output"}

Number AquaRiteT15Chlorinator_Setpoint "AquaRite Setpoint [%s]" <pool> (gAquaRite) {channel="mqtt:topic:aquarite:setpoint"}

String AquaRiteT15Chlorinator_SuperChlorinate "AquaRite Super Chlorinate [%s]" <pool> (gAquaRite) {channel="mqtt:topic:aquarite:superchlorinate"}

Number AquaRiteT15Chlorinator_SuperChlorinateHours "AquaRite SuperChlorinate Hours [%s]" <pool> (gAquaRite) {channel="mqtt:topic:aquarite:superchlorinatehours"}

Number AquaRiteT15Chlorinator_SaltLevel "AquaRite Salt Level [%s]" <pool> (gAquaRite) {channel="mqtt:topic:aquarite:saltlevel"}

Number AquaRiteT15Chlorinator_TargetOutput "AquaRite Target Output [%s]" <pool> (gAquaRite) {channel="mqtt:topic:aquarite:targetoutput"}

String AquaRiteT15Chlorinator_CurrentStatus "AquaRite Current Status [%s]" <pool> (gAquaRite) {channel="mqtt:topic:aquarite:status"}

and finally my sitemap


Text item=AquaRiteT15Chlorinator_Power
Setpoint item=AquaRiteT15Chlorinator_Setpoint minValue=00 maxValue=100 step=1
Text item=AquaRiteT15Chlorinator_CurrentOutput
Text item=AquaRiteT15Chlorinator_CurrentStatus
Switch item=AquaRiteT15Chlorinator_SuperChlorinate
Setpoint item=AquaRiteT15Chlorinator_SuperChlorinateHours minValue=00 maxValue=24 step=1
Text item=AquaRiteT15Chlorinator_SaltLevel
Text item=AquaRiteT15Chlorinator_TargetOutput
Text label=""

One of the items I have an issue with is “AquaRiteT15Chlorinator_CurrentStatus” which is the one that says “AquaRite Current Status” on the sitemap picture above. I simply want to show the desc which says “Ok” and not the entire string “{val=0, name=ok, desk=Ok}”

Finally, this is what it looks like in my MQTT explorer. The one I highlighted is the one that I can’t get the value from.

As this is read only, please don’t set the commandTopic.
Furthermore, commandTopic and stateTopic must not be the same topic. (i.e. it is not allowed)
mqtt topics are always oneway, either read or write, but never both directions.

Udo thanks for that tip. I was not aware of that. I did try without setting the command since as you mentioned this is read-only but that did not make a difference, I still see the full string "
{val=0, name=ok, desc=Ok} "

Type string : status "AquaRite Output [%s]" [ stateTopic="nixie-singlebody/state/chlorinators/1/aquaritet15/status", transformationPattern="JSONPATH:$.status.desc" ]

@Udo_Hartmann never mind that last comment. I made changes to both of my status things for the chlorinator and the pump. The one for the chlorinator is now showing correctly. For some reason, the pump is not but that might be something cached. The clarification you made above seems to have resolved my issue. Thanks! Ill mark this resolved.

As you did the configuration via text files… did you restart openHAB?

Yes that did the trick :slight_smile: Thanks again!

1 Like

I get impatient waiting for a restart, so I do this to force the Thing to properly refresh:

It’s also possible to restart the mqtt bundle.

@Udo_Hartmann I had noticed yesterday that the items I left with only the command topic were not working and were staying NULLl. If I add both the command and state topics as I had before it works as expected. Just thought I would state that in case someone runs into the same issue. The read only items I left with just the state command and all seems ok. When I look at the documentation, I noticed they have examples with both state and command separated by commas. Am I missing something here?

Please don’t.

You’ll need two different topics, one for command, another for state.

Using only command topic will result in a write only channel (i.e. no state), while using only stateTopic will result in a read only channel i.e. no commands).
Both options are valid. If using both command and state, it will result in a read/write channel.
The Item will copy the channel, so it’s either write only, read only or read/write.

If you want a write only channel, the Item should be configured with autoupdate=true. This way openHAB will “guess” the state.

Ok that makes sense. I will give that a try later tonight. Thanks again!

You might this helpful to understand state/command workflow

1 Like

Thanks @rossko57 I will take a look later tonight. Tried looking into @Udo_Hartmann suggestion last night but can’t figure out what the command should be so I am reaching out for some direction on the node-js poolController GitHub page as well.