Add support for discrete states to MyQ cover (#16251)

* Add discrete states and update dependency

* Add translation dict
This commit is contained in:
Matt Schmitt 2018-08-29 08:33:09 -04:00 committed by Martin Hjelmare
parent 18ba50bc2d
commit aaa1ebeed5
2 changed files with 28 additions and 5 deletions

View file

@ -8,17 +8,25 @@ import logging
import voluptuous as vol
from homeassistant.components.cover import CoverDevice
from homeassistant.components.cover import (
CoverDevice, SUPPORT_CLOSE, SUPPORT_OPEN)
from homeassistant.const import (
CONF_USERNAME, CONF_PASSWORD, CONF_TYPE, STATE_CLOSED)
CONF_PASSWORD, CONF_TYPE, CONF_USERNAME, STATE_CLOSED, STATE_CLOSING,
STATE_OPENING)
import homeassistant.helpers.config_validation as cv
REQUIREMENTS = ['pymyq==0.0.11']
REQUIREMENTS = ['pymyq==0.0.15']
_LOGGER = logging.getLogger(__name__)
DEFAULT_NAME = 'myq'
MYQ_TO_HASS = {
'closed': STATE_CLOSED,
'closing': STATE_CLOSING,
'opening': STATE_OPENING
}
NOTIFICATION_ID = 'myq_notification'
NOTIFICATION_TITLE = 'MyQ Cover Setup'
@ -87,7 +95,17 @@ class MyQDevice(CoverDevice):
@property
def is_closed(self):
"""Return true if cover is closed, else False."""
return self._status == STATE_CLOSED
return MYQ_TO_HASS[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
@property
def is_opening(self):
"""Return if the cover is opening or not."""
return MYQ_TO_HASS[self._status] == STATE_OPENING
def close_cover(self, **kwargs):
"""Issue close command to cover."""
@ -97,6 +115,11 @@ class MyQDevice(CoverDevice):
"""Issue open command to cover."""
self.myq.open_device(self.device_id)
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_OPEN | SUPPORT_CLOSE
def update(self):
"""Update status of cover."""
self._status = self.myq.get_status(self.device_id)

View file

@ -962,7 +962,7 @@ pymonoprice==0.3
pymusiccast==0.1.6
# homeassistant.components.cover.myq
pymyq==0.0.11
pymyq==0.0.15
# homeassistant.components.mysensors
pymysensors==0.17.0