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 (
|
from homeassistant.components.cover import (
|
||||||
CoverDevice, SUPPORT_CLOSE, SUPPORT_OPEN)
|
CoverDevice, SUPPORT_CLOSE, SUPPORT_OPEN)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_PASSWORD, CONF_TYPE, CONF_USERNAME, STATE_CLOSED, STATE_OPEN,
|
CONF_PASSWORD, CONF_TYPE, CONF_USERNAME, STATE_CLOSED, STATE_CLOSING,
|
||||||
STATE_CLOSING, STATE_OPENING)
|
STATE_OPEN, STATE_OPENING)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
REQUIREMENTS = ['pymyq==0.0.15']
|
REQUIREMENTS = ['pymyq==0.0.15']
|
||||||
|
@ -23,8 +23,8 @@ DEFAULT_NAME = 'myq'
|
||||||
|
|
||||||
MYQ_TO_HASS = {
|
MYQ_TO_HASS = {
|
||||||
'closed': STATE_CLOSED,
|
'closed': STATE_CLOSED,
|
||||||
'open': STATE_OPEN,
|
|
||||||
'closing': STATE_CLOSING,
|
'closing': STATE_CLOSING,
|
||||||
|
'open': STATE_OPEN,
|
||||||
'opening': STATE_OPENING
|
'opening': STATE_OPENING
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class MyQDevice(CoverDevice):
|
||||||
self.myq = myq
|
self.myq = myq
|
||||||
self.device_id = device['deviceid']
|
self.device_id = device['deviceid']
|
||||||
self._name = device['name']
|
self._name = device['name']
|
||||||
self._status = STATE_CLOSED
|
self._status = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
|
@ -96,17 +96,19 @@ class MyQDevice(CoverDevice):
|
||||||
@property
|
@property
|
||||||
def is_closed(self):
|
def is_closed(self):
|
||||||
"""Return true if cover is closed, else False."""
|
"""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
|
@property
|
||||||
def is_closing(self):
|
def is_closing(self):
|
||||||
"""Return if the cover is closing or not."""
|
"""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
|
@property
|
||||||
def is_opening(self):
|
def is_opening(self):
|
||||||
"""Return if the cover is opening or not."""
|
"""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):
|
def close_cover(self, **kwargs):
|
||||||
"""Issue close command to cover."""
|
"""Issue close command to cover."""
|
||||||
|
|
Loading…
Reference in New Issue