Why is there a 54 second delay before an automation will execute?

Augh!!! New users can only embed one image so I’m having to rewrite this without some of the screenshots. . .

Greetings. . .
I’m a noob naturally or I wouldn’t be bothering everyone with this but just to get it out of the way I’ve already RTFM and can’t find the answer and have spent 2 or 3 hours trying to figure out how to get the forum search to provide an answer but all I get is stuff that has absolutely nothing to do with my question.

I’m trying to use HA to automate a dust collector in a friends wood working shop. The idea is that when any of the tools get activated the dust collector turns on and when all are off the dust collector runs for 2 or 3 more minutes then shuts down.

I’m using a Raspberry Pi 3 and a Sonoff S31 along with an ESP8266 Node MCU to configure a test set up. The ESP8266 has an on board LED that I used to test HA configuration by creating a “Hello World turn the LED on” ability to see how HA works. I bought some Sonoff S31 wifi switches with build in current monitoring and flashed them using ESPHome. Both devices are working via the Overview and Generic dashboards.
Devices

I wrote 2 automations based on the current sense capability of the S31 to monitor current. At present a floor fan is used to simulate a wood working tool so that if the fan is on i.e. current above 0.3 (fan draws 0.5 amps in normal operation) then the LED on ESP8266 is turned on. This should simulate a tool being turned on and the command to turn on dust collector. The second automation is set up that if the current drops below 0.2 then check if ESP8266 LED is on and if so then turn it off.

The automation scripts seem to run OK but they take a LONG time to trigger. According to Logbook both automations are taking 54 seconds to trigger. The delay is consistent (sorry, had to manually enter as sceenshot was not allowed):

ESP8266HellowWorld Onboard LED turned on triggered by automation Fan Monitor On triggered by numeric state of S31-001S31-001 Current
20:57:54 - 34 minutes ago

Fan Monitor On triggered by numeric state of S31-001 S31-001 Current
20:57:54 - 34 minutes ago

S31-001 S31-001 Relay turned on triggered by service Switch: Turn on
20:57:00 - 35 minutes ago

Here’s the ON automation (was originally a screenshot of the built in automation editor now YAML):
alias: Fan Monitor On
description: Test to see if monitoring current draw can trigger different device
trigger:

  • platform: numeric_state
    entity_id: sensor.s31_001_s31_001_current
    for:
    hours: 0
    minutes: 0
    seconds: 0
    above: 0.2
    condition: []
    action:
  • type: turn_on
    device_id: d72d05b23966e4f0208fb76f677b67f8
    entity_id: c4b914e66e280110c83840805f199487
    domain: light

Does anyone have an idea why the automations are taking 54 seconds to trigger? From my reading I thought the resolution of automations was 1 second.

Or can anyone suggest search parameters that might point me in the right direction on finding answers in the forums maybe? Things like “automation delay too long” and “automation timing” and “automation execution time” and other assorted search phrases give me lots of answers that have nothing to do with what I’m trying to find. BTW, I tried a LOT of different search criteria to no avail. The above are just examples.

Thanks for any assistance you can provide

This is likely a polled sensor and only updates on a fixed interval. You don’t mention which integration you used to add the sensor so it is not possible to say for sure or what that interval is.

Have a look at its history graph in the History Panel and zoom in to a short time period using the time selectors. How often does the sensor update?

Make sure you use local push where ever possible and avoid cloud and especially cloud pull.

Sonoff devices can often be configured to run as local push, sometimes with anothet firmware.
ESPhome firmware might also be an option for these.

1 Like

Thanks for the prompt response guys.

@Tom Not sure what you mean by “which integration” but I used ESPHome default configuration for the S31 to generate the upload to the device and HA located it properly once it rebooted. I also tried to do as you suggested and use the history graph. I selected a 10 minute (20:05 to 2015) timeframe from yesterday during one of the test periods but the the graph refuses to show anything other but a 21 hour chart no matter what I try.

@Wally Not sure what you mean by “local push” (newbie remember) but I don’t do anything in the cloud. The whole reason I went with HA was to avoid ANY cloud based product, device, app, etc. That was why I used ESPHome to flash the S31 to the ESPHome instance of the S31 configuration.

I missed that you already use ESPHome, but read this one then.

Wow, that was fast. I don’t understand why my searches did not report that in the results.

Thank you very much. I’ll see what it says here in a moment.