WeMo component exposes Insight info if available
This commit is contained in:
parent
7a9898fbd2
commit
528cd8ee48
3 changed files with 15 additions and 7 deletions
|
@ -22,10 +22,8 @@ ENTITY_ID_ALL_SWITCHES = group.ENTITY_ID_FORMAT.format(
|
|||
|
||||
ENTITY_ID_FORMAT = DOMAIN + '.{}'
|
||||
|
||||
ATTR_TODAY_KWH = "today_kwh"
|
||||
ATTR_CURRENT_POWER = "current_power"
|
||||
ATTR_TODAY_ON_TIME = "today_on_time"
|
||||
ATTR_TODAY_STANDBY_TIME = "today_standby_time"
|
||||
ATTR_TODAY_MWH = "today_mwh"
|
||||
ATTR_CURRENT_POWER_MWH = "current_power_mwh"
|
||||
|
||||
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ import logging
|
|||
|
||||
from homeassistant.helpers import ToggleDevice
|
||||
from homeassistant.const import ATTR_FRIENDLY_NAME, CONF_HOSTS
|
||||
from homeassistant.components.switch import (
|
||||
ATTR_TODAY_MWH, ATTR_CURRENT_POWER_MWH)
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
|
@ -38,7 +40,6 @@ class WemoSwitch(ToggleDevice):
|
|||
""" represents a WeMo switch within home assistant. """
|
||||
def __init__(self, wemo):
|
||||
self.wemo = wemo
|
||||
self.state_attr = {ATTR_FRIENDLY_NAME: wemo.name}
|
||||
|
||||
def get_name(self):
|
||||
""" Returns the name of the switch if any. """
|
||||
|
@ -58,4 +59,13 @@ class WemoSwitch(ToggleDevice):
|
|||
|
||||
def get_state_attributes(self):
|
||||
""" Returns optional state attributes. """
|
||||
return self.state_attr
|
||||
if self.wemo.model.startswith('Belkin Insight'):
|
||||
cur_info = self.wemo.insight_params
|
||||
|
||||
return {
|
||||
ATTR_FRIENDLY_NAME: self.wemo.name,
|
||||
ATTR_CURRENT_POWER_MWH: cur_info['currentpower'],
|
||||
ATTR_TODAY_MWH: cur_info['todaymw']
|
||||
}
|
||||
else:
|
||||
return {ATTR_FRIENDLY_NAME: self.wemo.name}
|
||||
|
|
2
homeassistant/external/pywemo
vendored
2
homeassistant/external/pywemo
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 10e7d7ba12b2326d69e3afe335d663b236790d3d
|
||||
Subproject commit b86d410cd67ea1e3a60355aa23d17fe6761cb8c5
|
Loading…
Add table
Reference in a new issue