I’ve made some tests…
THING
Thing mqtt:topic:mymqtt:sonoff-ABCDEFG "ElectroDragon Relay Board" (mqtt:broker:mymqtt) @ "MQTT" {
Channels:
Type switch : sw1 "Switch 1" [
stateTopic="tasmota/sonoff-ABCDEFG/stat/POWER1",
commandTopic="tasmota/sonoff-ABCDEFG/cmnd/POWER1",
on="ON",
off="OFF"
]
Type switch : sw2 "Switch 2" [
stateTopic="tasmota/sonoff-ABCDEFG/stat/POWER2",
commandTopic="tasmota/sonoff-ABCDEFG/cmnd/POWER2",
on="ON",
off="OFF"
]
Type switch : sw1_stat "Status Backup Switch 1" [
stateTopic="tasmota/sonoff-ABCDEFG/stat/STATUS11",
transformationPattern="JSONPATH:$.StatusSTS.POWER1",
on="ON",
off="OFF"
]
Type switch : sw2_stat "Status Backup Switch 2" [
stateTopic="tasmota/sonoff-ABCDEFG/stat/STATUS11",
transformationPattern="JSONPATH:$.StatusSTS.POWER2",
on="ON",
off="OFF"
]
Type string : version [
stateTopic="tasmota/sonoff-ABCDEFG/stat/STATUS2",
transformationPattern="JSONPATH:$.StatusFWR.Version"
]
}
ITEM
// Test Board ElectroDragon
Switch mqtt_sonoff_ABCDEFG_sw1 "ED Switch 1 []" <switch> { channel="mqtt:topic:mymqtt:sonoff-ABCDEFG:sw1" }
Switch mqtt_sonoff_ABCDEFG_sw2 "ED Switch 2 []" <switch> { channel="mqtt:topic:mymqtt:sonoff-ABCDEFG:sw2" }
Switch mqtt_sonoff_ABCDEFG_sw1_stat "ED Switch 1 []" <switch> { channel="mqtt:topic:mymqtt:sonoff-ABCDEFG:sw1_stat" }
Switch mqtt_sonoff_ABCDEFG_sw2_stat "ED Switch 2 []" <switch> { channel="mqtt:topic:mymqtt:sonoff-ABCDEFG:sw2_stat" }
RULE
rule "update tasmota EletroDragon DEMO"
when
Item mqtt_sonoff_ABCDEFG_sw1 changed or
Item mqtt_sonoff_ABCDEFG_sw2 changed
then
val actions = getActions("mqtt","mqtt:broker:mymqtt")
actions.publishMQTT("tasmota/sonoff-ABCDEFG/cmnd/STATUS","11")
end
LOG - Buttons pushed manually at the device.
2019-10-06 15:31:50.367 [vent.ItemStateChangedEvent] - mqtt_sonoff_ABCDEFG_sw1 changed from OFF to ON
2019-10-06 15:31:50.415 [vent.ItemStateChangedEvent] - mqtt_sonoff_ABCDEFG_sw1_stat changed from OFF to ON
2019-10-06 15:31:51.815 [vent.ItemStateChangedEvent] - mqtt_sonoff_ABCDEFG_sw2 changed from OFF to ON
2019-10-06 15:31:51.878 [vent.ItemStateChangedEvent] - mqtt_sonoff_ABCDEFG_sw2_stat changed from OFF to ON
2019-10-06 15:31:53.298 [vent.ItemStateChangedEvent] - mqtt_sonoff_ABCDEFG_sw1 changed from ON to OFF
2019-10-06 15:31:53.348 [vent.ItemStateChangedEvent] - mqtt_sonoff_ABCDEFG_sw1_stat changed from ON to OFF
2019-10-06 15:31:54.557 [vent.ItemStateChangedEvent] - mqtt_sonoff_ABCDEFG_sw2 changed from ON to OFF
2019-10-06 15:31:54.645 [vent.ItemStateChangedEvent] - mqtt_sonoff_ABCDEFG_sw2_stat changed from ON to OFF
Until here everything looks ok.
Using this item code it looks ok. But without the status update
// Test Board ElectroDragon
Switch mqtt_sonoff_ABCDEFG_sw1 "ED Switch 1 []" <switch> { channel="mqtt:topic:mymqtt:sonoff-ABCDEFG:sw1" }
Switch mqtt_sonoff_ABCDEFG_sw2 "ED Switch 2 []" <switch> { channel="mqtt:topic:mymqtt:sonoff-ABCDEFG:sw2" }
Using the 2nd channel to get status updates the item within sitemap isn’t showing the real world
Switch mqtt_sonoff_ABCDEFG_sw1 "ED Switch 1 []" <switch> { channel="mqtt:topic:mymqtt:sonoff-ABCDEFG:sw1", channel="mqtt:topic:mymqtt:sonoff-ABCDEFG:sw1_stat" }
Switch mqtt_sonoff_ABCDEFG_sw2 "ED Switch 2 []" <switch> { channel="mqtt:topic:mymqtt:sonoff-ABCDEFG:sw2", channel="mqtt:topic:mymqtt:sonoff-ABCDEFG:sw2_stat" }
In the log you can see that “sw1” switch from OFF to ON->OFF->ON … This looks very strange.
2019-10-06 19:25:28.096 [ome.event.ItemCommandEvent] - Item 'mqtt_sonoff_33E958_sw1' received command ON
2019-10-06 19:25:28.105 [nt.ItemStatePredictedEvent] - mqtt_sonoff_33E958_sw1 predicted to become ON
2019-10-06 19:25:28.124 [vent.ItemStateChangedEvent] - mqtt_sonoff_33E958_sw1 changed from OFF to ON
2019-10-06 19:25:28.138 [vent.ItemStateChangedEvent] - mqtt_sonoff_33E958_sw1 changed from ON to OFF
2019-10-06 19:25:28.163 [vent.ItemStateChangedEvent] - mqtt_sonoff_33E958_sw1 changed from OFF to ON
2019-10-06 19:25:28.218 [vent.ItemStateChangedEvent] - mqtt_sonoff_33E958_sw1_stat changed from OFF to ON
I just want to have a MQTT topic which shows the right status of a switch.
Any suggestions?