Dear Community,
i do have a text configuration mqtt2-Binding installation. As far as i can see everything works fine except the automatic update for my power swtiches according to the power states of my tasmota devices.
That means if i force an update on my devices every value/item (e.g.: Uptime, Voltage, and much more) gets updated accordingly
CONFIGURATION:
openhab 2.5 stable on raspberry py 3b
it runs very stable without any other known issues.
tasmota.rules
//used through ForceUpdate Switch and triggered on timed event
//NEEDS sonoff_device_ids defined
rule “update MQTT Info”
when
//“At second :00, at minutes :02 and :32, of every hour”
Time cron “0 2,32 * ? * * *”
then
logInfo(“tasmota.rules”, "update MQTT Info for all devices: " )
val actionsBroker = getActions(“mqtt”,“mqtt:broker:5cef27a7”) // change to your broker name!
for (String device_id : sonoff_device_ids) {
actionsBroker.publishMQTT( device_id + "/cmnd/status", "0")
}
end
tasmota.things:
Thing mqtt:topic:sonoff0001_thing "Sonoff POW Switch 0001" (mqtt:broker:5cef27a7) @ "HOME" {
Channels:
Type switch : PowerSwitch "Power Switch" [ stateTopic="sonoff-0001/stat/POWER", stateTopic="sonoff-0001/tele/LWT", stateTopic="sonoff-0001/stat/STATUS", transformationPattern="JSONPATH:$.Status.Power", commandTopic="sonoff-0001/cmnd/POWER", ON="1", OFF="0" ]
Type number : POW_Current "POW Current" [ stateTopic="sonoff-0001/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Current", stateTopic="sonoff-0001/stat/STATUS8", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.Current", stateTopic="sonoff-0001/stat/STATUS10", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.Current"]
Type number : POW_Voltage "POW Voltage" [ stateTopic="sonoff-0001/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Voltage", stateTopic="sonoff-0001/stat/STATUS8", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.Voltage", stateTopic="sonoff-0001/stat/STATUS10", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.Voltage"]
Type number : POW_Watts "POW Watts" [ stateTopic="sonoff-0001/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Power", stateTopic="sonoff-0001/stat/STATUS8", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.Power", stateTopic="sonoff-0001/stat/STATUS10", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.Power"]
Type number : POW_Energy_today "Energy Today" [ stateTopic="sonoff-0001/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Today", stateTopic="sonoff-0001/stat/STATUS8", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.Today", stateTopic="sonoff-0001/stat/STATUS10", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.Today"]
Type number : POW_Energy_totalyest "Energy Yesterday" [ stateTopic="sonoff-0001/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Yesterday", stateTopic="sonoff-0001/stat/STATUS8", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.Yesterday", stateTopic="sonoff-0001/stat/STATUS10", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.Yesterday"]
Type number : POW_Energy_total "Energy Total" [ stateTopic="sonoff-0001/tele/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Total", stateTopic="sonoff-0001/stat/STATUS8", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.Total", stateTopic="sonoff-0001/stat/STATUS10", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.Total"]
Type string : hostname "Hostname" [ stateTopic="sonoff-0001/tele/INFO2", transformationPattern="JSONPATH:$.Hostname", stateTopic="sonoff-0001/stat/STATUS5", transformationPattern="JSONPATH:$.StatusNET.Hostname"]
Type string : IP "IP" [ stateTopic="sonoff-0001/tele/INFO2", transformationPattern="JSONPATH:$.IPAddress", stateTopic="sonoff-0001/stat/STATUS5", transformationPattern="JSONPATH:$.StatusNET.IPAddress"]
Type string : version "Version" [ stateTopic="sonoff-0001/tele/INFO1", transformationPattern="JSONPATH:$.Version", stateTopic="sonoff-0001/stat/STATUS2", transformationPattern="JSONPATH:$.StatusFWR.Version"]
Type string : uptime "Uptime" [ stateTopic="sonoff-0001/tele/STATE", transformationPattern="JSONPATH:$.Uptime", stateTopic="sonoff-0001/stat/STATUS11", transformationPattern="JSONPATH:$.StatusSTS.Uptime"]
Type number : wifi-rssi "Wifi Signal" [ stateTopic="sonoff-0001/tele/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI", transformationPattern="JSONPATH:$.Wifi.RSSI", stateTopic="sonoff-0001/stat/STATUS11", transformationPattern="JSONPATH:$.StatusSTS.Wifi.RSSI"]
Type switch : ForceUpdate "Force Update on Stats" [ stateTopic="sonoff-0001/stat/STATUS", commandTopic="sonoff-0001/cmnd/status", on="0", off="0"]
} // end of thing
tasmota.items
Switch Sonoff0001_PowerSwitch "Power Switch" <switch> (gSonoffSw0001, gTasmotaSwitchesAll) { channel="mqtt:topic:sonoff0001_thing:PowerSwitch" }
Number Sonoff0001_POW_Current "POW Current [%.1f A]" <line> (gSonoffSw0001, gTasmotaSwitchesAll) { channel="mqtt:topic:sonoff0001_thing:POW_Current" }
Number Sonoff0001_POW_Voltage "POW Voltage [%.1f V]" <line> (gSonoffSw0001, gTasmotaSwitchesAll) { channel="mqtt:topic:sonoff0001_thing:POW_Voltage" }
Number Sonoff0001_POW_Watts "POW Watts [%.1f W]" <line> (gSonoffSw0001, gTasmotaSwitchesAll) { channel="mqtt:topic:sonoff0001_thing:POW_Watts" }
Number Sonoff0001_POW_Today "POW Today [%.3f kWh]" <line> (gSonoffSw0001, gTasmotaSwitchesAll) { channel="mqtt:topic:sonoff0001_thing:POW_Energy_today" }
Number Sonoff0001_POW_totalyest "Energy Yesterday [%.3f kWh]" <line> (gSonoffSw0001, gTasmotaSwitchesAll,gVorg_Energy) { channel="mqtt:topic:sonoff0001_thing:POW_Energy_totalyest" }
Number Sonoff0001_POW_total "Energy Total [%.3f kWh]" <line> (gSonoffSw0001, gTasmotaSwitchesAll) { channel="mqtt:topic:sonoff0001_thing:POW_Energy_total" }
String Sonoff0001_Hostname "Hostname [%s]" <network> (gSonoffSw0001, gTasmotaSwitchesAll) { channel="mqtt:topic:sonoff0001_thing:hostname" }
String Sonoff0001_IP "IP [%s]" <network> (gSonoffSw0001, gTasmotaSwitchesAll) { channel="mqtt:topic:sonoff0001_thing:IP" }
String Sonoff0001_Version "Version [%s]" <network> (gSonoffSw0001, gTasmotaSwitchesAll) { channel="mqtt:topic:sonoff0001_thing:version" }
String Sonoff0001_Uptime "Uptime" <network> (gSonoffSw0001, gTasmotaSwitchesAll) { channel="mqtt:topic:sonoff0001_thing:uptime" }
Switch Sonoff0001_ForceUpdate "Force Update on Stats" <settings> (gSonoffSw0001, gTasmotaSwitchesAll) { channel="mqtt:topic:sonoff0001_thing:ForceUpdate" }
Number Sonoff0001_WifiRssi "Wifi Signal [%s]" <network> (gSonoffSw0001, gTasmotaSwitchesAll) { channel="mqtt:topic:sonoff0001_thing:wifi-rssi" }
I tried several variants as PowerSwitch:
Variant 1:
Type switch : PowerSwitch "Power Switch" [ stateTopic="sonoff-0001/stat/POWER", stateTopic="sonoff-0001/tele/LWT", stateTopic="sonoff-0001/stat/STATUS", transformationPattern="JSONPATH:$.Status.Power", commandTopic="sonoff-0001/cmnd/POWER", ON="1", OFF="0" ]
Variant 2:
Type switch : PowerSwitch "Power Switch" [ stateTopic="sonoff-0001/stat/POWER", stateTopic="sonoff-0001/tele/LWT", stateTopic="sonoff-0001/stat/STATUS11", transformationPattern="JSONPATH:$.StatusSTS.Power", commandTopic="sonoff-0001/cmnd/POWER", ON="1", OFF="0" ]
Variant 3:
Type switch : PowerSwitch "Power Switch" [ stateTopic="sonoff-0001/stat/POWER", stateTopic="sonoff-0001/tele/LWT", stateTopic="sonoff-0001/stat/STATUS11", transformationPattern="JSONPATH:$.StatusSTS.Power", transformationPattern="MAP:onoff.map", commandTopic="sonoff-0001/cmnd/POWER"]
onoff.map:
0=OFF
1=ON
Variant 4:
Type switch : PowerSwitch "Power Switch" [ stateTopic="sonoff-0001/stat/POWER", stateTopic="sonoff-0001/tele/LWT", stateTopic="sonoff-0001/stat/STATUS", transformationPattern="JSONPATH:$.Status.Power", commandTopic="sonoff-0001/cmnd/POWER", on="1", off="0" ]
With none of those i achieve any hug difference. But most of the time i do get the following warning:
2020-01-18 22:13:39.967 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command ‘{“Status”:{“Module”:6,“FriendlyName”:[“Sonoff0001”],“Topic”:“sonoff-0001”,“ButtonTopic”:“0”,“Power”:1,“PowerOnState”:3,“LedState”:0,“LedMask”:“FFFF”,“SaveData”:1,“SaveState”:1,“SwitchTopic”:“0”,“SwitchMode”:[0,0,0,0,0,0,0,0],“ButtonRetain”:0,“SwitchRetain”:0,“SensorRetain”:0,“PowerRetain”:0}}’ not supported by type ‘OnOffValue’: No enum constant org.eclipse.smarthome.core.library.types.OnOffType.{“Status”:{“Module”:6,“FriendlyName”:[“Sonoff0001”],“Topic”:“sonoff-0001”,“ButtonTopic”:“0”,“Power”:1,“PowerOnState”:3,“LedState”:0,“LedMask”:“FFFF”,“SaveData”:1,“SaveState”:1,“SwitchTopic”:“0”,“SwitchMode”:[0,0,0,0,0,0,0,0],“ButtonRetain”:0,“SwitchRetain”:0,“SensorRetain”:0,“PowerRetain”:0}}
==> /var/log/openhab2/events.log <==
2020-01-18 22:13:40.379 [vent.ItemStateChangedEvent] - Sonoff0001_POW_Voltage changed from 230 to 229
2020-01-18 22:13:40.429 [vent.ItemStateChangedEvent] - Sonoff0001_POW_total changed from 254.14 to 254.143
2020-01-18 22:13:40.457 [vent.ItemStateChangedEvent] - Sonoff0001_WifiRssi changed from 42 to 40
2020-01-18 22:13:40.464 [vent.ItemStateChangedEvent] - Sonoff0001_POW_Today changed from 0.299 to 0.302
2020-01-18 22:13:40.469 [vent.ItemStateChangedEvent] - Sonoff0001_Uptime changed from 4T23:15:51 to 4T23:27:31
2020-01-18 22:13:40.474 [vent.ItemStateChangedEvent] - Sonoff0001_POW_Current changed from 0.121 to 0.118
2020-01-18 22:13:40.586 [ome.event.ItemCommandEvent] - Item 'Sonoff0001_ForceUpdate' received command ON
2020-01-18 22:13:40.632 [nt.ItemStatePredictedEvent] - Sonoff0001_ForceUpdate predicted to become ON
2020-01-18 22:13:40.667 [vent.ItemStateChangedEvent] - Sonoff0001_ForceUpdate changed from OFF to ON
I can confirm that this warning is related to the PowerSwitch. Cause if i remove the switch as item i do not receive this error.
Thats a screenshot from the PaperUI:
The PowerSwitch is always like this - it never gets updated. As a matter of fact the actual state is “Power”:“1”.
i can confirm this because my powered device gets power and additionally i can check this on the console of the tasmota device:
22:22:16 MQT: sonoff-0001/stat/STATUS = {"Status":{"Module":6,"FriendlyName":["Sonoff0001"],"Topic":"sonoff-0001","ButtonTopic":"0","Power":1,"PowerOnState":3,"LedState":0,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0}}
22:22:16 MQT: sonoff-0001/stat/STATUS1 = {"StatusPRM":{"Baudrate":115200,"GroupTopic":"sonoffs","OtaUrl":"http://domus1:80/api/arduino/sonoff.ino.bin","RestartReason":"Software/System restart","Uptime":"4T23:36:08","StartupUTC":"2020-01-13T21:46:08","Sleep":50,"CfgHolder":4617,"BootCount":1615,"SaveCount":6584,"SaveAddress":"F8000"}}
22:22:16 MQT: sonoff-0001/stat/STATUS2 = {"StatusFWR":{"Version":"6.6.0(release-sonoff)","BuildDateTime":"2019-07-06T13:10:20","Boot":31,"Core":"2_3_0","SDK":"1.5.3(aec24ac9)"}}
22:22:16 MQT: sonoff-0001/stat/STATUS3 = {"StatusLOG":{"SerialLog":2,"WebLog":2,"SysLog":0,"LogHost":"domus1","LogPort":514,"SSId":["home-wlan","home-wlan2"],"TelePeriod":120,"Resolution":"558180C0","SetOption":["00000009","280500000100060000000000000000000000","00000001"]}}
22:22:16 MQT: sonoff-0001/stat/STATUS4 = {"StatusMEM":{"ProgramSize":503,"Free":500,"Heap":14,"ProgramFlashSize":1024,"FlashSize":4096,"FlashChipId":"1640E0","FlashMode":3,"Features":["00000809","0FDAE396","001783A0","22B617CD","01003BC0"]}}
22:22:16 MQT: sonoff-0001/stat/STATUS5 = {"StatusNET":{"Hostname":"sonoff-0001-1116","IPAddress":"192.168.1.81","Gateway":"192.168.1.1","Subnetmask":"255.255.255.0","DNSServer":"192.168.1.1","Mac":"5C:CF:7F:B4:A4:5C","Webserver":2,"WifiConfig":3}}
22:22:16 MQT: sonoff-0001/stat/STATUS6 = {"StatusMQT":{"MqttHost":"openhabianpi.lan2","MqttPort":1883,"MqttClientMask":"SO0001_%06X","MqttClient":"SO0001_B4A45C","MqttUser":"xxxx","MqttCount":15,"MAX_PACKET_SIZE":1000,"KEEPALIVE":30}}
22:22:16 MQT: sonoff-0001/stat/STATUS7 = {"StatusTIM":{"UTC":"Sat Jan 18 21:22:16 2020","Local":"Sat Jan 18 22:22:16 2020","StartDST":"Sun Mar 29 02:00:00 2020","EndDST":"Sun Oct 25 03:00:00 2020","Timezone":"+01:00","Sunrise":"08:36","Sunset":"17:24"}}
22:22:16 MQT: sonoff-0001/stat/STATUS9 = {"StatusPTH":{"PowerDelta":80,"PowerLow":0,"PowerHigh":0,"VoltageLow":0,"VoltageHigh":0,"CurrentLow":0,"CurrentHigh":0}}
22:22:16 MQT: sonoff-0001/stat/STATUS10 = {"StatusSNS":{"Time":"2020-01-18T22:22:16","ENERGY":{"TotalStartTime":"2019-01-25T18:16:46","Total":254.146,"Yesterday":0.315,"Today":0.305,"Power":26,"ApparentPower":40,"ReactivePower":31,"Factor":0.65,"Voltage":228,"Current":0.176}}}
22:22:16 MQT: sonoff-0001/stat/STATUS11 = {"StatusSTS":{"Time":"2020-01-18T22:22:16","Uptime":"4T23:36:08","Heap":14,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"POWER":"ON","Wifi":{"AP":1,"SSId":"home-wlan","BSSId":"84:16:F9:6C:64:04","Channel":13,"RSSI":42,"LinkCount":1,"Downtime":"0T00:00:06"}}}
TLDR: all items get updated but my PowerSwitch won´t. I believe that i covered all mqtt topics. But i cannot find the reason.
I searched the forums but i could not find the solution. I am literally on the end of my knowledge here. my logfile is pretty clean except for the mentioned warning.
Hopefully you can help me here out.
best regards and thanks in advance
habpower