I plugged my TV into a smart plug which conveniently also measures power flow through it. I wanted to use this to detect whether the TV was on.

The bad way: Initially, I fumbled my way with an input_boolean and two automations: One triggered when more than 10W were flowing to set the input_boolean to true. And another one to set it to false when power flow was below 10W.

The better way: Turns out there is a much easier way to do this with the template platform. Here is what I arrived at:

template:
  - binary_sensor:
    - name: "TV is on"
      state: "{{states('sensor.tv_power_switch_smartenergy_metering')|float >10}}"
      icon: mdi:television

This creates a new binary_sensor in the system with name TV is on and entity ID binary_sensor.tv_is_on that tracks whether or not the power flow through the sensor sensor.tv_power_switch_smartenergy_metering is greater than 10. The unit of measure for the smart plug I have is W.

Next up is to give the same treatment to the washing machine.