Disable sending "switch" state when setting MQTT light brightness

Some of my MQTT lights are dimmable and have a “switch” and “level” MQTT topic.

However, the “on” and “off” switch set the brightness to 100% and 0% respectively. The “level” topic will accept numbers from 0-100.

If I try to set a brightness level within HA, it sends the “on” switch and the brightness level, but the switch command of “on” overrides the brightness every time, setting it to max.

Is there a way to add conditional programming so that if I set a brightness, it won’t send a switch command?

It’s been discussed several times, has at least 2 bugs filed on it, and now has a pull request w/ a code update waiting for inclusion:
https://github.com/home-assistant/home-assistant/pull/9829

If you’re comfortable doing it, feel free to grab that update and test it out. I’d also recommend reading the issues referenced in that request - you can see the discussions that led up to the fix.

1 Like

Thanks, I’ll hold on for the merge and give it a go :).