[SOLVED] Sonoff POW openhab2 integration

I guess, had there been a section “Addons-transformation” it would have come to my mind to look under it - but this is what my “Add-ons”-Screen looks like:

Any idea why there is no “transformation”-section?

Do you by chance have simple mode turns on?

Yes, simple mode was turned on - but with it turned off, I still do only see “BINDINGS”, “MISC” and “VOICE” in the add-ons-section

What package did you choose when you first set up openHAB? This is the big icon you selected the very first time you opened the dashboard and you had choices like “Demo”, “Minimal”, “Basic” it the like.

I bet you code one if the “simpler” packages in which case all the transformations were installed automatically for you.

You can bet that I chose one of the simpler packages. To be honest, I do not remember which on I actually chose. And I do not know how to find out if either the JSON-transformation is installed or which package I actually chose in the dashboard.

I came to the comclusion, it might not be installed because I have the same “NaN”-problem like the threadstarter and I did not see the installed package anywhere…

It seems that sometimes it takes a bit more to get that to “stick” - not directly related, but probably worth following this process -

It has been as while, due to a vacation in Creeth, but I managed to get my Sonoff devices flashed with Tasmota…
Now I´m bit stuck on whats next to do…
I suspect I need a MQTT broker. But which one to use (I think I reacall mosquito is build-in openhabian, right?).
Then I need a binding in openhab… but which one to use… When I enter the addons, I see several mqtt binding.

My Sonoff devices is one RF Bridge and one Pow R2. Both are flashed and running Tasmota fine.

Yes, openHABian will install Mosquitto. I don’t think it get’s installed by default so you will want to go through openhabian-config to get it installed. Mosquitto is what most of us use I believe.

If you want a simpler to set up and use broker, OH now comes with Moquette which is an embedded broker you can install from the MISC tab in PaperUI. But this is a very simple broker lacking many of the features and capabilities of Mosquitto.

image

Docs MQTT - Bindings | openHAB

Yes, I just tried the embedded one… I have no idea what I´m doing or how to configure the manual things file when using this one… I guess I´ll have to try the mosquitto one and follow the examples above.

If you look at the docs (addons) and write mqtt in the search button, there are several (addons) which is named mqtt.
From paperUI there only seem to be one though.

You should do yourself a favor and go read the HiveMQ MQTT Tutorial to give yourself a grounding in how it works. It will save you a lot of effort in the long run. Then a lot of the settings and ways the OH presents MQTT to you will make more sense.

That’s a quirk that I think has an issue set up but hasn’t found a solution. The MQTT docs are split into many pages and each page shows up as a separate entry when you search.

I get the basic idea of MQTT… What I seem to be missing is how to set it up regarding openhab, (using manual things files).

have a look onto this documentation page (it is for the 2.4 version! not the latest!) it cotains an example for trhe file setup at the end!

I cant get it to work with the embedded mqtt broker.
Insted I tried to install mosquitto from openhabian-config. But the installation fails with this, and I have no idea why or where to find a solution:

2019-09-10_15:47:09_CEST [openHABian] Setting up the MQTT broker Eclipse Mosquitto...
$ apt-get update
Get:1 http://archive.raspberrypi.org/debian stretch InRelease [25.4 kB]
Hit:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease
Ign:3 https://dl.bintray.com/openhab/apt-repo2 testing InRelease
Get:4 https://dl.bintray.com/openhab/apt-repo2 testing Release [6,053 B]
Hit:5 https://repos.influxdata.com/debian stretch InRelease
Ign:6 https://dl.bintray.com/openhab/apt-repo2 testing Release.gpg
Hit:7 https://packages.grafana.com/oss/deb stable InRelease
Reading package lists... Done
E: The repository 'https://dl.bintray.com/openhab/apt-repo2 testing Release' is no longer signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
FAILED
[15:47:31] openhabian@openHABianPi:~$

I got it installed using:

sudo apt-get -f install mosquitto

EDIT - Still got problems though… Broker is online, but Thing doesn´t respond…

Please post how you have setup the thing and how your sonoff MQTT settings are (topic and full topic).

