Add stop support to openzwave (mqtt) cover (#44622)
* feat: add stop to openzwave (mqtt) cover
* Fix isort and black linter
* Remove supported_features for cover.
As suggested by @MartinHjelmare, not needed anymore because base class
implementation is sufficient.
https://github.com/home-assistant/core/pull/44622#discussion_r549854542
* Make a simpler version depending on idempotency
qt-openzwave already implements idempotency, see:
77e414217f/qt-openzwave/source/qtozwvalueidmodel.cpp (L180)
We can use it and trigger button release anywhen.
* Clean up
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
a73a82e381
commit
707a8e62f9
2 changed files with 83 additions and 35 deletions
|
@ -7,7 +7,6 @@ from homeassistant.components.cover import (
|
|||
DOMAIN as COVER_DOMAIN,
|
||||
SUPPORT_CLOSE,
|
||||
SUPPORT_OPEN,
|
||||
SUPPORT_SET_POSITION,
|
||||
CoverEntity,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
|
@ -16,9 +15,10 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
|||
from .const import DATA_UNSUBSCRIBE, DOMAIN
|
||||
from .entity import ZWaveDeviceEntity
|
||||
|
||||
SUPPORTED_FEATURES_POSITION = SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION
|
||||
SUPPORT_GARAGE = SUPPORT_OPEN | SUPPORT_CLOSE
|
||||
VALUE_SELECTED_ID = "Selected_id"
|
||||
PRESS_BUTTON = True
|
||||
RELEASE_BUTTON = False
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
|
@ -52,11 +52,6 @@ def percent_to_zwave_position(value):
|
|||
class ZWaveCoverEntity(ZWaveDeviceEntity, CoverEntity):
|
||||
"""Representation of a Z-Wave Cover device."""
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag supported features."""
|
||||
return SUPPORTED_FEATURES_POSITION
|
||||
|
||||
@property
|
||||
def is_closed(self):
|
||||
"""Return true if cover is closed."""
|
||||
|
@ -73,11 +68,20 @@ class ZWaveCoverEntity(ZWaveDeviceEntity, CoverEntity):
|
|||
|
||||
async def async_open_cover(self, **kwargs):
|
||||
"""Open the cover."""
|
||||
self.values.primary.send_value(99)
|
||||
self.values.open.send_value(PRESS_BUTTON)
|
||||
|
||||
async def async_close_cover(self, **kwargs):
|
||||
"""Close cover."""
|
||||
self.values.primary.send_value(0)
|
||||
self.values.close.send_value(PRESS_BUTTON)
|
||||
|
||||
async def async_stop_cover(self, **kwargs):
|
||||
"""Stop cover."""
|
||||
# Need to issue both buttons release since qt-openzwave implements idempotency
|
||||
# keeping internal state of model to trigger actual updates. We could also keep
|
||||
# another state in Home Assistant to know which button to release,
|
||||
# but this implementation is simpler.
|
||||
self.values.open.send_value(RELEASE_BUTTON)
|
||||
self.values.close.send_value(RELEASE_BUTTON)
|
||||
|
||||
|
||||
class ZwaveGarageDoorBarrier(ZWaveDeviceEntity, CoverEntity):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue