Think I have tried everything… except the right syntax.
How do I get the activate-button for my switch (Hassio 0.71.0)
This is not working:
switch.clear_log_ha:
can_cancel: false
- platform: template
switches:
clear_log_ha:
friendly_name: "Clear log HA"
value_template: "{{ 'off' }}"
turn_on:
service: script.clear_log_ha
turn_off:
service: script.dummy
silvrr
June 19, 2018, 8:39pm
2
Why create a switch?
Add “script.clear_log_ha” to your front end and it will appear with an “Active” button in blue text. If you click it the script runs.
If you are wanting to call this function in a automation, you can just call the script.
2 Likes
I read in the forum previously doing it like you describe (did not find it in the documentation), - did not work.
Tried it again now after cleaning up what I had coded, - and it works.
Thanks.
Even though I am using a script, my frontend displays a toggle switch and not “execute” (=“Ausführen” in German).
I copied one of your scripts @silvrr (your config is awesome btw, well ordered, clean and minimal. Great inspiration. Love it.) and modified it to my needs. But as you can see on the screenshot, there is a toggle switch in the backend. Does this appear because of the delay or because I call five scripts in one script?
Screenshot:
Script:
script:
receiver_volup:
alias: "Script - Volume Up AVR"
sequence:
- service: remote.send_command
data:
entity_id: remote.media_center
command:
- VolumeUp
device: 49404339
receiver_volup_5x:
alias: "Script - Volume Up 5x AVR"
sequence:
- service: homeassistant.turn_on
entity_id: script.receiver_volup
- delay:
milliseconds: 5
- service: homeassistant.turn_on
entity_id: script.receiver_volup
- delay:
milliseconds: 5
- service: homeassistant.turn_on
entity_id: script.receiver_volup
- delay:
milliseconds: 5
- service: homeassistant.turn_on
entity_id: script.receiver_volup
- delay:
milliseconds: 5
- service: homeassistant.turn_on
entity_id: script.receiver_volup
I tried:
Changing
-service: homeassistant.turn_on
to
-service: script.turn_on
= same result
silvrr
December 14, 2018, 12:49pm
5
The delay causes this. It’s in the docs at the bottom of the component page on scripts.
1 Like
adding the following line in a customize entry will change the toggle back to “Activate”:
script.<name_of_script>:
can_cancel: False
edit: this applies to a script with a delay in it.
2 Likes
Thanks for your replies.
Found the information at the component page. Never read that far…
can_cancel: false
“fixed” it.
MikeVR
June 14, 2019, 10:53pm
8
Note! can_cancel MUST be in customize.yaml