Hi,
Is it possible to have something in a script/automation that will only allow one activation of a button hold command? I’d rather not reduce the time for all button hold actions as this will slow other actions down.
Hi,
Is it possible to have something in a script/automation that will only allow one activation of a button hold command? I’d rather not reduce the time for all button hold actions as this will slow other actions down.
In case anybody comes across this, I found a fairly simple solution. I use a button hold command to trigger a script, which switches a Hue dimmer remote between controlling the lights or the blind. When I was holding the button, it would send repeat commands too quickly, and end up sending 2 or 3 commands when I only wanted to send 1 command.
I created a trigger that fires on the change of state of the script:
platform: state
entity_id:
- script.light_blind_toggle
to: null
id: Light/Blind Script
I then made an input boolean which is is turned on for 2 seconds when the script changes state:
- condition: trigger
id:
- Light/Blind Script
sequence:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.living_room_blind_lights_inhibitor
data: {}
- delay:
hours: 0
minutes: 0
seconds: 2
milliseconds: 0
- service: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.living_room_blind_lights_inhibitor
Then set an if condition for the button hold command that only lets it fire the script if the input boolean is off:
if:
- condition: state
entity_id: input_boolean.living_room_blind_lights_inhibitor
state: "off"
then:
- service: script.light_blind_toggle
metadata: {}
data: {}
This means it will only repeat the button hold command every 2 seconds, which is about right for me. The default Z2M repeat time is around 1 second, maybe less, which was too fast. You can obviously change the 2 seconds to whatever you would prefer.
I also added a TTS section in the script so I know which mode I have it set to:
- condition: state
entity_id: input_boolean.living_room_blind_lights
state: "on"
then:
- service: tts.speak
metadata: {}
data:
cache: true
media_player_entity_id: media_player.nest
message: Blind
target:
entity_id: tts.google_en_com
else:
- service: tts.speak
metadata: {}
data:
cache: true
media_player_entity_id: media_player.nest
message: Lights
target:
entity_id: tts.google_en_com