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?

  • infeeeee@lemm.ee
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    3 months ago

    I’m not familar with shelly, but they don’t use MQTT autodiscovery? If they use it you should have a corresponding HA entity or device of each switch. Then you can use built in tools or templates in automations, and don’t directly mess with MQTT. That’s much easier and stable.

    If they don’t use autodiscovery you can create HA entites via configuration.yaml manually

    • Nimrod@lemm.eeOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      3 months ago

      Yeah, Tasmota has ‘setoption19’ to enable autodiscovery, and I triggered it, and it finds a whole host of SENSORS - but none of them are the switches. It does add one entity which is a single switch. But it seems this just correlates to switch1. I’m thinking it has something to do with how I originally set up the dimmer… it was years ago, so I guess I need to dig into my notes and see if I can figure out what options I set on it before I moved it to it’s current spot.

      for reference, the data spit out by Tasmota: {“Time”:“2024-08-29T15:17:19”,“Switch1”:“OFF”,“Switch2”:“OFF”,“ANALOG”:{“Temperature”:35.1},“ENERGY”:{“TotalStartTime”:“2021-07-13T17:05:01”,“Total”:37178.152,“Yesterday”:0.000,“Today”:0.000,“Period”:0,“Power”:0,“ApparentPower”:0,“ReactivePower”:0,“Factor”:1.00,“Voltage”:117,“Current”:0.000},“TempUnit”:“C”}