Automation based on energy switch

I wanted to know how can i write an automation based on the energy usage of Aeon Labs Aeotec Z-Wave Smart Energy Switch.

This switch is connected to TV, when the TV is turned on it will show the watts in use and i would like to keep that as trigger and perform an automation to turn the energy switch to off after one hour. (i will set another automation to turn it on after couple of hours)

basically trying to turn off TV connected to Apple TV, (I have another topic asking if it can be done without the switch and just by using Apple TV integration, but seem have issues, so may be i can try this route)

If someone can help with steps i could try and i appreciate very much.

Hi There!

I’m sure I can point you in the right direction

For testing this, I’m not exactly sure as I don’t have / use what you have. So I’ve left what I can do at the bottom

  1. You’ll need to get the the amount of energy the tv uses while it is off

Then you can setup a automation that whenever the state of the power usage sensor changes check if it is equal to the usage while its off (1) , if its not start a delay for 1 hour, after that hour use the call service mode and tell the switch to turn off.

Note, You’ll want to change the words “Power usage while off” to the the amount of energy the tv uses while it is off (1)

If your wondering what that extra delay at the bottom is, that’s to give your tv a grace period to fully go back to its power usage while off (1). Otherwise the automation could put your tv into a loop of turning off every hour :joy:

alias: Turn off a TV after 1 hour of use
description: >-
  This will turn off the TV after 1 hour of use, based off of a smart plug with
  a power sensor connected to the tv
trigger:
  - platform: state
    entity_id: sensor.tv_power_usage
    from: Power usage while off
condition: []
action:
  - delay:
      hours: 1
      minutes: 0
      seconds: 0
      milliseconds: 0
  - service: switch.turn_off
    target:
      entity_id: switch.tv_power
  - delay:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
mode: single

A numeric state trigger would be best:

trigger:
  - platform: numeric_state
    entity_id: sensor.tv_power_usage
    above: 50 # change this to half way between the power drawn by the TV when on and off.
    for:
      hours: 1
action:
  - service: switch.turn_off
    target:
      entity_id: switch.tv_power

The delay at the end is not needed.

Oh that’s really cool, I didn’t know the numeric state trigger existed. Thank You, I just learned something new

Thank you so much for both of you.
I wanted to do this and my work place asked us to come back and been busy since then, now that i find some time i was looking into this automation, i see your samples and i took them and implemented it just now. I am hoping this should work out. Thanks again.