Hey there. I stumbled upon your post and would like to thank you for generally making my shelly dimmer work in Home Assistant. On my own and with the provided documentation about MQTT lights, I did not manage to get the dimming slider working.
I have a question though and Im hoping you could help me out here. I would totally understand if you dont.
My lights are controlled by a Homematic Switch. It turns them on and off either through the Homematic interface (or Home Assistant) or through a physical switch. I also have a shelly dimmer to add dimming functionality. With the code you provided I have a couple of inconveniences I would like to get rid off:
I want the shelly to not send on/off commands at all. Right now, when I move the slider to the left. The shelly turns off. The relay from the homematic switch thinks the lights are still on though. So when I press the physical light button, the button thinks the light is on still. Only after pressing the button twice (homematic relay off, homematic relay on again) the lights will turn on again. Same story the other way around: when the homematic switch is off through either the physical switch or the interface, and I move the slider to the right, the homematic system thinks the switch is still off. So in order to switch off the light with the physical switch, I have to press twice again (relay on, relay off).
Is it somehow possible to configure the slider in a way that it only dims? I was thinking about a slider that sends a retained brightness message to the shelly switch via MQTT and only when I activate the Homematic Switch the shelly dimmer will dim accordingly. I tested it with MQTT.fx and know that its working. I just dont know how to implement this slider into home assistant, because every configuration in MQTT light somehow requires these on/off topics.