Hold action - example?
Any example of hold_action? I have this code working:
tap_action:
action: call-service
service: script.executa_hisense_volume_up
service_data:
entity_id: script.executa_hisense_volume_up
How to add hold for Volume up?
What do you mean by hold_action? You want it to repeat the action while you hold the button?
Yes, exactly. I want to hold the Volume Up (etc) and increase volume.
Then it's by using repeat:
hold_action:
action: call-service
service: script.executa_hisense_volume_up
repeat: 500 # will run the action every 500ms
service_data:
entity_id: script.executa_hisense_volume_up
# Volume up
- type: 'custom:button-card'
entity: script.executa_hisense_volume_up
icon: mdi:volume-plus
name: Volume up
show_name: false
show_label: false
font-size: 12px
styles:
card:
- width: 50px
- height: 70px
- background-color: '#333'
- margin-left: 10px
- margin-top: 10px
- border-top-right-radius: 40px
- border-top-left-radius: 40px
name:
- font-size: 12px
- color: '#999'
- align-self: middle
- justify-self: center
- padding-bottom: 4px
icon:
- color: '#999'
- width: 40%
tap_action:
action: call-service
service: script.executa_hisense_volume_up
service_data:
entity_id: script.executa_hisense_volume_up
hold_action:
action: call-service
service: script.executa_hisense_volume_up
repeat: 200 # will run the action every 500ms
service_data:
entity_id: script.executa_hisense_volume_up
This is my full code, but it doesn't work ;(
Can you be a bit more explicit than "it doesn't work"?
Yes, sorry.
I press Volume UP - and in just a few seconds seems volume increasing. Issues:
- It works just for a few seconds of holding - then it stops increasing volume
- Increasing is too slow, like 1 point per half-second
Then you need to modify your script to make bigger increments in volume each time it's fired.
Also 200ms is a bit low between repetitions, I'd increase this to 500ms.
I'm facing the same issue. The repeat does work but only runs a handful of times before it stops. My guess is some other javascript hold event is taking over and preventing subsequent increments from happening? If this is the case, if it could be reproduced on the developers side, is there a possibility to fix it by somehow not bubbling the hold event up to the browser or whatever might be 'taking over' and stopping the nth repeat from kicking in. For me it feels like maybe 2 or 3 repeats usually work but after that none fire.