How to speed up Home Assistant automations with Parallel runs


Automations in home assistant by default run on a sequential basis, this means that each action will be run in a sequence one after the other waiting for the previous to be complete.

Parallel runs allow home assistant to run actions at the same time and not wait for the previous action to be complete.

In the example below I’m turning two lights on wrapped up by the parallel mode.

to add parallel mode, click add action and add parallel.

if you are more of a YAML user this is how you can add them in:

action:  
  - parallel:      
    - service: light.turn_on        
      entity_id: light.hue_color_candle_1      
    - service: light.turn_on        
      entity_id: light.hue_go_1

this is the version of the same code in sequential mode

action:       
  - service: light.turn_on        
    entity_id: light.hue_color_candle_1      
  - service: light.turn_on        
    entity_id: light.hue_go_1


Caveats

Why not just always do things in parallel right?

Let me give you a few reasons why you might not want to do that:

  1. Even if home assistant will execute both actions in parallel that doesn’t mean that they will be received at the same time and the order is not guaranteed.
  2. Variables within one parallel context will not be share with the other.

Gio

Gio loves rabbits, smart home tech, WWII, travelling to Thailand & my favourite pizza is margherita with parma ham!

Recent Posts