MyQ cover return unknown state if not available (#17207)
* Add additional supported states * Use get method for lookup * Return None if unable to get statuspull/17361/head
parent
6be52208fc
commit
9e386938bb
|
@ -11,8 +11,8 @@ import voluptuous as vol
|
|||
from homeassistant.components.cover import (
|
||||
CoverDevice, SUPPORT_CLOSE, SUPPORT_OPEN)
|
||||
from homeassistant.const import (
|
||||
CONF_PASSWORD, CONF_TYPE, CONF_USERNAME, STATE_CLOSED, STATE_OPEN,
|
||||
STATE_CLOSING, STATE_OPENING)
|
||||
CONF_PASSWORD, CONF_TYPE, CONF_USERNAME, STATE_CLOSED, STATE_CLOSING,
|
||||
STATE_OPEN, STATE_OPENING)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
REQUIREMENTS = ['pymyq==0.0.15']
|
||||
|
@ -23,8 +23,8 @@ DEFAULT_NAME = 'myq'
|
|||
|
||||
MYQ_TO_HASS = {
|
||||
'closed': STATE_CLOSED,
|
||||
'open': STATE_OPEN,
|
||||
'closing': STATE_CLOSING,
|
||||
'open': STATE_OPEN,
|
||||
'opening': STATE_OPENING
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ class MyQDevice(CoverDevice):
|
|||
self.myq = myq
|
||||
self.device_id = device['deviceid']
|
||||
self._name = device['name']
|
||||
self._status = STATE_CLOSED
|
||||
self._status = None
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
|
@ -96,17 +96,19 @@ class MyQDevice(CoverDevice):
|
|||
@property
|
||||
def is_closed(self):
|
||||
"""Return true if cover is closed, else False."""
|
||||
return MYQ_TO_HASS[self._status] == STATE_CLOSED
|
||||
if self._status in [None, False]:
|
||||
return None
|
||||
return MYQ_TO_HASS.get(self._status) == STATE_CLOSED
|
||||
|
||||
@property
|
||||
def is_closing(self):
|
||||
"""Return if the cover is closing or not."""
|
||||
return MYQ_TO_HASS[self._status] == STATE_CLOSING
|
||||
return MYQ_TO_HASS.get(self._status) == STATE_CLOSING
|
||||
|
||||
@property
|
||||
def is_opening(self):
|
||||
"""Return if the cover is opening or not."""
|
||||
return MYQ_TO_HASS[self._status] == STATE_OPENING
|
||||
return MYQ_TO_HASS.get(self._status) == STATE_OPENING
|
||||
|
||||
def close_cover(self, **kwargs):
|
||||
"""Issue close command to cover."""
|
||||
|
|
Loading…
Reference in New Issue