Script shown with switch instead of "activate" in the UI

Hi,

I’ve started using some small scripts, mainly to have a timed light that activates through motion detection.
I have one script that shows in the UI with a switch next to it. All other scripts have an “ACTIVATE” link next to them.
Why is that?

This is the script (called timer_off.yaml - you might recognize it from the examples page…):

  alias: 'turn off lamp after set time'
  sequence:
    - delay:
        seconds: 30
    - service: light.turn_off
      data:
        entity_id: light.hifi_rack

TIA,
Sebastian

Scripts with delay, can be canceled during run time. Therefore they have a switch to make that functionality available to the user

2 Likes

Thanks, that makes perfect sense :slight_smile:

Sebastian

Yes thanks, that does make a lot of sense as a standard (and this was slowly but surely driving me crazy; always nice to find the answer in a search). Can’t help wondering though, is there any way to modify this?

Hello @Aephir! Have you managed to fix that? I am also facing this behavior with multiple actions scripts showing as switches. Thanks!

@Schneider Well, sort of. What you could do is make a new script, referring to the script with the delay.

In my scripts (below), the “Shut Down Media Center” has a delay, since I’m doing a proper shutdown on a few Raspberry Pi’s, and then cutting the power to a Z-wave switch after they shut down.

BUT! The script “We’re Going to Sleep” activates the “Shutdown Media Center” as part of it. So there are delays in the sequence, but technically not in the “We’re going to sleep” script, and it shows an “activate” instead of a switch.

So my best bet is refer to your “switch” script from within another script, that doesn’t have delays (probably not an elegant way, but it works).

EDIT: @VDRainer And there’s the elegant way :slight_smile:

Do you know about the customization can_cancel: false ?
Here is an example.

1 Like

The “can_cancel: false” doesn’t seem to work anymore. Is there another current solution or did I do something wrong?

1 Like

Same question, and answer:

in customize.yaml

script.scriptname:
  can_cancel: false
2 Likes