Based on the tutorial from Sven, I was able to convert the MQTT setup for the Sonoff devices using the firmware from Theo Arends: https://github.com/arendst/Sonoff-Tasmota
When combining the definitions of the bridge and things in one file, the system did behave quite strange. Things were not updated or I had to rename the broker. Accordingly I moved the definition of the bridge in a separate file.
bridge.things:
// bridge.things
// https://community.openhab.org/t/using-sonoff-power-switches-with-tasmota-firmware-and-openhab2-mqtt2-binding/59969
Bridge mqtt:broker:MqttPandora20 "MQTT Broker Pandora" @ "MQTT Pandora" [
host="192.168.1.123",
port=1883,
secure="AUTO",
qos=0,
retain=false,
clientid="Oh2Mqtt2Thing",
//certificate="",
//certificatepin=false,
//publickey="",
//publickeypin=false,
keep_alive_time=30000,
reconnect_time=60000,
//lastwill_message="",
//lastwill_qos=1,
//lastwill_topic="",
username="mqttuser",
password="mqttpw"
]
sonoff.things
EDIT 30-Dec-2018: the commandTopic for the PowerSwitch was wrong
// sonoff.things
//
Thing mqtt:topic:SonoffPs02_thg "Sonoff POW Switch 02" (mqtt:broker:MqttPandora20) @ "MQTT" {
Channels:
Type switch : PowerSwitch "Power Switch 02" [ stateTopic="house/trockner/stat/sonoff/POWER", commandTopic="house/trockner/cmnd/sonoff/Power", on="1", off="0" ]
Type switch : PowerSwitchRes "Switch State 02" [ stateTopic="house/trockner/stat/sonoff/RESULT", transformationPattern="JSONPATH:$.POWER",on="ON",off="OFF"]
Type string : Version "Version 02" [ stateTopic="house/trockner/tele/sonoff/INFO1", transformationPattern="JSONPATH:$.Version"]
Type string : fallback "fallback topic" [ stateTopic="house/trockner/tele/sonoff/INFO1", transformationPattern="JSONPATH:$.FallbackTopic"]
Type string : hostname "hostname " [ stateTopic="house/trockner/tele/sonoff/INFO2", transformationPattern="JSONPATH:$.Hostname"]
Type string : IP "IP " [ stateTopic="house/trockner/tele/sonoff/INFO2", transformationPattern="JSONPATH:$.IPAddress"]
Type string : time "Time" [ stateTopic="house/trockner/tele/sonoff/STATE", transformationPattern="JSONPATH:$.Time" ]
Type string : uptime "Uptime" [ stateTopic="house/trockner/tele/sonoff/STATE", transformationPattern="JSONPATH:$.Uptime" ]
Type number : vcc "VCC" [ stateTopic="house/trockner/tele/sonoff/STATE", transformationPattern="JSONPATH:$.Vcc" ]
Type string : wifi-ap "Wifi AP" [ stateTopic="house/trockner/tele/sonoff/STATE", transformationPattern="JSONPATH:$.Wifi.AP" ]
Type string : wifi-ssid "Wifi SSID" [ stateTopic="house/trockner/tele/sonoff/STATE", transformationPattern="JSONPATH:$.Wifi.SSId" ]
Type string : wifi-channel "Wifi Channel" [ stateTopic="house/trockner/tele/sonoff/STATE", transformationPattern="JSONPATH:$.Wifi.Channel" ]
Type string : wifi-rssi "Wifi RSSI" [ stateTopic="house/trockner/tele/sonoff/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI" ]
Type string : SensorTime "Sensor Time" [ stateTopic="house/trockner/tele/sonoff/SENSOR", transformationPattern="JSONPATH:$.Time" ]
Type string : POW-startTime "POW Start Time" [ stateTopic="house/trockner/tele/sonoff/SENSOR", transformationPattern="JSONPATH:$.ENERGY.TotalStartTime" ]
Type string : POW-Total "POW Total" [ stateTopic="house/trockner/tele/sonoff/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Total" ]
Type string : POW-Voltage "POW Voltage" [ stateTopic="house/trockner/tele/sonoff/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Voltage" ]
Type string : devicestate "Device State" [ stateTopic="house/trockner/tele/sonoff/LWT" ]
} // end of thing
Thing mqtt:topic:SonoffPs01_thg "Sonoff Power Switch 01" (mqtt:broker:MqttPandora20) @ "MQTT" {
Channels:
Type switch : PowerSwitch "Power Switch 01" [ stateTopic="house/light1/stat/sonoff/POWER", commandTopic="house/light1/cmnd/sonoff/Power", on="1", off="0" ]
Type switch : PowerSwitchRes "Switch State 01" [ stateTopic="house/light1/stat/sonoff/RESULT", transformationPattern="JSONPATH:$.POWER",on="ON",off="OFF"]
Type string : Version "Version 01" [ stateTopic="house/light1/tele/sonoff/INFO1", transformationPattern="JSONPATH:$.Version"]
Type string : fallback "fallback topic" [ stateTopic="house/light1/tele/sonoff/INFO1", transformationPattern="JSONPATH:$.FallbackTopic"]
Type string : hostname "hostname " [ stateTopic="house/light1/tele/sonoff/INFO2", transformationPattern="JSONPATH:$.Hostname"]
Type string : IP "IP " [ stateTopic="house/light1/tele/sonoff/INFO2", transformationPattern="JSONPATH:$.IPAddress"]
Type string : time "Time" [ stateTopic="house/light1/tele/sonoff/STATE", transformationPattern="JSONPATH:$.Time" ]
Type string : uptime "Uptime" [ stateTopic="house/light1/tele/sonoff/STATE", transformationPattern="JSONPATH:$.Uptime" ]
Type number : vcc "VCC" [ stateTopic="house/light1/tele/sonoff/STATE", transformationPattern="JSONPATH:$.Vcc" ]
Type string : wifi-ap "Wifi AP" [ stateTopic="house/light1/tele/sonoff/STATE", transformationPattern="JSONPATH:$.Wifi.AP" ]
Type string : wifi-ssid "Wifi SSID" [ stateTopic="house/light1/tele/sonoff/STATE", transformationPattern="JSONPATH:$.Wifi.SSId" ]
Type string : wifi-channel "Wifi Channel" [ stateTopic="house/light1/tele/sonoff/STATE", transformationPattern="JSONPATH:$.Wifi.Channel" ]
Type string : wifi-rssi "Wifi RSSI" [ stateTopic="house/light1/tele/sonoff/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI" ]
Type string : devicestate "Device State" [ stateTopic="house/light1/tele/sonoff/LWT" ]
} // end of thing
sonoff.items
// sonoff.items
// itemname ["labeltext"] [<iconname>] [(group1, group2, ...)] [{bindingconfig}]
// Itead SONOFF - Tasmoto
// https://github.com/arendst/Sonoff-Tasmota/wiki
/************************************************** Gruppen ********************************************/
Group gSonoffSwitches "SONOFF Sensors" // used for chart
Group gSonoffSw1 "sonoff switch 1"
Group gSonoffSw1Info "sonoff Info 1"
Group gSonoffSw2 "sonoff switch 2"
Group gSonoffSw2Info "sonoff Info 2"
/************************************************** Items ********************************************/
String Switch_TH_Temperatur "Temperatur [%s °C]" <temperature> { channel="mqtt:topic:myMQTTBroker:sonoff_TH_Thing:Temperature"}
/*
Lighting Room1
*/
Switch SonoffPs01Switch_Switch "SPS01 Switch 1" (gSonoffSw1) { channel="mqtt:topic:SonoffPs01_thg:PowerSwitch" }
Switch SonoffPs01Switch_State "SPS01 State 1" (gSonoffSw1) { channel="mqtt:topic:SonoffPs01_thg:PowerSwitchRes"}
Number SonoffPs01Switch_Vcc "SPS01 VCC [%s]" (gSonoffSw1Info) { channel="mqtt:topic:SonoffPs01_thg:vcc" }
String SonoffPs01Switch_WifiAp "SPS01 Wifi AP [%s]" (gSonoffSw1Info) { channel="mqtt:topic:SonoffPs01_thg:wifi-ap" }
String SonoffPs01Switch_WifiSsid "SPS01 Wifi SSID [%s]" (gSonoffSw1Info) { channel="mqtt:topic:SonoffPs01_thg:wifi-ssid" }
String SonoffPs01Switch_WifiChannel "SPS01 Wifi Channel [%s]" (gSonoffSw1Info) { channel="mqtt:topic:SonoffPs01_thg:wifi-channel" }
String SonoffPs01Switch_WifiRssi "SPS01 Wifi RSSI [%s]" (gSonoffSw1Info) { channel="mqtt:topic:SonoffPs01_thg:wifi-rssi" }
String SonoffPs01Switch_Uptime "SPS01 Uptime" (gSonoffSw1Info) { channel="mqtt:topic:SonoffPs01_thg:uptime" }
String SonoffPs01Switch_Time "SPS01 Time" (gSonoffSw1Info) { channel="mqtt:topic:SonoffPs01_thg:time" }
String SonoffPs01Switch_Version "SPS01 Version [%s]" (gSonoffSw1Info) { channel="mqtt:topic:SonoffPs01_thg:Version" }
String SonoffPs01Switch_Hostname "SPS01 Hostname [%s]" (gSonoffSw1Info) { channel="mqtt:topic:SonoffPs01_thg:hostname" }
String SonoffPs01Switch_IP "SPS01 IP [%s]" (gSonoffSw1Info) { channel="mqtt:topic:SonoffPs01_thg:IP" }
String SonoffPs01Switch_DeviceState "SPS01 Device State" (gSonoffSw1Info) { channel="mqtt:topic:SonoffPs01_thg:devicestate" }
String SonoffPs01Switch_SensorTime "SPS01 Sensor Time" (gSonoffSw1) { channel="mqtt:topic:SonoffPs01_thg:SensorTime" }
/*
Trockner
*/
Switch SonoffPs02Switch_Switch "SPs02 Switch 1" (gSonoffSw2) { channel="mqtt:topic:SonoffPs02_thg:PowerSwitch" }
Switch SonoffPs02Switch_State "SPs02 State 1" (gSonoffSw2) { channel="mqtt:topic:SonoffPs02_thg:PowerSwitchRes"}
Number SonoffPs02Switch_Vcc "SPs02 VCC [%s]" (gSonoffSw2Info) { channel="mqtt:topic:SonoffPs02_thg:vcc" }
String SonoffPs02Switch_WifiAp "SPs02 Wifi AP [%s]" (gSonoffSw2Info) { channel="mqtt:topic:SonoffPs02_thg:wifi-ap" }
String SonoffPs02Switch_WifiSsid "SPs02 Wifi SSID [%s]" (gSonoffSw2Info) { channel="mqtt:topic:SonoffPs02_thg:wifi-ssid" }
String SonoffPs02Switch_WifiChannel "SPs02 Wifi Channel [%s]" (gSonoffSw2Info) { channel="mqtt:topic:SonoffPs02_thg:wifi-channel" }
String SonoffPs02Switch_WifiRssi "SPs02 Wifi RSSI [%s]" (gSonoffSw2Info) { channel="mqtt:topic:SonoffPs02_thg:wifi-rssi" }
String SonoffPs02Switch_Uptime "SPs02 Uptime" (gSonoffSw2Info) { channel="mqtt:topic:SonoffPs02_thg:uptime" }
String SonoffPs02Switch_Time "SPs02 Time" (gSonoffSw2Info) { channel="mqtt:topic:SonoffPs02_thg:time" }
String SonoffPs02Switch_Version "SPs02 Version [%s]" (gSonoffSw2Info) { channel="mqtt:topic:SonoffPs02_thg:Version" }
String SonoffPs02Switch_Hostname "SPs02 Hostname [%s]" (gSonoffSw2Info) { channel="mqtt:topic:SonoffPs02_thg:hostname" }
String SonoffPs02Switch_IP "SPs02 IP [%s]" (gSonoffSw2Info) { channel="mqtt:topic:SonoffPs02_thg:IP" }
String SonoffPs02Switch_DeviceState "SPs02 Device State" (gSonoffSw2Info) { channel="mqtt:topic:SonoffPs02_thg:devicestate" }
String SonoffPs02Switch_SensorTime "SPs02 Sensor Time" (gSonoffSw2) { channel="mqtt:topic:SonoffPs02_thg:SensorTime" }
String SonoffPs02Switch_POW_startTime "SPS02 POW Start Time" (gSonoffSw2) { channel="mqtt:topic:SonoffPs02_thg:POW-startTime" }
String SonoffPs02Switch_POW_Today "SPS02 POW Today" (gSonoffSw2) { channel="mqtt:topic:SonoffPs02_thg:POW-Total" }
String SonoffPs02Switch_POW_Voltage "SPS02 POW Voltage" (gSonoffSw2) { channel="mqtt:topic:SonoffPs02_thg:POW-Voltage" }
sonoff.sitemap
// meinHeim.sitemap
// list of icons: https://github.com/eclipse/smarthome/tree/master/extensions/ui/iconset/org.eclipse.smarthome.ui.iconset.classic/icons
sitemap sonoff label="Sonoff Devices" {
Frame label="sonoff Licht 01" {
Switch item=SonoffPs01Switch_Switch
Switch item=SonoffPs01Switch_State
Group item=gSonoffSw1Info
Text item=SonoffPs01Switch_SensorTime
} // end of Frame
Frame label="sonoff Trockner" {
Switch item=SonoffPs02Switch_Switch
Switch item=SonoffPs02Switch_State
Group item=gSonoffSw2Info
Text item=SonoffPs02Switch_SensorTime
Text item=SonoffPs02Switch_POW_Today
Text item=SonoffPs02Switch_POW_Voltage
Text item=SonoffPs02Switch_POW_startTime
} // end of Frame
} // end of sitemap