MQTT and NSPanel with Tasmota firmware. I can't get it to work

I have mosquitto running and tested with MQTTX and can send commands to the NSPanel and is working


I want to send to same command from OH3
I installed a Generic MQTT Thing and added a thing

This gives me in the rules file

String SendAString "Send astring" {channel="mqtt:topic:NAS:GenericMQTTThing:SendAString"}

Is this correct ?
As result I get from the NSPanel console

00:00:17.411 MQT: NSPanelKamer/RESULT = {"NSPSend":"Done"}
00:00:17.438 NSP: Received Raw = bytes('55AA000B007B226572726F72223A327DD3E600')
00:00:17.447 MQT: NSPanelKamer/RESULT = {"NSPanel":{"error":2}}

but when I do the same with MQTTX I get

00:02:31.495 NSP: Sent = {"temperature":55}
00:02:31.517 MQT: NSPanelKamer/RESULT = {"NSPSend":"Done"}

What do I wrong?

Your command and state topic should be different leave the state topic empty.

What are you sending to the string item?

I had a syntax issue in the string. The one below is working

    SendAString.sendCommand ('{"temperature":33}')

I created a receive string and get also feedback.


I can receive for instance a messages like below.
Is this the right way to communicate with a NSPanel?
Are there utilities to process the received string in a rule to react on it?

{"NSPanel":{"ctype":"group","id":"2","params":{"switches":[{"switch":"on","outlet":0},{"switch":"off","outlet":1}]}}}

Create another string channel with state topic NSPanelKamer/RESULT

Thanks is working fine.
Is JSONPath Transformation the way to do this?
or should I go for a totally different approach ?

You could either have one “result” channel and then deal with the different values in a rule, or have separate channels + items for each value you want to know about, e.g. temperature, etc. In this case you’d use json tranformation to extract the relevant data inside the RESULT payload.

As @JimT suggests there is more than one way to do it.

I do not have access to my openHAB environment for testing now so the following is just a guide.

The correct way is the one that works every time and if you change something it will adapt.

You can defiantly and should use JSON path transformation.
First install the JSON and REGEX transformation pattern if you have not already.

Setup a channel for each item you want to control. Lets look at one switch.

Example from doc is

Type switch : power [ stateTopic="stat/bedroom1-switch/RESULT", transformationPattern="REGEX:(.*POWER.*)∩JSONPATH:$.POWER", commandTopic="cmnd/bedroom1-switch/POWER" ]

Now to adapt it to what you want to achieve break it down to parts

Type switch : power [
 stateTopic="stat/bedroom1-switch/RESULT" // You know this one is  NSPanelKamer/RESULT
 transformationPattern="REGEX:(.*POWER.*)∩JSONPATH:$.POWER", // This is magic

To make the magic happen properly with REGEX I need more result examples. If tasmota sends a message that dose not have what we are looking for then it will log an error in openHAB logs so you can filter out the results we don’t want.

∩ is not n its an intersection if we want to chain transformations.

JSONPATH is what you asked about using and it is fantastic if you know how to use it.

In the channel you want on or off :slight_smile:

//your example result json
{
   "NSPanel":{
      "ctype":"group",
      "id":"2",
      "params":{
         "switches":[
            {
               "switch":"on",
               "outlet":0
            },
            {
               "switch":"off",
               "outlet":1
            }
         ]
      }
   }
}
transformationPattern="REGEX:(.*switches.*)∩JSONPATH:$.NSPanel.params.switches[?(@.outlet == 0)].switch"
transformationPattern="REGEX:(.*switches.*)∩JSONPATH:$.NSPanel.params.switches[?(@.outlet == 1)].switch"
//REGEX if the result has the string "switches" in it then we want it so send it to next transformation
//JSONPATH goto NSPanel.params.switches and look for outlet 0 then send me the value of switch
As the online jayway validator is down I cant 100% test this 

When this dosn’t work look in the openHAB logs to see why.