Refactor wemo standby state slightly
This commit is contained in:
parent
028551784a
commit
5ed6987067
3 changed files with 20 additions and 6 deletions
|
@ -24,7 +24,6 @@ ENTITY_ID_FORMAT = DOMAIN + '.{}'
|
|||
|
||||
ATTR_TODAY_MWH = "today_mwh"
|
||||
ATTR_CURRENT_POWER_MWH = "current_power_mwh"
|
||||
ATTR_STANDBY_STATE = "standby_state"
|
||||
ATTR_SENSOR_STATE = "sensor_state"
|
||||
|
||||
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
|
||||
|
@ -40,7 +39,6 @@ DISCOVERY_PLATFORMS = {
|
|||
PROP_TO_ATTR = {
|
||||
'current_power_mwh': ATTR_CURRENT_POWER_MWH,
|
||||
'today_power_mw': ATTR_TODAY_MWH,
|
||||
'standby_state': ATTR_STANDBY_STATE,
|
||||
'sensor_state': ATTR_SENSOR_STATE
|
||||
}
|
||||
|
||||
|
@ -106,8 +104,8 @@ class SwitchDevice(ToggleEntity):
|
|||
return None
|
||||
|
||||
@property
|
||||
def standby_state(self):
|
||||
""" Is the device on - or in standby. """
|
||||
def is_standby(self):
|
||||
""" Is the device in standby. """
|
||||
return None
|
||||
|
||||
@property
|
||||
|
|
|
@ -51,6 +51,16 @@ class WemoSwitch(SwitchDevice):
|
|||
""" Returns the name of the switch if any. """
|
||||
return self.wemo.name
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
""" Returns the state. """
|
||||
is_on = self.is_on
|
||||
if not is_on:
|
||||
return STATE_OFF
|
||||
elif self.is_standby:
|
||||
return STATE_STANDBY
|
||||
return STATE_ON
|
||||
|
||||
@property
|
||||
def current_power_mwh(self):
|
||||
""" Current power usage in mwh. """
|
||||
|
@ -64,10 +74,15 @@ class WemoSwitch(SwitchDevice):
|
|||
return self.insight_params['todaymw']
|
||||
|
||||
@property
|
||||
def standby_state(self):
|
||||
def is_standby(self):
|
||||
""" Is the device on - or in standby. """
|
||||
if self.insight_params:
|
||||
return self.insight_params['standby_state']
|
||||
standby_state = self.insight_params['standby_state']
|
||||
# Standby is actually '8' but seems more defensive to check for the On and Off states
|
||||
if standby_state == '1' or standby_state == '0'
|
||||
return False
|
||||
else
|
||||
return True
|
||||
|
||||
@property
|
||||
def sensor_state(self):
|
||||
|
|
|
@ -46,6 +46,7 @@ STATE_CLOSED = 'closed'
|
|||
STATE_PLAYING = 'playing'
|
||||
STATE_PAUSED = 'paused'
|
||||
STATE_IDLE = 'idle'
|
||||
STATE_STANDBY = 'standby'
|
||||
|
||||
# #### STATE AND EVENT ATTRIBUTES ####
|
||||
# Contains current time for a TIME_CHANGED event
|
||||
|
|
Loading…
Add table
Reference in a new issue