Add Motionblinds WoodShutter support (#72814)

pull/72824/head
starkillerOG 2022-06-01 12:33:13 +02:00 committed by Franck Nijhof
parent 9e723f9b6d
commit 1139136365
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
4 changed files with 61 additions and 3 deletions

View File

@ -9,6 +9,7 @@ from homeassistant.components.cover import (
ATTR_TILT_POSITION,
CoverDeviceClass,
CoverEntity,
CoverEntityFeature,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
@ -64,6 +65,10 @@ TILT_DEVICE_MAP = {
BlindType.VerticalBlindRight: CoverDeviceClass.BLIND,
}
TILT_ONLY_DEVICE_MAP = {
BlindType.WoodShutter: CoverDeviceClass.BLIND,
}
TDBU_DEVICE_MAP = {
BlindType.TopDownBottomUp: CoverDeviceClass.SHADE,
}
@ -108,6 +113,16 @@ async def async_setup_entry(
)
)
elif blind.type in TILT_ONLY_DEVICE_MAP:
entities.append(
MotionTiltOnlyDevice(
coordinator,
blind,
TILT_ONLY_DEVICE_MAP[blind.type],
sw_version,
)
)
elif blind.type in TDBU_DEVICE_MAP:
entities.append(
MotionTDBUDevice(
@ -356,6 +371,49 @@ class MotionTiltDevice(MotionPositionDevice):
await self.hass.async_add_executor_job(self._blind.Stop)
class MotionTiltOnlyDevice(MotionTiltDevice):
"""Representation of a Motion Blind Device."""
_restore_tilt = False
@property
def supported_features(self):
"""Flag supported features."""
supported_features = (
CoverEntityFeature.OPEN_TILT
| CoverEntityFeature.CLOSE_TILT
| CoverEntityFeature.STOP_TILT
)
if self.current_cover_tilt_position is not None:
supported_features |= CoverEntityFeature.SET_TILT_POSITION
return supported_features
@property
def current_cover_position(self):
"""Return current position of cover."""
return None
@property
def is_closed(self):
"""Return if the cover is closed or not."""
if self._blind.angle is None:
return None
return self._blind.angle == 0
async def async_set_absolute_position(self, **kwargs):
"""Move the cover to a specific absolute position (see TDBU)."""
angle = kwargs.get(ATTR_TILT_POSITION)
if angle is not None:
angle = angle * 180 / 100
async with self._api_lock:
await self.hass.async_add_executor_job(
self._blind.Set_angle,
angle,
)
class MotionTDBUDevice(MotionPositionDevice):
"""Representation of a Motion Top Down Bottom Up blind Device."""

View File

@ -3,7 +3,7 @@
"name": "Motion Blinds",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/motion_blinds",
"requirements": ["motionblinds==0.6.7"],
"requirements": ["motionblinds==0.6.8"],
"dependencies": ["network"],
"dhcp": [
{ "registered_devices": true },

View File

@ -1038,7 +1038,7 @@ mitemp_bt==0.0.5
moehlenhoff-alpha2==1.2.1
# homeassistant.components.motion_blinds
motionblinds==0.6.7
motionblinds==0.6.8
# homeassistant.components.motioneye
motioneye-client==0.3.12

View File

@ -715,7 +715,7 @@ minio==5.0.10
moehlenhoff-alpha2==1.2.1
# homeassistant.components.motion_blinds
motionblinds==0.6.7
motionblinds==0.6.8
# homeassistant.components.motioneye
motioneye-client==0.3.12