Using Sonoff Power Switches with Tasmota firmware and openHAB2 MQTT2 binding

mqtt
mqtt-binding
mqttsonoff
Tags: #<Tag:0x00007f1e669310a8> #<Tag:0x00007f1e66930e28> #<Tag:0x00007f1e66930ba8>
(David Graeff) #72

Not yet. At the moment Paper UI and text files are basically fighting each other and it makes sense to choose one and stay there.

0 Likes

(WJ) #73

No real question, some experience shared

Completely agree I had recent a OH mess-up because I followed the manual of the network binding to the letter and created an <openHAB-conf>/services/network.cfg file (not sure if I also installed the binding itself in paper UI).

Later, for another reason I thought it was wise to do the combination of cleaning the cache and deleting file /var/lib/openhab2/config/org/openhab/addons.config in one go with results all bindings were ‘gone’ and things not working. Oeps. Notice in addons.config that only the Network binding was there. Manage to restore this and OH is now running again but some errors on startup remain.

0 Likes

(SiHui) #74

addons.config is created automatically based on the settings in your addons.cfg and should not be edited.
If you define a binding in addons.cfg it takes precedence over the installed bindings in PaperUI, meaning you either have to define ALL your bindings in addons.cfg OR ALL bindings in PaperUI.

1 Like

(WJ) #75

Did not change recently anything in addons.cfg; only package and ui is activated here, which explains I lost in the past habpanel because ui info was ‘ui = basic,paper’ I changed this to ‘ui = basic,habpanel,paper’ but based on your answer the better option is to set ui on comment with #ui?

Yesterday I had good experience to re-add the astro.binding to the addons.config file because adding it to the paper ui again gave problems with adding the Astro things with old names (confession: did a forced remove of these things). The Astro binding is working like a charm now again.

0 Likes

(SiHui) #76

Again: don’t edit the config files! If you do not want to use PaperUI, do your complete setup via addons.cfg, stop openHAB, delete the addons.config, then restart openHAB. Based on your settings in the addons.cfg openHAB will recreate the correct addons.config automatically.

0 Likes

(J Wee) #77

I have a DS18B20 sensor on my sonoff RF that reads fine on the sonoff but has this error in OH under MQTT 2.4

Thing
Type string : temperature “Temperature” [ stateTopic=“tele/sonoff/powerstrip3/SENSOR”, transformationPattern=“JSONPATH:$.DS18B20.Temperature”]

Item
Number Sonoffps3_Temperature “Powerstrip3 Temperature [%d °C]” (Sonoffps3) { channel=“mqtt:topic:sonoffps3:DS18B20.temperature”}

This is the error:

2019-01-31 15:55:22.544 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type 'channel' of item 'Sonoffps3_Temperature' could not be parsed correctly.

org.eclipse.smarthome.model.item.BindingConfigParseException: UID segment 'DS18B20.temperature' contains invalid characters. The last segment of the channel UID must match the pattern '[\w-]*|[\w-]*#[\w-]*'.

	at org.eclipse.smarthome.model.thing.internal.GenericItemChannelLinkProvider.createItemChannelLink(GenericItemChannelLinkProvider.java:83) ~[?:?]

	at org.eclipse.smarthome.model.thing.internal.GenericItemChannelLinkProvider.processBindingConfiguration(GenericItemChannelLinkProvider.java:73) ~[?:?]

	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:397) ~[?:?]

	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:366) ~[?:?]

	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.processBindingConfigsFromModel(GenericItemProvider.java:229) ~[?:?]

	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.modelChanged(GenericItemProvider.java:432) ~[?:?]

	at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:303) ~[?:?]

	at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:141) ~[?:?]

	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:239) ~[?:?]

	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.processWatchEvent(FolderObserver.java:303) ~[?:?]

	at org.eclipse.smarthome.core.service.WatchQueueReader.lambda$3(WatchQueueReader.java:323) ~[?:?]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]

	at java.lang.Thread.run(Thread.java:748) [?:?]

What am I doing wrong?

0 Likes

Configuration of openHAB
(David Graeff) #78

Sigh. It’s not the MQTT bindings fault. You need to read up on the .thing file syntax. I know it is complex and long and tedious, but you decided not use Paper UI.

0 Likes

(Jürgen Baginski) #79

Take a look into PaperUI, under Configuration- Things you will find your thing, click on it and all channels will be shown, under the bold name of the channel the correct syntax for that channel to be used in the items file is shown.
My guess , you omitted the brokername.

0 Likes

(J Wee) #80

Hi David, I am not blaming the binding. I am assuming I mess up somewhere in my configuration of the thing /item file. Which is why I am requesting for insights

Hi Jurgen, you were right on. Somehow I link a wrong item to the temperature channel for that thing.
Thank you very much

1 Like

(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