I have a MQTT based switch running (Shelly), which allows me to switch on/off lights via Openhab’s web interface, the original wall swich and furhtermore via my Logitech Harmony using Hue Emulation. In principle everthing is working, but one problem remains: I can’t sync the status of the Hue Emulation switch with the status of the MQTT switch. E.g. if I turn on the light via the Harmony remote (Hue emulation) and later on off via the wall switch, the Hue emulation would not know about the off status.
I tried to resolve that via rules, but that brought me into an endless loop (off via MQTT triggers off for HUE, triggers off for MQTT …). Is there a preferred/best practice way to sync the state of two switches in such a scenario?
Thank you all for the quick response and suggestions.
I implemented the way via postUpdate and it works perfrectely fine.
Here is a code snippet, just in case somebody face the same issue
rule "Stehlampe anschalten via Hue"
Item egHueEmuLichtStehlampe received command ON
rule "Stehlampe ausschalten via Hue"
Item egHueEmuLichtStehlampe received command OFF
rule "Stehlampe anschalten Hue Status"
Item egLichtStehlampe changed from OFF to ON
rule "Stehlampe ausschalten Hue Status"
Item egLichtStehlampe changed from ON to OFF
Where egLichtStehlampe is the MQTT switch and egHueEmuLichtStehlampe is the emulated Hue switch.