# JSONPATH transformations on nodejs-poolController not working via MQTT

**URL:** <https://community.openhab.org/t/jsonpath-transformations-on-nodejs-poolcontroller-not-working-via-mqtt/137951>\
**Category:** Items & Sitemaps\
**Tags:** mqtt, jsonpath\
**Created:** [August 7, 2022, 10:02pm UTC](https://community.openhab.org/t/jsonpath-transformations-on-nodejs-poolcontroller-not-working-via-mqtt/137951 "2022-08-07T22:02:19Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![fifo](https://community.openhab.org/letter_avatar_proxy/v4/letter/f/e19adc/32.png) [@fifo](https://community.openhab.org/u/fifo)\
**Post date:** [August 7, 2022, 10:02pm UTC](https://community.openhab.org/t/jsonpath-transformations-on-nodejs-poolcontroller-not-working-via-mqtt/137951/1 "2022-08-07T22:02:19Z")

</div>

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.

 ![Pool Pump 01](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/1/5/1585ec9ba8b4212423b08dfc8dfeca399aaed4a9.png)

This is the section from my mqtt.things file.

```csv
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.

```csv
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

```php

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.

 ![MQTT 01](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/6/7/674a91dd82c36eb6cf611d2cef95ddfdff9d9b36.png)

---

<div class="post-metadata">

**Author:** ![Udo\_Hartmann](https://community.openhab.org/user_avatar/community.openhab.org/udo_hartmann/32/70871_2.png) [@Udo\_Hartmann](https://community.openhab.org/u/Udo_Hartmann)\
**Post date:** [August 7, 2022, 11:57pm UTC](https://community.openhab.org/t/jsonpath-transformations-on-nodejs-poolcontroller-not-working-via-mqtt/137951/2 "2022-08-07T23:57:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fifo](https://community.openhab.org/letter_avatar_proxy/v4/letter/f/e19adc/32.png) [@fifo](https://community.openhab.org/u/fifo)\
**Post date:** [August 8, 2022, 1:03am UTC](https://community.openhab.org/t/jsonpath-transformations-on-nodejs-poolcontroller-not-working-via-mqtt/137951/3 "2022-08-08T01:03:13Z")

</div>

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} "

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

```

---

<div class="post-metadata">

**Author:** ![fifo](https://community.openhab.org/letter_avatar_proxy/v4/letter/f/e19adc/32.png) [@fifo](https://community.openhab.org/u/fifo)\
**Post date:** [August 8, 2022, 1:46am UTC](https://community.openhab.org/t/jsonpath-transformations-on-nodejs-poolcontroller-not-working-via-mqtt/137951/4 "2022-08-08T01:46:12Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![Udo\_Hartmann](https://community.openhab.org/user_avatar/community.openhab.org/udo_hartmann/32/70871_2.png) [@Udo\_Hartmann](https://community.openhab.org/u/Udo_Hartmann)\
**Post date:** [August 8, 2022, 8:05am UTC](https://community.openhab.org/t/jsonpath-transformations-on-nodejs-poolcontroller-not-working-via-mqtt/137951/5 "2022-08-08T08:05:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fifo](https://community.openhab.org/letter_avatar_proxy/v4/letter/f/e19adc/32.png) [@fifo](https://community.openhab.org/u/fifo)\
**Post date:** [August 8, 2022, 12:06pm UTC](https://community.openhab.org/t/jsonpath-transformations-on-nodejs-poolcontroller-not-working-via-mqtt/137951/6 "2022-08-08T12:06:47Z")

</div>

Yes that did the trick 🙂 Thanks again!

---

<div class="post-metadata">

**Author:** ![hafniumzinc](https://community.openhab.org/letter_avatar_proxy/v4/letter/h/b9bd4f/32.png) [@hafniumzinc](https://community.openhab.org/u/hafniumzinc)\
**Post date:** [August 8, 2022, 12:39pm UTC](https://community.openhab.org/t/jsonpath-transformations-on-nodejs-poolcontroller-not-working-via-mqtt/137951/7 "2022-08-08T12:39:37Z")

</div>

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

> [@OH2 MQTT standalone server with text file config](https://community.openhab.org/t/oh2-mqtt-standalone-server-with-text-file-config/110330/4):
>
> This is for Things files. For some, restarting openHAB is a huge pain in the backside. Perhaps try the following first: Deliberately corrupt your Things file, by making a deliberate syntactical error: remove a { somewhere. Save the corrupted Things file. If you’re watching the logs you will see openHAB complain and unload all the Things defined in that file. Un-corrupt the Things file by fixing the syntax: put the { back. Save the fixed Things file. If you’re watching the logs you’ll see all …

---

<div class="post-metadata">

**Author:** ![Udo\_Hartmann](https://community.openhab.org/user_avatar/community.openhab.org/udo_hartmann/32/70871_2.png) [@Udo\_Hartmann](https://community.openhab.org/u/Udo_Hartmann)\
**Post date:** [August 8, 2022, 11:35pm UTC](https://community.openhab.org/t/jsonpath-transformations-on-nodejs-poolcontroller-not-working-via-mqtt/137951/8 "2022-08-08T23:35:45Z")

</div>

It’s also possible to restart the mqtt bundle.

---

<div class="post-metadata">

**Author:** ![fifo](https://community.openhab.org/letter_avatar_proxy/v4/letter/f/e19adc/32.png) [@fifo](https://community.openhab.org/u/fifo)\
**Post date:** [August 11, 2022, 2:36am UTC](https://community.openhab.org/t/jsonpath-transformations-on-nodejs-poolcontroller-not-working-via-mqtt/137951/9 "2022-08-11T02:36:53Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![Udo\_Hartmann](https://community.openhab.org/user_avatar/community.openhab.org/udo_hartmann/32/70871_2.png) [@Udo\_Hartmann](https://community.openhab.org/u/Udo_Hartmann)\
**Post date:** [August 11, 2022, 6:21pm UTC](https://community.openhab.org/t/jsonpath-transformations-on-nodejs-poolcontroller-not-working-via-mqtt/137951/10 "2022-08-11T18:21:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fifo](https://community.openhab.org/letter_avatar_proxy/v4/letter/f/e19adc/32.png) [@fifo](https://community.openhab.org/u/fifo)\
**Post date:** [August 12, 2022, 12:47am UTC](https://community.openhab.org/t/jsonpath-transformations-on-nodejs-poolcontroller-not-working-via-mqtt/137951/11 "2022-08-12T00:47:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rossko57](https://community.openhab.org/user_avatar/community.openhab.org/rossko57/32/70263_2.png) [@rossko57](https://community.openhab.org/u/rossko57)\
**Post date:** [August 12, 2022, 11:18am UTC](https://community.openhab.org/t/jsonpath-transformations-on-nodejs-poolcontroller-not-working-via-mqtt/137951/12 "2022-08-12T11:18:28Z")

</div>

You might this helpful to understand state/command workflow

> [@Autoupdate - a primer](https://community.openhab.org/t/autoupdate-a-primer/101509):
>
> I’ve found myself having to investigate and/or explain some of the features of autoupdate over time, and thought an in-depth view would be helpful. These notes apply to openHAB version 2.5 Overview Autoupdate is primarily a “speed up” feature for openHAB Items. Mostly we can ignore it, but sometimes you may get an unwanted or unexpected effect, or you may wish to exercise more control. To fully understand autoupdate, we must understand the difference between command and state of Items. If w…

---

<div class="post-metadata">

**Author:** ![fifo](https://community.openhab.org/letter_avatar_proxy/v4/letter/f/e19adc/32.png) [@fifo](https://community.openhab.org/u/fifo)\
**Post date:** [August 12, 2022, 12:11pm UTC](https://community.openhab.org/t/jsonpath-transformations-on-nodejs-poolcontroller-not-working-via-mqtt/137951/13 "2022-08-12T12:11:40Z")

</div>

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.
