How do you automate based on WEMO INSIGHT wattage?

I tried to do this with a template sensor but keep getting errors. Here’s my setup:

- platform: template
  sensors:
    washer_watts:
      friendly_name: "Washing Machine Power"
      icon: "mdi:washing-machine"
      unit_of_measurement: "w"
      value_template: "{{states.switch.washer.attributes.current_power_w}}"

DEV-STATE PAGE:

switch.washer	

on	

current_power_w: 0.365
today_energy_kwh: 0.43
state_detail: on
on_latest_time: 02d 04h 47m 35s
on_today_time: 00d 18h 51m 34s
on_total_time: 09d 11h 05m 58s
power_threshold_w: 0
friendly_name: Washer

Erroring out saying invalid template sensor and linking me here: https://home-assistant.io/components/sensor.template/

I tried everything I could think of, still no dice.

Try this for your value template:

value_template: '{% if states.switch.washer %}{{ states.switch.washer.attributes.current_power_w }}{% else %}Off{% endif %}'

1 Like

MAGIC!!!

Not sure how you figured that out but I was just reading through templating and trying to see what I could figure out.

Thank you!

In this instance, will I have to worry about this if the WEMO disconnects or is unplugged, or will it just post the ‘Off’ state?

If the state is off on the wemo, it will display off as it cannot display a reading from the atrribute current power w.