Revise power and energy units and property names. (#6212)
* Revise power and energy units and property names. * Add change for new wemo parameter.
This commit is contained in:
1 parent
970bde9e99
commit
acf75b5253
12 files changed
+50
-49
No files matched your search
@@ -8,6 +8,7 @@ import logging
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from homeassistant.components.switch import SwitchDevice
|
||||
from homeassistant.util import convert
|
||||
from homeassistant.const import (
|
||||
STATE_OFF, STATE_ON, STATE_STANDBY, STATE_UNKNOWN)
|
||||
from homeassistant.loader import get_component
|
||||
@@ -118,8 +119,10 @@ class WemoSwitch(SwitchDevice):
|
||||
WemoSwitch.as_uptime(self.insight_params['ontoday'])
|
||||
attr['on_total_time'] = \
|
||||
WemoSwitch.as_uptime(self.insight_params['ontotal'])
|
||||
attr['power_threshold_mw'] = \
|
||||
self.insight_params['powerthreshold']
|
||||
attr['power_threshold_w'] = \
|
||||
convert(
|
||||
self.insight_params['powerthreshold'], float, 0.0
|
||||
) / 1000.0
|
||||
|
||||
if self.coffeemaker_mode is not None:
|
||||
attr[ATTR_COFFEMAKER_MODE] = self.coffeemaker_mode
|
||||
@@ -136,16 +139,18 @@ class WemoSwitch(SwitchDevice):
|
||||
uptime.second)
|
||||
|
||||
@property
|
||||
def current_power_mwh(self):
|
||||
"""Current power usage in mWh."""
|
||||
def current_power_w(self):
|
||||
"""Current power usage in W."""
|
||||
if self.insight_params:
|
||||
return self.insight_params['currentpower']
|
||||
return convert(
|
||||
self.insight_params['currentpower'], float, 0.0
|
||||
) / 1000.0
|
||||
|
||||
@property
|
||||
def today_power_mw(self):
|
||||
"""Today total power usage in mW."""
|
||||
def today_energy_kwh(self):
|
||||
"""Today total energy usage in kWh."""
|
||||
if self.insight_params:
|
||||
return self.insight_params['todaymw']
|
||||
return convert(self.insight_params['todaymw'], float, 0.0) / 1000.0
|
||||
|
||||
@property
|
||||
def detail_state(self):
|
||||
|
||||
Reference in new issue
Block a user