I just got it to work… I believe there is a error in the binding, (or at least a issue/cause I wasn´t aware of).

This is my previous .things file which fail to get the thing online:

Bridge mqtt:broker:mosquitto "mosquitto" [ host="10.4.28.200", port=1883, secure=false, username="openhabian", password="openhab" ]
{   
    Thing topic sonoffPOW1  {
    Channels:
        Type string : reachable    "Reachable"                [ stateTopic="tele/sonoffPOW1/LWT" ]
        Type switch : power        "Power"                    [ stateTopic="stat/sonoffPOW1/POWER", commandTopic="cmnd/sonoffPOW1/POWER" ]
        Type number : powerload    "Power load"               [ stateTopic="tele/sonoffPOW1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Power"]
        Type number : voltage      "Line voltage"             [ stateTopic="tele/sonoffPOW1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Voltage"]
        Type number : current      "Line current"             [ stateTopic="tele/sonoffPOW1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Current"]
        Type number : total        "Total energy today"       [ stateTopic="tele/sonoffPOW1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Today"]
        Type number : totalyest    "Total energy yesterday"   [ stateTopic="tele/sonoffPOW1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Yesterday"]
        Type number : rssi         "WiFi Signal Strength"     [ stateTopic="tele/sonoffPOW1/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
    } 
}

Notice the capital letters in the third line, (sonoffPOW1).

When I changed this to lower letters (sonoffpow1) things got online, and now everything is working allright… Like this:

Bridge mqtt:broker:mosquitto "mosquitto" [ host="10.4.28.200", port=1883, secure=false, username="openhabian", password="openhab" ]
{   
    Thing topic sonoffpow1  {
    Channels:
        Type string : reachable    "Reachable"                [ stateTopic="tele/sonoffPOW1/LWT" ]
        Type switch : power        "Power"                    [ stateTopic="stat/sonoffPOW1/POWER", commandTopic="cmnd/sonoffPOW1/POWER" ]
        Type number : powerload    "Power load"               [ stateTopic="tele/sonoffPOW1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Power"]
        Type number : voltage      "Line voltage"             [ stateTopic="tele/sonoffPOW1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Voltage"]
        Type number : current      "Line current"             [ stateTopic="tele/sonoffPOW1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Current"]
        Type number : total        "Total energy today"       [ stateTopic="tele/sonoffPOW1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Today"]
        Type number : totalyest    "Total energy yesterday"   [ stateTopic="tele/sonoffPOW1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Yesterday"]
        Type number : rssi         "WiFi Signal Strength"     [ stateTopic="tele/sonoffPOW1/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
    } 
}

Again, notice the third line, now using lower letters.

The topic of my Sonoff Pow is named: sonoffPOW1. So I assumed it should be the same. Unfortunalty this is not true. It seems like capital letters isn´t allowed in the thing name. But in the topic state, it´s has to be exact the same as the device topic named.

Its either a bug or its highly confusing.

Btw I´m using openhabian 2.5 M1. I have no idea if this may have been fixed in the recently released M3 or M2.

I am still on the 2.4 stable release and I am using Thing names with capitals but names that are different then the mqtt topic.

Maybe an issue in M1 then… I still dont understand howcome the names doesnt have to be exact the same. It really makes no sense to me.
Maybe @David_Graeff knows. As far as I can tell he´s the developer of the binding.

Probably not. David doesn’t use nor does he promote the use of .things files.

If there is a bug here though, you will need to try it first on version 2.5 M3 (there were a number of PRs applied to the binding for that release) to see if it’s still a problem and if so, file an issue. I’m certain debug logs will be required as well.

I got everything up running. But I seem to have a problem with my Sonoff RF Bridge 433mhz and JSONPATH.
This is the openhab log when the RF Bride receives at key (RfReceived):

2019-09-12 11:09:04.071 [WARN ] [l.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.RfKey1' in '{"RfReceived":{"Sync":8320,"Low":290,"High":820,"Data":"AB7BC2","RfKey":1}}'
2019-09-12 11:09:04.076 [WARN ] [eneric.internal.generic.ChannelState] - Command '{"RfReceived":{"Sync":8320,"Low":290,"High":820,"Data":"AB7BC2","RfKey":1}}' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.{"RfReceived":{"Sync":8320,"Low":290,"High":820,"Data":"AB7BC2","RfKey":1}}
2019-09-12 11:09:04.107 [WARN ] [l.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.RfKey1' in '{"RfReceived":{"Sync":8320,"Low":290,"High":820,"Data":"AB7BC2","RfKey":1}}'
2019-09-12 11:09:04.110 [WARN ] [eneric.internal.generic.ChannelState] - Command '{"RfReceived":{"Sync":8320,"Low":290,"High":820,"Data":"AB7BC2","RfKey":1}}' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.{"RfReceived":{"Sync":8320,"Low":290,"High":820,"Data":"AB7BC2","RfKey":1}}
2019-09-12 11:09:04.117 [WARN ] [l.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.RfKey1' in '{"RfReceived":{"Sync":8320,"Low":290,"High":820,"Data":"AB7BC2","RfKey":1}}'
2019-09-12 11:09:04.123 [WARN ] [eneric.internal.generic.ChannelState] - Command '{"RfReceived":{"Sync":8320,"Low":290,"High":820,"Data":"AB7BC2","RfKey":1}}' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.{"RfReceived":{"Sync":8320,"Low":290,"High":820,"Data":"AB7BC2","RfKey":1}}
2019-09-12 11:09:04.144 [WARN ] [l.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.RfKey1' in '{"RfReceived":{"Sync":8320,"Low":290,"High":820,"Data":"AB7BC2","RfKey":1}}'
2019-09-12 11:09:04.152 [WARN ] [eneric.internal.generic.ChannelState] - Command '{"RfReceived":{"Sync":8320,"Low":290,"High":820,"Data":"AB7BC2","RfKey":1}}' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.{"RfReceived":{"Sync":8320,"Low":290,"High":820,"Data":"AB7BC2","RfKey":1}}

My thing file looks like the above:

Bridge mqtt:broker:mosquitto "mosquitto" [ host="10.4.28.200", port=1883, secure=false, username="openhabian", password="openhab" ]
{   
    Thing topic sonoffpow1 "Sonoff Pow1 " @ "A Room" {
    Channels:
        Type string : reachable    "Reachable"                [ stateTopic="tele/sonoffPOW1/LWT" ]
        Type switch : power        "Power"                    [ stateTopic="stat/sonoffPOW1/POWER", commandTopic="cmnd/sonoffPOW1/POWER" ]
        Type number : powerload    "Power load"               [ stateTopic="tele/sonoffPOW1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Power"]
        Type number : voltage      "Line voltage"             [ stateTopic="tele/sonoffPOW1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Voltage"]
        Type number : current      "Line current"             [ stateTopic="tele/sonoffPOW1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Current"]
        Type number : total        "Total energy today"       [ stateTopic="tele/sonoffPOW1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Today"]
        Type number : totalyest    "Total energy yesterday"   [ stateTopic="tele/sonoffPOW1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Yesterday"]
        Type number : totalall     "Total energy alltime"     [ stateTopic="tele/sonoffPOW1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Total"]
        Type number : rssi         "WiFi Signal Strength"     [ stateTopic="tele/sonoffPOW1/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
    } 

   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:$.RfKey1" ]
        Type switch : button3       "Button 3"             [ stateTopic="tele/sonoffbm/RESULT", commandTopic="cmnd/sonoffbm/RFKEY3", transformationPattern="JSONPATH:$.RfKey1" ]
        Type switch : button4       "Button 4"             [ stateTopic="tele/sonoffbm/RESULT", commandTopic="cmnd/sonoffbm/RFKEY4", transformationPattern="JSONPATH:$.RfKey1" ]
        Type number : rssi          "WiFi Signal Strength" [ stateTopic="tele/sonoffbm/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
    }
}

It´s ONLY the RF Bridge which returns this error.

One of these JSONPATH is not like the other

but maybe more important
JSONPATH:$.RfKey1
isn’t going to match anything in
'{"RfReceived":{"Sync":8320,"Low":290,"High":820,"Data":"AB7BC2","RfKey":1}}'