Using Sonoff Power Switches with Tasmota firmware and openHAB2 MQTT2 binding

mqtt
mqtt-binding
mqttsonoff
Tags: #<Tag:0x00007f1e5b35ace8> #<Tag:0x00007f1e5b35aba8> #<Tag:0x00007f1e5b35a9f0>
(Hans Neesen) #81

Had the same problem. Fixed it by deleting the cache and temp removing and afterwards adding the things file with the broker. probably had some mixed paperui old mqtt v1 stuff

0 Likes

(J Wee) #82

Has there been changes to the MQTT 2.4 binding recently?
The “Sonoff Maintenance” rule earlier in this thread no longer works. I get an error

2019-02-25 17:38:51.504 [INFO ] [.smarthome.model.script.sonoff.rules] - Sonoff Maintenance on all devices:queryFW

2019-02-25 17:38:51.505 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Sonoff Maintenance': Instance is not an MQTTActions class.

It was working fine earlier. Currently on the latest 2.5 snapshot

0 Likes

(David Graeff) #83

There are a lot of build related changes and it could just be that the actions part did not compile / not got included / some dependencies are not resolving. It is at the moment not the best idea to use the snapshots and if you do, you need to check your logs intensively.

Cheers, David

0 Likes

(J Wee) #84

Thanks David. So should I just go with the M1 build instead?
Unfortunately I also need the latest Z wave snaphots for my z wave devices

0 Likes

(SiHui) #85

Just download the latest zwave snapshot binding and put it in your addons folder. Uninstall the PaperUI zwave binding first.

0 Likes

(J Wee) #86

Thank you . What is the safest way to move from 2.40/2.50 snapshot to 2.5 M1 , and not have to reconfigure all the Z wave and MQTT items again? Docker installation for OH

0 Likes

(SiHui) #87

Sorry, no idea about Docker :sunglasses:

0 Likes

(Marc) #88

I am using the 2.5 snapshot atm and got strange behaviour…

when is use that thing file entry :

