Limit Television viewing

I’m using a Zooz Zwave Zen15 with a LG ThinQ TV plugged into it. I want to monitor and limit TV viewing for 2 hours a day and can’t seem to find the right combination in HA to accomplish this.
I’ve tried using the Utility meter like so:

    source: sensor.living_room_television_switch_power
    cycle: daily
    source: sensor.living_room_television_switch_power
    cycle: hourly

I’m able to see the Watts from the Zen15 for both daily and hourly but I’m not sure how I can use this. I was initially hoping to just monitor the Zen15 sensor…power setting which goes from 0 to any positive number when the TV is on. But again I’m not sure how I can add up the minutes or hours for how long the TV is in an “On” state from the power sensor.
Perhaps I’m overcomplicating this but I’m hoping someone can give me some clues on how to solve this.
Thank you in advance!

1 Like

The history stats sensor will track how long a device has been on:

Yes I saw that but wasn’t sure how to use it. The Zen15 has a power_consumption sensor which will go from 0 to any positive float when the TV is on. Would I track the power_consumption state? Since I want to monitor daily usage I would set the start setting to 00:00:00 and duration for 24 hours?

If I understand this sensor, based upon my example above, it will sum the amount of time daily that the TV is drawing power above 0?

Edit: I tried this but it doesn’t work. Value is always 0.

  name: Living Room TV ON today
  entity_id: sensor.living_room_television_switch_power #LG Television
  state: "power_consumption"
  type: time
  start: "{{ now().replace(hour=0, minute=0, second=0) }}"
    hours: 24

You will also need to create a binary template sensor that is on when your power consumption is >0. Feed this binary sensor to the History stats sensor.

Ah, okay that makes sense. I would assume I would change the entity in the History stats sensor to the binary template sensor? Thanks for your assistance.

No. Feed the power sensor to the template binary sensor. Feed the binary sensor to the History stats.

Got it. Thanks. I’ll give it a try and see how it goes.

Binary sensor:

  - binary_sensor:
      - name: "TV On"
        state: "{{ states('sensor.living_room_television_switch_power')|float(0) > 0 }}"
        icon: "{{ 'mdi:television-classic' if is_state('binary_sensor.tv_on', 'on') else 'television-classic-off' }}"

History stats:

  - platform: history_stats
    name: TV On Today
    entity_id: binary_sensor.tv_on
    state: "on"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0) }}"
    end: "{{ now() }}"

How you trigger an automation using this depends on the attributes of this sensor. Post them (look in developer tools / states) If you need a hand.

Thank you so very much. That worked. Appreciate the help!

1 Like