Update device_state_attributes only
This gets rid of the other stuff and just updates device_state_attributes, leaving the default properties alone.pull/6001/head
parent
f6e46aecf5
commit
ef87d4dad4
|
@ -21,16 +21,6 @@ ATTR_SWITCH_MODE = "switch_mode"
|
||||||
ATTR_CURRENT_STATE_DETAIL = 'state_detail'
|
ATTR_CURRENT_STATE_DETAIL = 'state_detail'
|
||||||
ATTR_COFFEMAKER_MODE = "coffeemaker_mode"
|
ATTR_COFFEMAKER_MODE = "coffeemaker_mode"
|
||||||
|
|
||||||
# Wemo Insight
|
|
||||||
ATTR_POWER_CURRENT_W = 'power_current_w'
|
|
||||||
# ATTR_POWER_AVG_W = 'power_average_w'
|
|
||||||
ATTR_POWER_TODAY_MW_MIN = 'power_today_mW_min'
|
|
||||||
ATTR_POWER_TOTAL_MW_MIN = 'power_total_mW_min'
|
|
||||||
ATTR_ON_FOR_TIME = 'on_time_most_recent'
|
|
||||||
ATTR_ON_TODAY_TIME = 'on_time_today'
|
|
||||||
ATTR_ON_TOTAL_TIME = 'on_time_total'
|
|
||||||
ATTR_POWER_THRESHOLD = 'power_threshold_w'
|
|
||||||
|
|
||||||
MAKER_SWITCH_MOMENTARY = "momentary"
|
MAKER_SWITCH_MOMENTARY = "momentary"
|
||||||
MAKER_SWITCH_TOGGLE = "toggle"
|
MAKER_SWITCH_TOGGLE = "toggle"
|
||||||
|
|
||||||
|
@ -120,44 +110,24 @@ class WemoSwitch(SwitchDevice):
|
||||||
|
|
||||||
if self.insight_params or (self.coffeemaker_mode is not None):
|
if self.insight_params or (self.coffeemaker_mode is not None):
|
||||||
attr[ATTR_CURRENT_STATE_DETAIL] = self.detail_state
|
attr[ATTR_CURRENT_STATE_DETAIL] = self.detail_state
|
||||||
attr[ATTR_POWER_CURRENT_W] = self.power_current_watt
|
attr['current_power_w'] = \
|
||||||
# attr[ATTR_POWER_AVG_W] = self.power_average_watt
|
self.insight_params['currentpower'] / 1000
|
||||||
attr[ATTR_POWER_TODAY_MW_MIN] = self.power_today_mw_min
|
attr['today_power_mW_min'] = self.insight_params['todaymw']
|
||||||
attr[ATTR_POWER_TOTAL_MW_MIN] = self.power_total_mw_min
|
attr['total_power_mW_min'] = self.insight_params['totalmw']
|
||||||
attr[ATTR_ON_FOR_TIME] = self.on_for
|
attr['on_time_most_recent'] = \
|
||||||
attr[ATTR_ON_TODAY_TIME] = self.on_today
|
WemoSwitch.as_uptime(self.insight_params['onfor'])
|
||||||
attr[ATTR_ON_TOTAL_TIME] = self.on_total
|
attr['on_time_today'] = \
|
||||||
attr[ATTR_POWER_THRESHOLD] = self.power_threshold
|
WemoSwitch.as_uptime(self.insight_params['ontoday'])
|
||||||
|
attr['on_time_total'] = \
|
||||||
|
WemoSwitch.as_uptime(self.insight_params['ontotal'])
|
||||||
|
attr['power_threshold_w'] = \
|
||||||
|
self.insight_params['powerthreshold'] / 1000
|
||||||
|
|
||||||
if self.coffeemaker_mode is not None:
|
if self.coffeemaker_mode is not None:
|
||||||
attr[ATTR_COFFEMAKER_MODE] = self.coffeemaker_mode
|
attr[ATTR_COFFEMAKER_MODE] = self.coffeemaker_mode
|
||||||
|
|
||||||
return attr
|
return attr
|
||||||
|
|
||||||
# @property
|
|
||||||
def _current_power_mw(self):
|
|
||||||
"""Current power usage in mW."""
|
|
||||||
if self.insight_params:
|
|
||||||
try:
|
|
||||||
return self.insight_params['currentpower']
|
|
||||||
except KeyError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
|
||||||
def power_current_watt(self):
|
|
||||||
"""Current power usage in W."""
|
|
||||||
if self.insight_params:
|
|
||||||
try:
|
|
||||||
return self._current_power_mw() / 1000
|
|
||||||
except TypeError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
|
||||||
def power_threshold(self):
|
|
||||||
"""Threshold of W at which Insight will indicate it's load is ON."""
|
|
||||||
if self.insight_params:
|
|
||||||
return self.insight_params['powerthreshold'] / 1000
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def as_uptime(_seconds):
|
def as_uptime(_seconds):
|
||||||
"""Format seconds into uptime string in the format: 00d 00h 00m 00s."""
|
"""Format seconds into uptime string in the format: 00d 00h 00m 00s."""
|
||||||
|
@ -168,40 +138,16 @@ class WemoSwitch(SwitchDevice):
|
||||||
uptime.second)
|
uptime.second)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def on_for(self):
|
def current_power_mwh(self):
|
||||||
"""On time in seconds."""
|
"""Current power usage in mWh."""
|
||||||
if self.insight_params:
|
if self.insight_params:
|
||||||
return WemoSwitch.as_uptime(self.insight_params['onfor'])
|
return self.insight_params['currentpower']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def on_today(self):
|
def today_power_mw(self):
|
||||||
"""On time in seconds."""
|
"""Today total power usage in mW."""
|
||||||
if self.insight_params:
|
if self.insight_params:
|
||||||
return WemoSwitch.as_uptime(self.insight_params['ontoday'])
|
return self.insight_params['todaymw']
|
||||||
|
|
||||||
@property
|
|
||||||
def on_total(self):
|
|
||||||
"""On time in seconds."""
|
|
||||||
if self.insight_params:
|
|
||||||
return WemoSwitch.as_uptime(self.insight_params['ontotal'])
|
|
||||||
|
|
||||||
@property
|
|
||||||
def power_total_mw_min(self):
|
|
||||||
"""Total of average mW per minute."""
|
|
||||||
if self.insight_params:
|
|
||||||
try:
|
|
||||||
return self.insight_params['totalmw']
|
|
||||||
except KeyError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
|
||||||
def power_today_mw_min(self):
|
|
||||||
"""Total consumption today in mW per minute."""
|
|
||||||
if self.insight_params:
|
|
||||||
try:
|
|
||||||
return self.insight_params['todaymw']
|
|
||||||
except KeyError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def detail_state(self):
|
def detail_state(self):
|
||||||
|
|
Loading…
Reference in New Issue