I would like to make my mqtt Switch to use a 3:rd icon if by any reason a change don’t come in for a coupple of seconds. This indicates that ther are some sort of failure in the communication…
E.g. When all is OK I get this communication
2017-02-22 13:31:49.677 [ItemCommandEvent ] - Item ‘Light_S20_0885’ received command OFF
2017-02-22 13:31:49.702 [GroupItemStateChangedEvent] - Lights changed from ON to OFF through Light_S20_0885
2017-02-22 13:31:49.709 [ItemStateChangedEvent ] - Light_S20_0885 changed from ON to OFF
But is someone have unplugged my smart plug, I only get
2017-02-22 13:31:49.677 [ItemCommandEvent ] - Item ‘Light_S20_0885’ received command OFF
In this case I would like to display an icon “switch-unknown”
I have not been able to come up with a good implementation for this.
My best guess is that I have ta have a second item for each of my switches in my item file. Then write some tricky rule which is my problem for the monent.
Then use visability to hide my “real” switch in favor for the “disable” switch.
If I try to switch my disable switch, and it gets a response I change state of my “second item”, to show my real switch again…
Home.itemsSwitch Light_S20_0885 "S20_0885" (Sonoff, Lights) { mqtt=">[broker:cmnd/S20_0885/power:command:*:default], <[broker:stat/S20_0885/POWER:state:default]", autoupdate="false" } Number Light_S20_0885_Fail "S20_0885" (Sonoff, Lights) { mqtt=">[broker:cmnd/S20_0885/power:command:*:default], <[broker:stat/S20_0885/POWER:state:default]", autoupdate="false" }
Home.sitemapSwitch item=Switch Light_S20_0885 visibility=[Number Light_S20_0885_Fail =0] Switch item=Switch Light_S20_0885 icon="switch-unknown" visibility=[Number Light_S20_0885_Fail =1]
MQTT-Offline.rule
??? I have no clue how to trigger on the missing GroupItemStateChangedEvent or ItemStateChangedEvent
Does this make any sense?
Any iders on how to write the rule…?
Any other suggestions?