Trigger an automation if <some device> draws power for less than <x> seconds

I have an e-bike charger connected to a switchable socket. If the charger draws power for less than a couple of seconds after the socket is being switched on, this is a clear sign that I forgot to plug the charger into the bike.

I want to be notified in this case. While I can think of some clumsy solution with timers or template triggers subtracting last changed timestamps from the current time I suspect, I’m just overlooking something super easy but somehow I can’t figure this out right now.

is there an elegant way to achieve this? Or do I have to use timers or timestamp calculations?

Hm, depending on how frequently HA receives the energy data you could use the following:

  • a “delay” action, waiting for x seconds
  • a condition after that checking if the power is lower than (charging power).
  • your notification service

How about:

- trigger:
  - platform: state
    entity_id: switch.SWITCH
    to: 'on'
    for: 5
  condition:
  - condition: numeric_state
    entity_id: sensor.POWER
    below: N
  action:
  - ...

This will trigger when the switch is turned on and stays on for 5 seconds. At that time it will check the power draw level and if it’s below some threshold it will run the actions.

Thank you @fedot & @pnbruckner for the suggestion, that’s the kind of elegant solution I was looking for!

1 Like