I have an automation called Light toggle (Dad office) that is listening to:
When: switch goes from off to on
Then: call service light toggle
I would like to use the same switch to have the press of the button for less than 1 second wil toggle the light and between 1 second and 2 seconds will change the light to low intensity.
Right. In your automation, you just need to trigger on the hold_action event. However, it will vary depending on what kind of physical switch you have and how you have it connected to HA (ZHA, Zigbee, Tuya, etc.
What kind of physical switch is it? How is it connected to HA? Have you looked at the events to see what actions the switch supports?
I have a physical switch (not in lovelace) on my wall that is from IHC but is fully recognised by home assistant.
As I said, I want to control a short and long press of this switch in the wall to toggle 2 different lights from the same switch in the wall.
I insist on the fact in the wall because I tried to look how to do it and the hold_action seems from the documentation to be used in the lovelace button.
But what I want to do is do it for my switch in the wall, not in lovelace. I have at the moment the following code:
Right. I get that. But it depends on if the wall switch supports long presses. If it does, depending on how you have it connected to HA, you should be able to see if it supports a hold action. Not all wall switches do. Do you know what model it is?
Honestly, I’m not sure. I’ve never heard of this brand. But, it looks like the switches are simply Boolean on and off. There’s no hold actions that I can see.
What you can do, is go to /Developer-Tools#States find the switch, and check the current State
Then press 1 second, see if it change state, and to what !, And same if you hold the switch/button pressed
Some buttons is either mend for i.e trigger/toggle( Direct or through a relay ), or as i.e a “start-motor” button " hold it in untill engine runs, release it" … This is basically “same signal”
When you click it fast power runs through it, until you release, if you hold it longer power runs through it untill you release
So if it works like this, it should go from off to on, when you press it, then go back to off, when you release it. Hold it for 5 seconds and see if it’s the same “pattern”
Then you can use this in a Condition. I.e If on for 3 seconds, do something else
Perhaps what your looking for is a blueprint to use in an automation. I used this blueprint. If I pressed for less than 1 second on a physical switch which was seen in HA it turned a light on and if I held it for more than 2 seconds it turned the TV on. Short, long or double click