Clarifying Understanding of parallel actions and the delay

Afternoon All

I am trying to put in a place a simple automation where a fan is put on for a set time and then turned off again. Previously, I woudl have created a autoanton rule to turn on and then another to turn off at a set time…

Was just playing about today and am sure there is a simpler way within one Automation rule to do this… So got playing with parallel actions coupled with a delay… But it doesn’t seem to be working and when I enable the parallel action - they don’t turn on…

Am i missing something? Maybe mis-understanding a simple way to achieve this?

alias: Smelly-AM
description: Turn on diffusers in the morning
trigger:
  - platform: time
    at: "13:50:00"
    enabled: false
condition: []
action:
  - type: turn_on
    device_id: 769b415debf12cdcd8905dffa639e60e
    entity_id: 0641a1d386982264a61fdd9bed91dbfb
    domain: switch
  - type: turn_on
    device_id: 95390fb22284a0f7772326bbc8a5407e
    entity_id: eb0df1ffc2c19e3da6089394ba21d066
    domain: switch
  - parallel:
      - delay:
          hours: 0
          minutes: 1
          seconds: 0
          milliseconds: 0
      - type: turn_off
        device_id: 769b415debf12cdcd8905dffa639e60e
        entity_id: 0641a1d386982264a61fdd9bed91dbfb
        domain: switch
      - type: turn_off
        device_id: 95390fb22284a0f7772326bbc8a5407e
        entity_id: eb0df1ffc2c19e3da6089394ba21d066
        domain: switch
    enabled: true
mode: single

I think you misunderstood what parallel actions are. The actions nested under Parallel are initiated at the same time. In your example, switch 1 turns on then switch two turns on; then at the same time commands are sent to turn off both switches and start a delay. The delay runs for 1 minute then the automation stops.

Also your trigger is disabled.

Thanks for replying : was thinking that and reading the documentation to get a better understanding of the action…

Is there a simpler way to achieve my delay job? Or just live with two separate automation rules?

I thought it would have paused for 1 min before executing that parallel action

Just ommit the parallel.

I am sure your switches turn on in a split second so there is no need to execute the two in parallel. It can actually harm if the mechanism you use like Zigbee could not handle them in parallel anyway.

You want to turn on the two switches.

Wait 1 minute

Turns both off again as a normal sequence

A simple delay should be fine.

If you wanted a delay of hours then I would advice having two automations because should you restart HA in the period the switches are on - they will remain on until the next day

follow up

The


  - parallel:
      - delay:
          hours: 0
          minutes: 1
          seconds: 0
          milliseconds: 0
      - type: turn_off
        device_id: 769b415debf12cdcd8905dffa639e60e
        entity_id: 0641a1d386982264a61fdd9bed91dbfb
        domain: switch
      - type: turn_off
        device_id: 95390fb22284a0f7772326bbc8a5407e
        entity_id: eb0df1ffc2c19e3da6089394ba21d066
        domain: switch

does the following.

It parallels 3 actions. It starts a delay of 1 second. And it turns off the two switches in parallel right away. When the delay expires after 1 second the two switches are already turned off. The delay just delays the time before the automation can be retriggered which is irrelevent as it only gets triggered once per day at specific time. The parallel only does harm.

Your switches turn on and immediately off as you made it

1 Like

yeah have it delayed for testing while i tried to better understand the parallel aciton and delay