Goal: have a toggle button on ha dashboard that will toggle my custom led overhead lights on and off.
What I have done: I have custom WLED playlists for on and off transitions (they’re awesome). I have also setup the restful calls in home assistant that I can call from the developer options.
The bottom line: I would like a button on the dashboard that looks like a lightbulb, and will toggle my on playlist, and my off playlist when pressed.
The issue I’m having: I don’t know how to make this button on the HA dashboard.
Any advice? I’m a web developer so I’m not afraid of writing custom code if needed.
Thank you for the reply. I have a button that executes the turn on api call. The next issue I’m having is how do I make that button call the turn OFF api call when I press it again? I’d also like to have state on the button to indicate on or off.
What you want now is best done with a template light:
Don’t be bewildered by the multitude of options. They are almost all optional. All you need are the actrions for turn_on and turn_off. If you have state feedback from the light you can add a value_template as well. Otherwise it will work in optimistic mode and assume that the commands you sent from home assistant actually got there and changed the light. e.g.
light:
- platform: template
lights:
overhead_lights:
friendly_name: "Overhead Lights"
turn_on:
service: # your 'on' rest command here
turn_off:
service: # your 'off' rest command here
value_template: "{{ a template that returns 'on' or 'off' from your light }}" # optional
Restart Home Assistant.
You can then use this new light entity in an entity card (or any other card) in your frontend:
Thanks tom_I. The only issue I’m having now is the toggle switch can’t find the current state of my lights. When making the rest call, the device only returns success: true. So now my light button just keeps turning them on over and over. I’m a little foggy on the “value_template.” I think this is where I can get the lights current state. Any advice?