Add support for Kogan smart blinds to Tuya (#60552)

This commit is contained in:
Adam Chyb 2021-11-30 21:07:44 +11:00 committed by GitHub
parent ae9320b616
commit 56899d61fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: