I have a Shelly dimmer 2 behind one of the switches in my kitchen running Tasmota. There are two switch inputs on the Dimmer module, so I have it behind a 2 gang wall box with two physical switches. Each switch is connected to one of the switch inputs of the Shelly.

I’ve set the switches to be independent of each other, so I can potentially use the different switches for different triggers. Switch one is configured as a push button switch and dims my kitchen lights. Switch two does nothing. I desire to have switch2 trigger my dining room lights, so after some digging I discovered that I can use MQTT to make Home Assistant do stuff! Perfect.

But not perfect. I set up an automation to listen for this devices’ MQTT topic “tele/lights_kitchen/SENSOR” and when the switch is flipped either up or down, my mosquitto broker hears that topic, and it just toggles my lights! I thought I had it all figured out. But what I didn’t notice at first, is that the Shelly Dimmer pings out an MQTT status every so often, even if no switches are flipped. So my dining room lights have been going on and off all afternoon!

There is some data in the payload of the MQTT that I think should be able to fix my issue, but I’m having trouble conceptualizing how.

The payload contains a key:value pair {“Switch2”:“ON”} or “OFF”. So I’m hoping I can use a change in that value as a toggle. Because it’s operating as a 3 way switch, I don’t care if the actual value is ON or OFF, I just want to know if it’s changed. Do I need some sort of helper that keeps track? This seems like something MQTT would be good at, but I can’t find a good example to steal the right config from. I thought maybe I could use two triggers, one for each state, but that makes a huge complicated set of logic that needs to be added, and I really feel like there should be a more elegant way to handle this.

Any assistance?

  • bastion@feddit.nl
    link
    fedilink
    English
    arrow-up
    1
    ·
    4 months ago

    There’s a HACS integration called ‘variable’ that might help. Create the variable, then just:

    • check if variable equals switch state
      • if not, flip switch, and update the variable to the current switch state