mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Fix bug, use constants for states.
This commit is contained in:
parent
54dd09df29
commit
3256552675
@ -7,6 +7,7 @@ Support for WeMo switches.
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchDevice
|
from homeassistant.components.switch import SwitchDevice
|
||||||
|
from homeassistant.const import STATE_ON, STATE_OFF, STATE_STANDBY
|
||||||
|
|
||||||
REQUIREMENTS = ['pywemo==0.3']
|
REQUIREMENTS = ['pywemo==0.3']
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ class WemoSwitch(SwitchDevice):
|
|||||||
def is_standby(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:
|
||||||
standby_state = self.insight_params['standby_state']
|
standby_state = self.insight_params['state']
|
||||||
# Standby is actually '8' but seems more defensive to check for the On and Off states
|
# Standby is actually '8' but seems more defensive to check for the On and Off states
|
||||||
if standby_state == '1' or standby_state == '0':
|
if standby_state == '1' or standby_state == '0':
|
||||||
return False
|
return False
|
||||||
@ -90,9 +91,9 @@ class WemoSwitch(SwitchDevice):
|
|||||||
if self.maker_params and self.has_sensor:
|
if self.maker_params and self.has_sensor:
|
||||||
# Note a state of 1 matches the WeMo app 'not triggered'!
|
# Note a state of 1 matches the WeMo app 'not triggered'!
|
||||||
if self.maker_params['sensorstate']:
|
if self.maker_params['sensorstate']:
|
||||||
return 'off'
|
return STATE_OFF
|
||||||
else:
|
else:
|
||||||
return 'on'
|
return STATE_ON
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def switch_mode(self):
|
def switch_mode(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user