ESPHome Automations as an autonomous device?

Hi, I’d like to be able build a device using and ESP32-S3 using the ESPHome framework, integrated in homeassistant (for configuration, reporting, control) but fully autonomous for automations.

Basically, I need to control a pump and have automations that will run locally on the ESP32 that will:

  • No matter what make sure that the pump runs a minimum x minutes a day, this needs to survice across reboots …
  • No matter what, make sure that the pump never runs more than y minutes a day, based, say, on a current-sensor that I will have, that also needs to survive reboot and it would be very unlikely that the pump stays on while the reboot takes place (but maybe, stuck relay, pin, ), but I can get back the state when the boards reboot using the current sensor and approximate run time across reboot (or power off) if I have a last checked time and the time elapsed since.
  • trigger an alarm on homeassistant (and maybe a local buzzer if need be) if I find out that I exceed these values
  • turn off, make sure the pin stays turned off, if I exceed the maximum time.

All the configuration should be local to the esp32 but changeable on the homeassistant dashboard and i should be able to track runtime, status, turn on the pomp, turn it off, …

My probleme is mostly with automations, I think this can be done with Lambdas but I’m puzzled on where to start. (every day at (configurable times) run pump for (configuratble) minutes, (constantly check maximum and minimum thresholds and act accordingly (pin, alerts, …)

Can anybody give me some information on how to do that?

Thank you!

There’s a couple of options.

Sprinkler component:
Use the regular automations in ESPhome or use the Sprinkler component in ESPhome and set up the pump as a single zone sprinkler system.

The other option:
Create the time variables in HA for you run time, start time etc.
(reference docs)

In the ESPhome code on the device you then pull those values in to be used by the internal automations.

1 Like

Thank you very much Dave. I’ll have a look at the sprinkler component.,

I am not sure about internal automations, mostly about the pump-runtime (persistent across reboots) watchdog timer.

Esphome works great as a standalone platform. Just be sure to disable the api watchdog timer or it will reboot periodically if it can’t connect to HA.

The Time Component supports launching automations, including scripts, at scheduled times. You will want a network connection to sync the clock if you are relying on time-based automations.

A “delay” in a script can be used like a timer in between start/stop commands.

If you save last_started/stopped as numeric (i.e. unix timestamp) template sensors, then you can use restore_value to save across reboots, and can easily calculate runtime before starting to avoid overrun.

1 Like