Bridge mqtt:broker:myAuthentificatedBroker "MyBroker" @ "MyHome" [ host="192.168.178.212", secure=false, username="openhabian", password="xxxx", qos=1] {
Channels:
        Type string : reachable "Reachable"            [ stateTopic="tasmota/tele/sonoff-basic-1-00/LWT" ]
        Type switch : power     "Power"                [ stateTopic="tasmota/stat/sonoff-basic-1-00/POWER", commandTopic="tasmota/cmnd/sonoff-basic-1-00/POWER", on="ON", off="OFF" ]
        Type number : rssi      "WiFi Signal Strength" [ stateTopic="tasmota/tele/sonoff-basic-1-00/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
        Type publishTrigger : myTriggerChannel "Receive everything" [ stateTopic="tasmota/#", separator="#" ]
}

without the Thing line, i get channels shown in Visual studio in the Thing list.

if i go like this, which should be correct according to the documentation from what i can see, it doesnt show any channels :

Bridge mqtt:broker:myAuthentificatedBroker "MyBroker" @ "MyHome" [ host="192.168.178.212", secure=false, username="openhabian", password="xxxxxx", qos=1] {
Thing mqtt:topic:SonoffBasic01 "Sonoff Power Switch 01" @ "MQTT"  {
Channels:
        Type string : reachable "Reachable"            [ stateTopic="tasmota/tele/sonoff-basic-1-00/LWT" ]
        Type switch : power     "Power"                [ stateTopic="tasmota/stat/sonoff-basic-1-00/POWER", commandTopic="tasmota/cmnd/sonoff-basic-1-00/POWER", on="ON", off="OFF" ]
        Type number : rssi      "WiFi Signal Strength" [ stateTopic="tasmota/tele/sonoff-basic-1-00/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
        Type publishTrigger : myTriggerChannel "Receive everything" [ stateTopic="tasmota/#", separator="#" ]
}
}

now the channels need to be correct, since a thing config like this :

Type publishTrigger : myTriggerChannel "Receive everything" [ stateTopic="tasmota/tele/sonoff-basic-1-00/POWER", separator="#" ]

results in that loggin

2019-03-30 15:37:37.621 [vent.ChannelTriggeredEvent] - mqtt:broker:myAuthentificatedBroker:reachable triggered Online

2019-03-30 15:37:43.861 [vent.ChannelTriggeredEvent] - mqtt:broker:myAuthentificatedBroker:power triggered ON

2019-03-30 15:37:56.665 [vent.ChannelTriggeredEvent] - mqtt:broker:myAuthentificatedBroker:power triggered OFF

2019-03-30 15:37:59.593 [vent.ChannelTriggeredEvent] - mqtt:broker:myAuthentificatedBroker:rssi triggered {"Time":"2019-03-30T15:38:00","Uptime":"0T00:05:20","Vcc":3.170,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":20,"POWER":"OFF","Wifi":{"AP":1,"SSId":"Elias W-LAN","BSSId":"A0:04:60:86:32:62","Channel":6,"RSSI":32,"LinkCount":1,"Downtime":"0T00:00:06"}}

the item file is like follows, but either way, does not really work

String Reachable "Reachable" {channel="mqtt:broker:myAuthentificatedBroker:reachable"}
Number Rssi "WiFi Signal Strength" {channel="mqtt:broker:myAuthentificatedBroker:rssi"}
Switch 		OnOff_Bath_Mirror_OG	"An/Aus (Bad Spiegel) OG"		<light_led>		/*(G_Lights_Bath,G_OnOff)*/		{channel="mqtt:broker:myAuthentificatedBroker:power"}

i have no clue what the problem is… does anyone see the mistake or know the reason why i cant have the thing line in the thing config file ?
Also i am not sure why the JASONPATH transformation is not working … i have the transformation jsonpath installed…

0 Likes

(WJ) #89

@schelli Marc, maybe I am not the best person to answer your question I’ve got it working with all the examples I found on this forum. for starters I use MQTT bridge in a separate thing file. This file contains no “{”; so think you can remove that in your bridge line. Not sure but the differences in your StateTopic might be problem.
Please note my solution works but might be not the most perfect solotion.

PS Still not found the SonOff icons, anyone?

Bridge:

Bridge mqtt:broker:MyMosquitto "MQTT Broker Mosquitto" @ "MQTT" 
[ 
.....
]

Thing:

//=================================================================================================================================================
Thing mqtt:topic:Sonoff1 "Sonoff 1" (mqtt:broker:MyMosquitto) @ "MQTT"  {
  Channels:
    Type switch : power          [ stateTopic="stat/Sonoff1/POWER",  commandTopic="cmnd/Sonoff1/Power"]
    Type string : fw             [ stateTopic="tele/Sonoff1/INFO1",  transformationPattern="JSONPATH:$.Version"]
    Type string : hostname       [ stateTopic="tele/Sonoff1/INFO2",  transformationPattern="JSONPATH:$.Hostname"]
    Type string : ip             [ stateTopic="tele/Sonoff1/INFO2",  transformationPattern="JSONPATH:$.IPAddress"]
    Type string : wifi-rssi      [ stateTopic="tele/Sonoff1/STATE",  transformationPattern="JSONPATH:$.Wifi.RSSI" ]
    Type switch : devicestate    [ stateTopic="tele/Sonoff1/LWT",    transformationPattern="MAP:reachable.map" ]
} // end of thing
//=================================================================================================================================================

Item:

//=================================================================================================================================================
Switch Sonoff1_Switch          "Voordeur"            <selflight>    (Sonoffs) { channel="mqtt:topic:Sonoff1:power" }
String Sonoff1_hostname        "Sonoff1 hostname"                   (Sonoffs) { channel="mqtt:topic:Sonoff1:hostname" }
String Sonoff1_IP              "Sonoff1 IP"          <ip>           (Sonoffs) { channel="mqtt:topic:Sonoff1:ip" }
String Sonoff1_FW              "Sonoff1 FW"          <selfinfo>     (Sonoffs) { channel="mqtt:topic:Sonoff1:fw" }
String Sonoff1_WifiRssi        "Sonoff1 Wifi RSSI"   <network>      (Sonoffs) { channel="mqtt:topic:Sonoff1:wifi-rssi" }
Switch Sonoff1_DeviceState     "Sonoff1 Device State" <selfshield> (gReachable,Sonoffs) { channel="mqtt:topic:Sonoff1:devicestate" }
//=================================================================================================================================================
0 Likes

(Jürgen Baginski) #90

IMHO it is possible to add channels to the broker-thing ( which is a bridge), but those channels are of no use!
Did you copy the channel definition from your PaperUI? The channel definition show on PaperUI can be used in both cases, either if things are defined on PaperUI as well as in files.

0 Likes

(Marc) #91

Hmm, the problem was as so many times between my own ears :roll_eyes:

I was looking in the thing list under the MQTT Broker name for channels to appear. but ofc i had to look under the name of my MQTT topic thing in the thing list … incredibly stupid, but well, cost me 2 or 3 hours fiddling around, just a simple thinking mistake … thx for your help though.

@opus actually your note about being able to create those channels without effect, made me think about where the channels should be / appear…

0 Likes

(udondan) #92

I’m having the same here. Thanks for your post, that brought me on the right track.

So, whenever I save the thing-file that contains the bridge, all related MQTT things immediately stop working.

Only solutions I have found:

  • Renaming the Bridge
  • Restarting OpenHAB

The trick with defining the bridge in a separate file - and of course never touching that again - therefore is the only way to add new MQTT things without breaking everything.

I’m running 2.5.0.M1

0 Likes

(David Graeff) #93

OH 2.4 introduced the new MQTT extension, and the issue really is that I don’t use textual configuration files, I guess. But since OH 2.4 and also OH 2.5M1 a lot of fixes have accumulated that should make the MQTT binding also useful for textual configuration users.

Cheers, David

0 Likes