Wemo Switch use data as a sensor?

Hi,

I have a few WeMo switches and am wondering if I can use the data from them to create a sensor with history.

One WeMo returns the following attributes:

What I am looking to do is make a sensor that I can read the current consumption from (yep 11.06kwh today…it’s a hot tub!)

I have the following (part of a separate sensors.yaml file) but I cannot get any values:

  - platform: statistics
    entity_id: switch.wemo
    value_template: '{{ states.switch.wemo.today_energy_kwh.attributes }}'
    name: Wemo Consumption

Am I missing something or way off the mark :slight_smile:

You are almost there

  - platform: template
    sensors:
      sensor1:
        value_template: '{{ states.switch.wemo.attributes["today_energy_kwh"] }}'
        unit_of_measurement: 'W'

I use this to pull from my edimax switches which pull similar data.

https://github.com/SilvrrGIT/HomeAssistant/blob/master/sensors.yaml

2 Likes

Thanks @silvrr

I’m still getting unknown though:

It works!

It was the yaml. It is in a separate file so it was slightly out on the indents :slight_smile:

      - platform: template
        sensors:
          wemo_energy_today:
          value_template: '{{ states.switch.wemo.attributes["today_energy_kwh"] }}'
          friendly_name: 'Wemo Consumption'
          unit_of_measurement: 'W'

Thanks!!!

Ok, one last question (promise).
I am trying to convert the kw/hour to the total cost (13.5p per hour)

This is what I have (last sensor), but it just returns 1.35 (ie the value of 0.135 times 10?)

- platform: template
  sensors:
    wemo_energy_today:
    value_template: '{{ states.switch.wemo.attributes["today_energy_kwh"] }}'
    friendly_name: 'Hot Tub Consumption Today'
    unit_of_measurement: 'kwh'
  wemo_current_energy:
    value_template: '{{ states.switch.wemo.attributes["current_power_w"] | round(-1) }}'
    friendly_name: 'Hot Tub Current Consumption'
    unit_of_measurement: 'w'
  wemo_energy_cost_today:
    value_template: '{{ states.switch.wemo.attributes["today_energy_kwh"] | multiply(0.135) }}'
    friendly_name: 'Hot Tub Cost Today'
    unit_of_measurement: '£'

Any ideas? I’ve tried various combinations.

Thanks all again :slight_smile:

ask away, no problem.

  edimax2_cost:
    value_template: '{{ states("sensor.edimax2_kwh") | round  (2) |  float * 16 }}'
    unit_of_measurement: '¢'

That is my config for the same thing. I’m outputting to cents not dollars though. You need to adjust the decimal point as needed for dollars vs cents.

also

  edimax2_cost:
    value_template: '{{ states("sensor.edimax2_kwh") | round  (2) |  float * 16 }}'
    unit_of_measurement: '¢'

and

  edimax2_cost:
    value_template: '{{ states("sensor.edimax2_kwh")  |  float * 16 | round  (2) }}'
    unit_of_measurement: '¢'

Return two different values as the first rounds the sensor the second rounds the result of the math. You may want to play around with them to see which you prefer. Also sometimes these template sensors return really long results, the round (2) is there to limit it to 2 decimal places but it doesn’t always work. The first option above gives me one decimal place and the second one gives me 5 or 6.

1 Like

@silvrr

Thanks! Works a treat. Still messing around with the decimal point but the main figure is there.

Just got to work out now why since the upgrade to 0.49.0 every restart of hass needs me to press the button on the hue bridge, even though I have explicitly named it in the configuration.yaml.

Thanks again :wink:

Sorry don’t have a hue bridge so can’t offer any advice there. Search around on the forum a bit or start a new thread if you can’t find the answer, Im sure someone else has run into the issue.

Thanks will do.

I think it is something to do with the habridge that I use for Alexa to ‘talk’ to my TiVo and other devices. Weird as been good upto v 0.49.0.

Thanks for all your help today :+1:

@markbajaj

Hey,
Did you add something to your config to get the Attributes?

I have three switches, but they don’t show any Attributes, it display’s as below.

switch.backyard on friendly_name: Backyard
switch.girls_room off friendly_name: Girls Room
switch.boys_room off friendly_name: Boys Room

Not all switches report power usage. What switches do you have?

@markbajaj

Still messing around with the decimal point but the main figure is there

I just figured this out, I wanted it to display Dollars (Aus) rather than cents.

value_template: '{{ (states("sensor.tv_energy_today") | float * 0.29) | round(2) }}'

1 Like

Hi,

Just like @silvrr says, you need the correct version of the WeMo to report power usage. Mine is a WeMo Insight Switch rather than the taller Wemo Switches. If you have the correct version they report power in the WeMo app

I guess that’s why I don’t see any additional attributes.

I have the wemo light switches.