I have 2 scripts that dome several things. In the frontend one has an “activate” link, the other an on/off switch. I can’t see what’s the difference between these scripts.
Any idea why the frontend looks different for these?
The default behavior for a script is “ACTIVATE” I’d like to see your config.
If there is any kind of delay or wait in your script, it will show as a toggle and not as Activate. Post your script and maybe we can see something.
Yes, one script has a delay, the other does not. Why is a script with a delay shown differently?
Scripts with delay can, in theory be stopped while being executed, reason for which they appear as a switch rather than Activate (turning switch off is to cancel script execution).
You can have it show always as Activate / Switch, by using can_cancel: false
/ can_cancel: true
in customize section of configuration.yaml.
For example, I have a script that turns on my fan, waits forty minutes, and then shuts it off. If I turn off the script itself during that time, the fan will stay on.
Thanks for this information. This makes sense i many cases. I will just use the customisation.
Hey,
i did it in my file, but still, i have on/ off only
switch.philips_tv:
friendly_name: "Philips TV"
can_cancel: true also / false
The example you were looking at was listing the two options for can cancel:
which are true
or false
. So, because you don’t want to be able to cancel the script running, you should write your customize like this:
switch.philips_tv:
friendly_name: "Philips TV"
can_cancel: false
Yes i did it, still not working
switch.philips_tv sounds like a switch, can_cancel is for scripts?
my I do some think worng
where i need to add the can_cancel: ?
Because the switch.philips_tv is a switch, it can only be off or on. Perhaps you could do some custom UI thing to change it to say “activate / deactivate,” but the original poster’s problem was that he wanted a script to show only the activate button.
This link will be much more helpful in describing what a script is.
sorry I still do not understand what I need to do I order to get a activate button …
i be happy if anyone can share me a code for sample
in your customize.yaml
script.script1:
icon: mdi:timelapse
can_cancel: false
yes, i did it… still did not show.
I’ll say it again. Those are switches not scripts.
As switches I assume they show a switch?
What are you trying to show? Please explain again!
never mind, Thanks… i will stay with on / off button .
Apologies for opening up an old thread but wasn’t sure if protocol is to open a new thread or add to existing thread on a topic.
I’m struggling to get can_cancel to work within my yaml configuration.
I have edited my configure.yaml and included the following code
homeassistant:
customize: !include customize.yaml'
and also created a customize.yaml file and included the following code
script_heat_downstairs:
can_cancel: false
script.1645352977749:
can_cancel: true
Following a reboot I still get both scripts offer me the capability to both run and cancel. I thought the code would allow me to stop the first script being cancelled.