Simple automation won't work

I have a smart plug connected to my computer.
The consumption in standby is 9,5 Watt, in operation above 100 Watt.
To avoid the idle current when I don’t use the computer I’v put the smartplug to switch of the computer completely.
But indeed, sometimes, I forget and therefore I made this automation.
If the smart plug is on and the current consumption is below 20 Watt for 1 minuit, the plug should be switched off.
I reloaded first the automations but as this won’t work I restarted HA completely but without success. If I switch on the smart plug it remains on, even the power current is only 9,5 Watt.
The automation action works, there should be something wrong with the trigger and/or condition…

- id: '1615549246028'
  alias: Game PC automatisch uit
  description: ''
  trigger:
  - platform: state
    to: 'on'
    entity_id: binary_sensor.spare2_binary_sensor
  condition:
  - condition: and
    conditions:
    - condition: state
      entity_id: sensor.spare2_current_consumption
      state: 'below: 20'
      for: 00:01:00
  action:
  - service: switch.turn_off
    target:
      entity_id: switch.spare2_tuya
  mode: single

Trigger:
Schermafbeelding 2021-03-12 om 13.02.52

Condition:
Schermafbeelding 2021-03-12 om 13.05.32

trigger:
  - platform: numeric_state
    entity_id: sensor.spare2_current_consumption
    below: 20
    for:
      minutes: 1
condition: []
action:
  - service: switch.turn_off
    entity_id: switch.spare2_tuya
mode: single

No condition required, it does not harm to turn off a switch that is already switched off.

1 Like

Btw: Did you manage to compose this using the Automation UI? The state: criterion looks weird, but I might not be up-to-date…

Btw²: Conditions are AND by default, so no need to use a 1st level AND condition with a single 2nd level condition.

Thanks for your code. This works.
Yes, the automation was made with the GUI.