Script delay milliseconds is broken?

So I created the following script:

'1535060106362':
  alias: East Garage Door
  sequence:
  - service: homeassistant.turn_on
    entity_id: switch.ohd_nbay_east
  - delay:
    milliseconds: 200
  - service: homeassistant.turn_off
    entity_id: switch.ohd_nbay_east

When I ran the “Update Scripts”, I was given the following error message:

Invalid config for [script]: [delay] is an invalid option for [script]. Check: script->script->1535060106362->sequence->1->delay. (See /config/configuration.yaml, line 70). Please check the docs at Scripts - Home Assistant

So I went over to the scripts documentation page, and it clearly lists that I should be able to do exactly what I showed above.

I tried an alternate method that does seem to work:

'1535060106362':
  alias: East Garage Door
  sequence:
  - service: homeassistant.turn_on
    entity_id: switch.ohd_nbay_east
  - delay: 00:00:00.2
  - service: homeassistant.turn_off
    entity_id: switch.ohd_nbay_east

It didn’t throw any errors when I used this script instead. Has the alternate version of delay been depreciated??

I’m running hassio v0.76.2 on a Pi 3 B+ 64bit with the hassio image.

1 Like

Try indenting "milliseconds under the delay key. Like so:

  - delay:
      milliseconds: 200

You will probably find that delays under a second or so have widely varying actual timings depending on the system load as the call to the delay routine can take up to a second. If you really need a reasonably accurate sub second delay there are horrible workarounds like this this for example:

hello!

- delay: 00:00:00.2

works great for me thank you. I always used the milliseconds before but this seems to be broken.

thx

What you have is equivalent to 200ms. Home assistant works on 1 second listeners. There is no way you can guarantee less than 1 second delay.

Ah ok that’s why they bit different every execution.

That was my workaround for bringing my Venetian blinds in position. They need 1,5 sec for one turn…

So you think 1.2 will work but not 0.4 right?

Thx for Info

It’s asynchronous. So the minimum time possible will be 1.2s but as the event listener only updates every second it could be up to 2s.