Control an Input Boolean based on current power consumption

I have connected a TP-Link KP115 smart plug. I got specifically for the energy monitoring so that I can use that to control an input boolean. This helper helps me to control other automations.

So what I want it to do is when the consumption rises above 5W to turn the helper on and when it falls below 5W to turn the helper off. I do NOT want to turn the TP-Link switch on and off with this automation. I want the TP-link to stay on at all times and just use the energy monitoring capabilities of it.

I have been reading through examples and have been unable to get this to work. Here is what I’ve got so far.

alias: ATV On
description: ''
trigger:
  - platform: numeric_state
    entity_id: switch.living_tv
    attribute: current_consumption
    above: '5'
condition:
  - condition: device
    type: is_on
    device_id: 347081a8c237dc8fe7eee99823c64806
    entity_id: switch.living_tv
    domain: switch
action:
  - service: input_boolean.turn_on
    target:
      entity_id: input_boolean.tv_power
mode: single
alias: ATV Off
description: ''
trigger:
  - platform: numeric_state
    entity_id: switch.living_tv
    attribute: current_consumption
    below: '20'
    for:
      hours: 0
      minutes: 0
      seconds: 5
condition:
  - condition: device
    type: is_on
    device_id: 347081a8c237dc8fe7eee99823c64806
    entity_id: switch.living_tv
    domain: switch
action:
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.tv_power
mode: single

Any help would be greatly appreciated.

Above 5 is always below 20…

Good catch. I had been changing values to see if I could get it to work and I guess I missed a change in one. Unfortunately, that did not fix it. I was able to get it working, by clicking through and finding another way to do it. To close the loop for anyone in the future. Here is what I ended up using.

alias: ATV Off
description: ''
trigger:
  - type: power
    platform: device
    device_id: 347081a8c237dc8fe7eee99823c64806
    entity_id: sensor.living_tv_current_consumption
    domain: sensor
    below: 20
    for:
      hours: 0
      minutes: 0
      seconds: 5
condition: []
action:
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.tv_power
mode: single
alias: ATV On
description: ''
trigger:
  - type: power
    platform: device
    device_id: 347081a8c237dc8fe7eee99823c64806
    entity_id: sensor.living_tv_current_consumption
    domain: sensor
    above: 20
condition: []
action:
  - service: input_boolean.turn_on
    target:
      entity_id: input_boolean.tv_power
mode: single

Good thing you solved it .
I have bad experience with wifi sockets ( beside the idea itself to turn power off which now i feel does not make scene ) . I got 5 tuya power strips and plugs and I want to change them because they do not even have power monitoring like the one you have .

Do you find KP115 useful and do you recommend it

It is useful for my case I am not turning the TV on and off with it. My Apple TV through CEC does this. I only use the KP 115 to monitor the power usage of the TV to control other automations in my homekit home.

The only Home Assistant automation I have running is the ones I noted above. When homekit sees the input boolean turn on, it controls automations for me in homekit. I am not prepared to move everything to Home Assistant yet. Mostly because I am already well entrenched in Apple’s ecosystem. I use Home Assistant to help expand the abilities of my homeket integrations.

I do use Home Assistant to create virtual switches for homekit, add some aqara sensors for occupancy/lux, and add non-compatible devices to homekit. For instance, I have three other Kasa powerstrips integrated into homekit, through home assistant.

All of that to provide some context for my statement that I have been quite happy with all of my Kasa equipment. I have only had the KP115 for a couple days, but the powerstrips I have had for a couple of months. I have had no issues with any of it.