mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Refactor wemo standby state slightly
This commit is contained in:
parent
028551784a
commit
5ed6987067
@ -24,7 +24,6 @@ ENTITY_ID_FORMAT = DOMAIN + '.{}'
|
|||||||
|
|
||||||
ATTR_TODAY_MWH = "today_mwh"
|
ATTR_TODAY_MWH = "today_mwh"
|
||||||
ATTR_CURRENT_POWER_MWH = "current_power_mwh"
|
ATTR_CURRENT_POWER_MWH = "current_power_mwh"
|
||||||
ATTR_STANDBY_STATE = "standby_state"
|
|
||||||
ATTR_SENSOR_STATE = "sensor_state"
|
ATTR_SENSOR_STATE = "sensor_state"
|
||||||
|
|
||||||
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
|
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
|
||||||
@ -40,7 +39,6 @@ DISCOVERY_PLATFORMS = {
|
|||||||
PROP_TO_ATTR = {
|
PROP_TO_ATTR = {
|
||||||
'current_power_mwh': ATTR_CURRENT_POWER_MWH,
|
'current_power_mwh': ATTR_CURRENT_POWER_MWH,
|
||||||
'today_power_mw': ATTR_TODAY_MWH,
|
'today_power_mw': ATTR_TODAY_MWH,
|
||||||
'standby_state': ATTR_STANDBY_STATE,
|
|
||||||
'sensor_state': ATTR_SENSOR_STATE
|
'sensor_state': ATTR_SENSOR_STATE
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,8 +104,8 @@ class SwitchDevice(ToggleEntity):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def standby_state(self):
|
def is_standby(self):
|
||||||
""" Is the device on - or in standby. """
|
""" Is the device in standby. """
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -51,6 +51,16 @@ class WemoSwitch(SwitchDevice):
|
|||||||
""" Returns the name of the switch if any. """
|
""" Returns the name of the switch if any. """
|
||||||
return self.wemo.name
|
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
|
@property
|
||||||
def current_power_mwh(self):
|
def current_power_mwh(self):
|
||||||
""" Current power usage in mwh. """
|
""" Current power usage in mwh. """
|
||||||
@ -64,10 +74,15 @@ class WemoSwitch(SwitchDevice):
|
|||||||
return self.insight_params['todaymw']
|
return self.insight_params['todaymw']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def standby_state(self):
|
def is_standby(self):
|
||||||
""" Is the device on - or in standby. """
|
""" Is the device on - or in standby. """
|
||||||
if self.insight_params:
|
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
|
@property
|
||||||
def sensor_state(self):
|
def sensor_state(self):
|
||||||
|
@ -46,6 +46,7 @@ STATE_CLOSED = 'closed'
|
|||||||
STATE_PLAYING = 'playing'
|
STATE_PLAYING = 'playing'
|
||||||
STATE_PAUSED = 'paused'
|
STATE_PAUSED = 'paused'
|
||||||
STATE_IDLE = 'idle'
|
STATE_IDLE = 'idle'
|
||||||
|
STATE_STANDBY = 'standby'
|
||||||
|
|
||||||
# #### STATE AND EVENT ATTRIBUTES ####
|
# #### STATE AND EVENT ATTRIBUTES ####
|
||||||
# Contains current time for a TIME_CHANGED event
|
# Contains current time for a TIME_CHANGED event
|
||||||
|
Loading…
x
Reference in New Issue
Block a user