[SOLVED] Sonoff POW openhab2 integration

I do not have aRF-Bridge, but I found this snippet (and saved it, maybe I will get a Bridge in the future)

        Type switch : button1       "Button 1"             [ stateTopic="stat/sonoff-rf/RESULT", commandTopic="cmnd/sonoff-rf/RFKEY1", transformationPattern="JSONPATH:$.RfKey1" ]

As you can see it’s a “little” bit different :wink:

Partly :frowning:
I know there has to be a match. And there is a match with the RfKey (without 1) when the RF Bridde receive the EEEEEE message.
It also returns the “None” allright.

But I fail to understand, why JSONPATH returns a warning… It seems like it (JSONPATH) continues to the four buttonchannels, and somehow mix up the RfKey with the RfKey1 (or any simular number).
I have 4 keys learned in the Bridge from my Key fob. They´re learned on RfKey1 - Rfkey4.
So JSONPATH should dicover the match fine then…

The JSONPATH warning is gone, when I remove the four Switch (buttons) channels from my thing file.

There is… I made a small typo… But Rfkey1 is still the same. And after correcting the typo, I still got the JSONPATH warning :slight_smile:
This is how it looks right now, (though I have disabled the button channels).

   Thing topic sonoffbm "RF Bridge" @ "second Room"    {
    Channels: 
        Type string : reachable     "Reachable"            [ stateTopic="tele/sonoffbm/LWT" ]
        Type string : recieveddata  "Received Data"        [ stateTopic="tele/sonoffbm/RESULT", transformationPattern="JSONPATH:$.RfReceived.Data"]
        Type string : recievedsync  "Received Sync"        [ stateTopic="tele/sonoffbm/RESULT", transformationPattern="JSONPATH:$.RfReceived.Sync"]
        Type string : recievedlow   "Received Low"         [ stateTopic="tele/sonoffbm/RESULT", transformationPattern="JSONPATH:$.RfReceived.Low"]
        Type string : recievedhigh  "Received High"        [ stateTopic="tele/sonoffbm/RESULT", transformationPattern="JSONPATH:$.RfReceived.High"]
        Type string : recievedrfkey "Received RfKey"       [ stateTopic="tele/sonoffbm/RESULT", transformationPattern="JSONPATH:$.RfReceived.RfKey"]
//        Type switch : button1       "Button 1"             [ stateTopic="tele/sonoffbm/RESULT", commandTopic="cmnd/sonoffbm/RFKEY1", transformationPattern="JSONPATH:$.RfKey1" ]
//        Type switch : button2       "Button 2"             [ stateTopic="tele/sonoffbm/RESULT", commandTopic="cmnd/sonoffbm/RFKEY2", transformationPattern="JSONPATH:$.RfKey2" ]
//        Type switch : button3       "Button 3"             [ stateTopic="tele/sonoffbm/RESULT", commandTopic="cmnd/sonoffbm/RFKEY3", transformationPattern="JSONPATH:$.RfKey3" ]
//        Type switch : button4       "Button 4"             [ stateTopic="tele/sonoffbm/RESULT", commandTopic="cmnd/sonoffbm/RFKEY4", transformationPattern="JSONPATH:$.RfKey4" ]
        Type number : rssi          "WiFi Signal Strength" [ stateTopic="tele/sonoffbm/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
    }

It also dont explain howcome JSONPATH gives a warning when the Brigde sends the EEEEEEE message. (RfKey)

12:59:58 MQT: tele/sonoffbm/RESULT = {"RfReceived":{"Sync":7050,"Low":250,"High":690,"Data":"EEEEEE","RfKey":"None"}}

Yep. The binding gets a bunch of data (it happens to be JSON). The binding works through every channel for that topic Thing looking for things to do. (EDIT - where the stateTopic matches of course)
In your case, each channel has its own JSONPATH to run. So, every different JSONPATH for every channel is run on the incoming data.

If the JSONPATH looks for “banana” and it is not present in the data packet, it will fail.

Thats what I thought as well… But how come I get the JSON warning when receiving the “RfKey” then? It is there, its defined in the String channel (above the buttons).

Here is the full example:

    Thing topic sonoffrf "RF Bridge" @ "Yet Another Room" {
        Type string : reachable     "Reachable"            [ stateTopic="tele/sonoff-rf/LWT" ]
        Type string : recieveddata  "Received Data"        [ stateTopic="tele/sonoff-rf/RESULT", transformationPattern="JSONPATH:$.RfReceived.Data"]
        Type string : recievedsync  "Received Sync"        [ stateTopic="tele/sonoff-rf/RESULT", transformationPattern="JSONPATH:$.RfReceived.Sync"]
        Type string : recievedlow   "Received Low"         [ stateTopic="tele/sonoff-rf/RESULT", transformationPattern="JSONPATH:$.RfReceived.Low"]
        Type string : recievedhigh  "Received High"        [ stateTopic="tele/sonoff-rf/RESULT", transformationPattern="JSONPATH:$.RfReceived.High"]
        Type string : recievedrfkey "Received RfKey"       [ stateTopic="tele/sonoff-rf/RESULT", transformationPattern="JSONPATH:$.RfReceived.RfKey"]
        Type switch : button1       "Button 1"             [ stateTopic="stat/sonoff-rf/RESULT", commandTopic="cmnd/sonoff-rf/RFKEY1", transformationPattern="JSONPATH:$.RfKey1" ]
        Type switch : button16      "Button 16"            [ stateTopic="stat/sonoff-rf/RESULT", commandTopic="cmnd/sonoff-rf/RFKEY16", transformationPattern="JSONPATH:$.RfKey16" ]
        Type number : rssi          "WiFi Signal Strength" [ stateTopic="tele/sonoff-rf/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
    }

The little difference is the keyword “stat” in the topic instead of “tele” could this make the difference ?

1 Like

“RfKey” in the data is not equal to “RfKey1” being sought.

Arrgh, damit… Didnt see that one… Nice catch!
I´ll give it a try…

You missed my second mqtt message:

13:03:09 MQT: tele/sonoffbm/RESULT = {"RfReceived":{"Sync":7080,"Low":240,"High":700,"Data":"EEEEEE","RfKey":"None"}}

Notic the “RfKey” (without any number).
This channel is defined like this:

        Type string : recievedrfkey "Received RfKey"       [ stateTopic="tele/sonoffbm/RESULT", transformationPattern="JSONPATH:$.RfReceived.RfKey"]

This should not return a JSON warning, but it does… Otherweise I simply dont get it.

But I believe Fibu found the reason… Ofcouse the buttons would need to be stats, otherweise the bindings thinks it´s receiving the same RfKey again. (at least this is my guess).

EDIT - Fibu-freak seems to be right… Changing the buttons channels to stat solved the problem… Sorry I totally missed that stupid cut&paste error… :frowning:

POW2 MQTT integration