Hello, I have a set of automation switching on light and separate ones swithing off the lights. I want to create a dashboard button that at 1 press switches on at the 2nd push switches off the lights. The automation is basically for our house maid, when she comes to switch all lights on or off by the press of 1 button. The lights are triggered by motion sensors or time of the day.
Maybe asked differently, how can I toggle between 2 separate actions by the same dashboard button?
Maybe a very simple ask but I have not figured out how it worked. Any help?
Create a script.
Action in the script â light.toggle.
Add script to dashboard
Hi, as previously explained: a script controlled by a button.
An automation needs a trigger and even that is possible with a dashboard button but not straightforward.
If the automation you are using is not intended for something else, itâs not good practice to do it that way.
If, on the other hand, you also need the trigger for some other scenario, you can add the script as an action so that sequence is running with that trigger and you can separately start that script as well with a dashboard button.
Just some ideasâŚ
Why not just use a toggle helper, itâs what they are for surely.
When the helper is turned on the lights come on when the helper changes to off turn the lights go off.
Or am I missing something.
I was implying that for making it work with an automation.
OTH: just using a script without extra âintermediate stuffâ (a helper) seems more foolproof, no?
Just a tile card (or similar) for the light or a light group. You donât need any automation or script or helper to just toggle lights.
So do you want to disable the existing automations with the same toggle or just switch the lights on and off?
Sorry, I jumped the wagon to fast.
As suggested by @Arh: adding a helper and using that as an additional trigger to the existing automation, which in turn can be turned on from a dashboard will be the best option IMHO.
Thank you very much for the suggestions. I still need to figure out how, at least the path: HELPER is an indication where I should improve my learning curve.
Yes, I want 1st to disable the existing switch off automations when switching on the lights and switching on the light automation when the button is on on. Makes sense what I wrote? Basically I want to activate all the switch on automations for on and disable the automation for lights off. when the button is set to on, I want to reactivate the switch off automations. Maybe not very elegant but thatâs all I came with⌠I I even dont know how to implementâŚ
Do you have one light that is very very unlikely to be on when she arrives and needs to turn on when she is there?
You can run, enable or disable automations as an action.
so when helper is toggled to on then turn run the on automation and disable the off automation
I would make a similar recommendation to what Arh and Nick have made above.
Create an Input Boolean/Toggle Helper.
Use that as a trigger for an automation to turn the lights on and off. There is a keyword all that will target all the light entities when used in light actions:
triggers:
- id: "on"
trigger: state
entity_id: input_boolean.example
to: "on"
from: "off"
- id: "off"
trigger: state
entity_id: input_boolean.example
to: "off"
from: "on"
conditions: []
actions:
- if:
- condition: trigger
id: "off"
then:
- action: light.turn_off
target:
- entity_id: all
else:
- action: light.turn_on
target:
- entity_id: all
To control the other automations you have 2 options:
- Option 1: Add the state of the helper as a condition to all your other light automations. When the helper is âonâ the other automations should not run because the housekeeper is there.
- Option 2: Add automation actions in the automation triggered by the Helper to enable/disable to other light automations.
Both options require a little code maintenance every time you add a new automation that controls lights. In the first option you have to remember to add the condition as youâre building the new automation. In the second, you have to make sure the new automation is added to the targets of the actions that will disable/enable it.
Personally, I prefer Option 1. I would rather reserve the ability to disable automations for when I need to do maintenance or testing. If other automations are programmed to enable those automations it can be very frustrating.
Thatâs my idea too but to skip the helper.
Either by looking at the motion automations state or by looking at a lights state.
So if the light is off then turn lights on and automations off.
Or if the automations are on, turn lights on and turn off the automations.
Not sure which would work best but I donât think the helper is actually needed
Tones of thanks, I know where to start now. Really appreciated.
If it needs triggering if someone is home and not at other times then use location as a trigger or condition. If then after a length of time the automation for the lights needs to become active again the you can use wait for an amount of time in the action or use a timer helper. Or another automation triggered at a certain time. The options are endless and there will be many ways to do it. Simple or complex you just have to choose what is easiest and most logical in your head.
Got it with thanks!