How to turn a plug off if it goes below a certain current

Hi I’m new to this but cant understand where I’m going wrong.
I’m trying to make a automation to turn my pc off at the wall when I shutdown the pc. I’m using a tuya smart plug to read the current and what I want it to do is if the current goes under a certain value it turn the plug off

here’s my automation

 alias: if computer shutdown turn off computer plug
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.computer_current
    attribute: trigger.below
    below: '0.5'
    value_template: A
action:
  - type: turn_off
    device_id: 92dd89ea7ef5d08e0238edb71f92b51a
    entity_id: switch.computer
    domain: switch
mode: single

Shouldn’t a numeric_state be a number instead of a string :thinking:

That doesn’t matter. The GUI ads quotes around some numeric states.

But what does matter is

    attribute: trigger.below
    value_template: A

Why attribute? Why trigger.below?
Why a value_template? And why is the value_template in amps?

I’d say remove those two lines and try again.

thanks that worked


alias: if computer shutdown turn off computer plug
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.computer_current
    below: '0.5'
action:
  - type: turn_off
    device_id: 92dd89ea7ef5d08e0238edb71f92b51a
    entity_id: switch.computer
    domain: switch
mode: single

Just to clarity the issue here.

Attribute that you used means to HA: “Don’t look at the state, look at the attribute called…”.

Value_template, I doubt that is valid syntax with numeric state. But what it means is take this yaml syntax and process is.

Adding these two here meant either you could not save it due to the value template or that it just couldn’t do the conflicting calculations.

it did save but it wouldn’t do anything but its fixed cheers @Hellis81