Because you were talking about the dimmer, read this thread…
There’s a similar custom device handler for the switch too if you have some of those.