From 56899d61fe2ae969e7d27799c26b8fcb2be2cf0b Mon Sep 17 00:00:00 2001 From: Adam Chyb Date: Tue, 30 Nov 2021 21:07:44 +1100 Subject: [PATCH] Add support for Kogan smart blinds to Tuya (#60552) --- homeassistant/components/tuya/cover.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/tuya/cover.py b/homeassistant/components/tuya/cover.py index b5ac5645cd2..2598429dda3 100644 --- a/homeassistant/components/tuya/cover.py +++ b/homeassistant/components/tuya/cover.py @@ -10,6 +10,7 @@ from tuya_iot import TuyaDevice, TuyaDeviceManager from homeassistant.components.cover import ( ATTR_POSITION, ATTR_TILT_POSITION, + DEVICE_CLASS_BLIND, DEVICE_CLASS_CURTAIN, DEVICE_CLASS_GARAGE, SUPPORT_CLOSE, @@ -68,6 +69,15 @@ COVERS: dict[str, tuple[TuyaCoverEntityDescription, ...]] = { set_position=DPCode.PERCENT_CONTROL_3, device_class=DEVICE_CLASS_CURTAIN, ), + # switch_1 is an undocumented code that behaves identically to control + # It is used by the Kogan Smart Blinds Driver + TuyaCoverEntityDescription( + key=DPCode.SWITCH_1, + name="Blind", + current_position=DPCode.PERCENT_CONTROL, + set_position=DPCode.PERCENT_CONTROL, + device_class=DEVICE_CLASS_BLIND, + ), ), # Garage Door Opener # https://developer.tuya.com/en/docs/iot/categoryckmkzq?id=Kaiuz0ipcboee @@ -183,9 +193,7 @@ class TuyaCoverEntity(TuyaEntity, CoverEntity): if device.function[description.key].type == "Boolean": self._attr_supported_features |= SUPPORT_OPEN | SUPPORT_CLOSE elif device.function[description.key].type == "Enum": - data_type = EnumTypeData.from_json( - device.status_range[description.key].values - ) + data_type = EnumTypeData.from_json(device.function[description.key].values) if "open" in data_type.range: self._attr_supported_features |= SUPPORT_OPEN if "close" in data_type.range: