This configuration seems to work (using a white dimmer to create a switch). It’s very similar in approach to the YAML template that was originally posted by @jvm33 (I think) a while ago but using the template generator. I’ve used variants of that original template on most of the dimmers configured for On/Off operation that I have installed.
The dimmer itself is marked as “hidden” (“Visible” is unchecked).
Note that in the “Actions on turn on” and and “Actions on turn off” you must add the entity associated with the dimmer not the device,
