Trigger is very slow. What's happening?

I’ve an automation with a trigger based on an binary_sensor to on.

   - alias: Cmd Porta Abitazione One Shot
    description: FuoriPorta Abitazione
    trigger:
      - platform: state
        entity_id: binary_sensor.pulsante_fuoriporta_abitazione
        to: "on"
    condition:
      - condition: state
        entity_id: switch.porta_abitazione
        state: "on"
    action:
      - service: script.turn_on
        entity_id: script.porta_abitazione_open

The problem is that sometimes it takes 2 seconds from the event to the start of the automation

How can I investigate this?

My first assumption would be that your hardware is overloaded.

My second would be that there’s something going on in that script.

I’m going to add few sensors from systemmonitor to check what’s happening when it happens.
I don’t think that the script can be the problem, as it is happening after the delay from the trigger, or I’m missing something?

There are a few options you can add to the end of your code that might help.

Parallel Actions (scroll to bottom)

I have a few of these and they work great. I use it for mirroring light switches and brightness. Whichever light is secondary always follows the first switch immediately. If that doesn’t work I’d suggest sharing your script that this automation is triggering for more insight.

Good luck!

I’ve another example with the system monitor on.

This is the logbook:

It took three seconds to start the triggered automation.
At that time, 15.46.19, that was the monitor

It doesn’t seem I was running out of resources, isn’t?

@zgadson Thank you for your suggestion, but assuming the logbook is correct, I think the problem to understand is why is taking three seconds to start a trigger.

This is the system when it is triggering within a second.


@Tinkerer do you have an idea on what can be the problem based on the system logs? Do you still think that this can be a HW problem?

1 Like

No idea what’s going on TBH, though the 15 second interval on the CPU load may be hiding things. It may also be an I/O issue.

Even on a Pi3 I never saw multi-second delays like this.