Fix Velbus covers (includes velbus lib upgrade) (#31153)

* Fix velbus covers

* Update python-velbus lib

* flake8 and black fixes

* Fix comments

* fix codeowner
This commit is contained in:
Maikel Punie 2020-01-26 14:36:29 +01:00 committed by Martin Hjelmare
parent bc196a3c9f
commit 3f03848a07
5 changed files with 22 additions and 11 deletions

View File

@ -368,7 +368,7 @@ homeassistant/components/upnp/* @robbiet480
homeassistant/components/uptimerobot/* @ludeeus
homeassistant/components/usgs_earthquakes_feed/* @exxamalte
homeassistant/components/utility_meter/* @dgomes
homeassistant/components/velbus/* @cereal2nd
homeassistant/components/velbus/* @Cereal2nd
homeassistant/components/velux/* @Julius2342
homeassistant/components/versasense/* @flamm3blemuff1n
homeassistant/components/version/* @fabaff

View File

@ -4,8 +4,10 @@ import logging
from velbus.util import VelbusException
from homeassistant.components.cover import (
ATTR_POSITION,
SUPPORT_CLOSE,
SUPPORT_OPEN,
SUPPORT_SET_POSITION,
SUPPORT_STOP,
CoverDevice,
)
@ -33,24 +35,26 @@ class VelbusCover(VelbusEntity, CoverDevice):
@property
def supported_features(self):
"""Flag supported features."""
if self._module.support_position():
return SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP | SUPPORT_SET_POSITION
return SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP
@property
def is_closed(self):
"""Return if the cover is closed."""
return self._module.is_closed(self._channel)
if self._module.get_position(self._channel) == 100:
return True
return False
@property
def current_cover_position(self):
"""Return current position of cover.
None is unknown, 0 is closed, 100 is fully open
Velbus: 100 = closed, 0 = open
"""
if self._module.is_closed(self._channel):
return 0
if self._module.is_open(self._channel):
return 100
return None
pos = self._module.get_position(self._channel)
return 100 - pos
def open_cover(self, **kwargs):
"""Open the cover."""
@ -72,3 +76,10 @@ class VelbusCover(VelbusEntity, CoverDevice):
self._module.stop(self._channel)
except VelbusException as err:
_LOGGER.error("A Velbus error occurred: %s", err)
def set_cover_position(self, **kwargs):
"""Move the cover to a specific position."""
try:
self._module.set(self._channel, (100 - kwargs[ATTR_POSITION]))
except VelbusException as err:
_LOGGER.error("A Velbus error occurred: %s", err)

View File

@ -2,8 +2,8 @@
"domain": "velbus",
"name": "Velbus",
"documentation": "https://www.home-assistant.io/integrations/velbus",
"requirements": ["python-velbus==2.0.35"],
"requirements": ["python-velbus==2.0.36"],
"config_flow": true,
"dependencies": [],
"codeowners": ["@cereal2nd"]
"codeowners": ["@Cereal2nd"]
}

View File

@ -1629,7 +1629,7 @@ python-telnet-vlc==1.0.4
python-twitch-client==0.6.0
# homeassistant.components.velbus
python-velbus==2.0.35
python-velbus==2.0.36
# homeassistant.components.vlc
python-vlc==1.1.2

View File

@ -540,7 +540,7 @@ python-miio==0.4.8
python-nest==4.1.0
# homeassistant.components.velbus
python-velbus==2.0.35
python-velbus==2.0.36
# homeassistant.components.awair
python_awair==0.0.4