I am having some trouble with a Light template. Everything is working as expected, except i can’t get the Turn_on action to work. Turn_off works properly. And if i manually turn on the light this is supposed to control, the light template updates to the correct state. Set_level also works as expected. Any help is much appreciated.
What are you trying to do with the following portion of your value_template?
Unless your switch has an attribute named “on” (which would not be normal), the state_attr() function will return null and so the if/then will always return “on”.
Thank you, I hadn’t quite understood what that was doing, I have cleaned that up. Unfortunately the turn_on command is still not working when i toggle the light template on. Here is the change I made.
My goal here is to combine the switch and the dimmer into a single light entity. I have tested the level and value template in developer tools and they are outputting on/off and 0-255 as expected.
If the dimmer is not set up to automatically change to “on” when powered, you likely need a light.turn_on in your turn_on action sequence. And you may need to include a short delay to cover the dimmer’s bootup/connection time: