So, if I’m understanding right, you want to be able to tap the button, and if the light’s off, turn it on to a low brightness, tap it again and turn it to full brightness, and tap it again to turn it off?
You could call a script, passing the entity_id in and evaluating the current state of the light to decide which action to take. Let me know if you need additional guidance and I can help you put it together later.
Hi, that’s exactly what I’m looking for. I figured that it could be done with some script, however I never worked with those before. Would be awesome if you could help out.
I have a philips Hue system connected, and can control the lights directly from Home Assistant. the current entity I’m working with is “light.sidetable” and it just switched on/off now, however in the info-window I can choose a differen colours and brightness. No idea yet how I need to add this to a script.
Right… That’s because whenever you assign a width or a height to the card, I assign actually those properties to the container of the card itself. When you wrap it, it can’t work. It would need another card around again
Your config works just fine for me, however you are missing one - in front of width and quotes around the last operator.
Put the horizontal-stack with all the elements inside your conditional card, not a conditional card for each element inside your horizontal-stack.
A script would be possible, but it’s going to be a bit more complex to understand if you’re starting with Home Assistant. My suggestion for this is to use a input_select with 3 values (on, dim, off) add an automation triggered based on the input select value to do what you want (turn off, set dim and turn on) and then on the button-card the tap_action would be:
For learning purpose, this is the solution with a script. It would look like this (didn’t test, but should work). Compared to the other solution, this one is completely generic and you can reuse it just by changing the light in you call to the script. No need to have a lot of input_select etc…:
@hwoltering@RomRider the nice thing about the script is it can be reused for multiple lights/buttons. @RomRider the script you posted looks good to me other than the fact that I think it is going to go Off > Full > Dim instead of Off > Dim > Full. Here’s an updated version (disclosure, I haven’t tested either):
@apop@RomRider
Thanks both for the quick help. I actually tried both, but I think for future use it’s easier to use the script-version (I have many lights, so can use it for all of them). I will do have a look at the input select option too, as I want to understand all possible options. Surely both come in handy somewhere anyway.
The script goes not from off to dim to full, however it does not turn the lights off on the third tap action. I’ve checked the light state on the full brightness, but it then indicates to be 254 instead of 255.
Whe I tried to change the script from 255 to 254, it gives me an error:
Failed to call service script/dim_on_off, extra keys not allowed @ data[‘brightness’]
I also tried to change it to less than 250, but that also didn’t work. The changes I tried:
{% if state_attr(light, ‘brightness’) | int != 255
{% if state_attr(light, ‘brightness’) | int != 254
{% if state_attr(light, ‘brightness’) | int !>= 250
{% if state_attr(light, ‘brightness’) | int < 250
And the same thing for the line further down:
{% elif states(light) == ‘on’ and state_attr(light, ‘brightness’) | int != 254 %}
Any ideas what I can do here?
ps. how do I add code in a nice box in these comments?
If you used my version, try by just removing the last else 0 in the brightness object.
2nd option (I think this one is even better), keep the else and replace the whole block of service_template with just service_template: light.turn_on
Is there a way using the button to show feedback? I have a bunch of buttons that are 1 liner scripts that have no on/off status. I’d like to flash the button with a different style for half a second to let the user know the button was pressed. Is this possible?