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.
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:
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.
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.
Can for the quick response. I’ve read through the link you provided but I can’t seem to find out how I now stop a script being cancelled.
Currently I’m trying to setup a Lovelace button to run the script but not offer the option to cancel the run. I’m using a button entity and on the first click it runs the script but if the user clicks the button again it cancels the script. Any ideas how I can stop the script being cancelled if can_cancel has been removed as an option?
My understanding is that this is no longer possible, not sure exactly why, but probably due to the improvements/changes introduced in scripts from 0.113 on…
@pplucky - Thanks for pointing me at the latest documentation. I can see what they’ve done and now realise it’s how you call the script. I’ve now called the script using the following code and it works. First click runs the script and second click doesn’t do anything.