Simple script interface question

Hi everyone, I’m beginning to work with scripts, I have done some simple ones, but now I’m a bit stuck with an interface issue

The script is :

garage_opener:
  alias: 'Garage'
  sequence:
    - service: switch.turn_on
      entity_id: switch.switch_sh1_02
    - delay:
        seconds: 1
    - service: switch.turn_off
      entity_id: switch.switch_sh1_02

The problem is that in the overview I get this interface
28

If I have a script with a single sequence element, i.e.

garage_opener:
  alias: 'Garage'
  sequence:
    - service: switch.turn_on
      entity_id: switch.switch_sh1_02

the interface is the following (much better)
20
( ESEGUI is RUN in Italian )

So can I control the interface and have a RUN button instead of the awkward toggle ?

The first script contains a delay statement. All scripts containing delay are represented in the UI with a toggle button.

The toggle button allows you to abort the delay.

You get the “awkward toggle” whenever a script has a delay or a wait_template. This allows you to stop the script if it’s in one of those wait states.

@123 you beat me to it.

second!! :slight_smile:

Thank you all for your answers, by which I can guess there’s no solution :unamused:

Ciao

Claudio

If it’s really important to you to have the button instead of the toggle… I don’t know for SURE if this will work but I think so…

garage_opener:
  alias: 'Garage'
  sequence:
    - service: script.garage_opener_real

garage_opener_real:
  alias: 'Garage Real'
  sequence:
    - service: switch.turn_on
      entity_id: switch.switch_sh1_02
    - delay:
        seconds: 1
    - service: switch.turn_off
      entity_id: switch.switch_sh1_02

If you remove the delay, does the script operate the garage door correctly? The real-world delay between the two commands (turning the switch on then off) will be less than a second but maybe that’s still sufficient to trigger the door.

@swiftlyfalling Yes the two script strategy works perfectly, don’t like the double script but I will sort it out in the future when interface will be finalized.

@123 thank you for the tip, unfortunately the on-off call sometimes is too fast, so it doesn’t always switch the relay, and my garage door button needs at least some tenths of seconds to do a proper work

Thank you both again

Ciao
Claudio

1 Like

If after turning switch_sh1_02 to on you always want it automatically return to off (after a 1-second delay) then this behavior can be achieved with an automation.

automation:

- alias: 'turn garage switch off'
  trigger:
    platform: state
    entity_id: switch.switch_sh1_02
    to: 'on'
    for: '00:00:01'
  action:
  - service: switch.turn_off
    entity_id: switch.switch_sh1_02

Now your script is simplified to this:

garage_opener:
  alias: 'Garage'
  sequence:
    - service: switch.turn_on
      entity_id: switch.switch_sh1_02

Hi Taras,

you’re right, I think this will work as the two script method.

Since the relay is a shelly (probably a sonoff sv in the future) and I’m using esphome right now, I’m trying to see if I can get the same result programming the esphome to just get ahold of the impulse process, and then fire a single script to ‘open the door’

Thank you

Ciao
Claudio

If you’re using ESPHome you can program the off automation in it as well.

@swiftlyfalling

Hi, sorry for the delay , I was out of town for a couple of days.

I managed to put the ‘impulse’ automation into esphome adding the switch.on_turn_on automation to the device configuration

switch:
  - platform: gpio
    name: "Switch SH1 02"
    pin: GPIO04
    id: relay_sh1_02
    on_turn_on:
    - delay: 500ms
    - switch.turn_off: relay_sh1_02

now I just fire the script with a service: switch.turn_on call and the device does the rest.
I like this solution as the device itself takes care of the job and hass.io just tells it to do it

Thank you all for the help.

Ciao

Claudio

1 Like