markbajaj
(Mark Bajaj)
July 18, 2017, 6:23pm
1
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
silvrr
July 18, 2017, 6:29pm
2
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
markbajaj
(Mark Bajaj)
July 18, 2017, 6:39pm
3
Thanks @silvrr
I’m still getting unknown though:
markbajaj
(Mark Bajaj)
July 18, 2017, 7:32pm
4
It works!
It was the yaml. It is in a separate file so it was slightly out on the indents
- platform: template
sensors:
wemo_energy_today:
value_template: '{{ states.switch.wemo.attributes["today_energy_kwh"] }}'
friendly_name: 'Wemo Consumption'
unit_of_measurement: 'W'
Thanks!!!
markbajaj
(Mark Bajaj)
July 18, 2017, 8:12pm
5
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
silvrr
July 18, 2017, 8:31pm
6
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
markbajaj
(Mark Bajaj)
July 18, 2017, 8:52pm
7
@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
silvrr
July 18, 2017, 9:30pm
8
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.
markbajaj
(Mark Bajaj)
July 18, 2017, 9:43pm
9
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
@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
silvrr
October 20, 2017, 4:18am
11
Not all switches report power usage. What switches do you have?
kanga_who
(Jason)
October 20, 2017, 8:22am
12
@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
markbajaj
(Mark Bajaj)
October 20, 2017, 9:22am
13
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.