Automation with power check does not trigger if power remains zero

Hi all,
I am pretty new to HA but I already love it!

I have a problem with a simple automation: I have a MQTT power switch (Sonoff Pow R2) connected to a power strip where I attached a TV and an oven.

I want that HA turns off the switch if all appliances are powered off for 30 miinutes.

I use this automation:

- id: spegni_cucina
  alias: Spegnimento automatico cucina
  trigger:
    - platform: numeric_state
      entity_id: sensor.cucina_potenza_attuale
      value_template: '{{states.sensor.cucina_potenza_attuale.state}}'
      below: 5
      for: '00:30:00'
  condition:
    - condition: state
      entity_id: switch.cucina
      state: 'on'
  action:
    - service: switch.turn_off
      data:
        entity_id: switch.cucina

Automation works only if I switch on at least one appliance. If all remains powered off the automation does not triggers.

Any idea?

Thanks in advance!!!

Remove this line:

  value_template: '{{states.sensor.cucina_potenza_attuale.state}}'

in addition to @tom_l 's suggestion, Iā€™m not sure if for can be assigned a value. You may need to swap it for:

    - platform: numeric_state
      entity_id: sensor.cucina_potenza_attuale
      below: 5
      for:
        minutes: 30

Thank you very much @tom_l now automation works perfectly!!!

@petro I confirm you that works with

for: '00:30:00'

and with

for:
  minutes: 30

Thanks for the suggestion!

1 Like

Good to know!