Inconsistent Execution Time for Simple Automation

Hi everyone,

I’m encountering an inconsistency with the execution time of a very simple automation in Home Assistant, and I hope someone can help me understand what’s going wrong.

Issue: The automation is set to toggle the bedroom lights when a button is pressed. Sometimes the automation executes in less than a second, but other times it takes around 5 seconds. Below are the details of the automation and the trace timelines from two different executions:

Automation Configuration:

- id: '1716233469374'
  alias: Turn on bedroom lights
  description: ''
  trigger:
    - device_id: 2cb29f233ce0c7bd1a1534e0eb328fe7
      domain: zha
      platform: device
      type: remote_button_short_press
      subtype: button_1
  condition: []
  action:
    - service: light.toggle
      data: {}
      target:
        area_id: bedroom
  mode: queued
  max: 10

Trace Timeline 1:

  • Event: zha_event at May 21, 2024, at 11:28:27 PM
  • Action: Light ‘Toggle’ on Dormitorio
  • Lights turned on:
    • light.luz_dormitorio_1_light
    • light.luces_dormitorio_techo
    • light.luz_dormitorio_2_light
  • Finished: May 21, 2024, at 11:28:27 PM (runtime: 0.39 seconds)

Trace Timeline 2:

  • Event: zha_event at May 22, 2024, at 6:58:28 AM
  • Action: Light ‘Toggle’ on Dormitorio
  • Lights turned on:
    • light.luz_dormitorio_1_light
    • light.luces_dormitorio_techo
    • light.luz_dormitorio_2_light
  • Finished: May 22, 2024, at 6:58:34 AM (runtime: 5.55 seconds)

As you can see, the first execution took only 0.39 seconds, while the second one took 5.55 seconds. Both traces indicate that the event and actions are the same, but the execution time differs significantly.

Has anyone experienced similar issues or can provide insights into why this might be happening?

Thanks in advance for your help!

Try using endity_id instead of device_id

Communication latency.

What is the integration used to communicate with the lights? Do the three lights uses the same integration?

For example, do all three lights communicate via Zigbee and you’re using ZHA integration?