Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions zhaquirks/tuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
TUYA_MCU_VERSION_RSP = 0x11
TUYA_LEVEL_COMMAND = 514

BATTERY_CHANGE = "battery_change"
LEVEL_EVENT = "level_event"
TUYA_MCU_COMMAND = "tuya_mcu_command"

Expand Down Expand Up @@ -1235,6 +1236,16 @@ def handle_cluster_request(
ATTR_COVER_INVERTED,
tuya_payload.data[1], # Check this
)
elif (
self.endpoint.device.tuya_battery_attr is not None
and tuya_payload.command_id
== TUYA_DP_TYPE_VALUE + self.endpoint.device.tuya_battery_attr
):
self.endpoint.device.battery_bus.listener_event(
BATTERY_CHANGE,
tuya_payload.data[4],
)

elif hdr.command_id == TUYA_SET_TIME:
"""Time event call super"""
super().handle_cluster_request(hdr, args, dst_addressing=dst_addressing)
Expand Down Expand Up @@ -1377,9 +1388,13 @@ class TuyaWindowCover(CustomDevice):
# Don't invert _TZE200_cowvfni3: https://github.com/Koenkk/zigbee2mqtt/issues/6043
tuya_cover_inverted_by_default = False

# For covers which report battery, this sets the battery report attribute id
tuya_battery_attr = None

def __init__(self, *args, **kwargs):
"""Init device."""
self.cover_bus = Bus()
self.battery_bus = Bus()
super().__init__(*args, **kwargs)


Expand Down
7 changes: 7 additions & 0 deletions zhaquirks/tuya/ts0601_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
from zhaquirks.tuya import (
TuyaManufacturerWindowCover,
TuyaManufCluster,
TuyaPowerConfigurationCluster,
TuyaWindowCover,
TuyaWindowCoverControl,
)

ZEMISMART_BATTERY_ATTR = 0x0D


class TuyaZemismartSmartCover0601(TuyaWindowCover):
"""Tuya Zemismart blind cover motor."""
Expand Down Expand Up @@ -352,6 +355,8 @@ class TuyaZemismartSmartCover0601_2_inv_position(TuyaWindowCover):
class TuyaMoesCover0601(TuyaWindowCover):
"""Tuya blind controller device."""

tuya_battery_attr = ZEMISMART_BATTERY_ATTR

signature = {
# "node_descriptor": "NodeDescriptor(byte1=2, byte2=64, mac_capability_flags=128, manufacturer_code=4098,
# maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264,
Expand Down Expand Up @@ -381,6 +386,7 @@ class TuyaMoesCover0601(TuyaWindowCover):
("_TZE200_icka1clh", "TS0601"),
("_TZE200_1vxgqfba", "TS0601"),
("_TZE200_fctwhugx", "TS0601"),
("_TZE200_vexa5o82", "TS0601"),
],
ENDPOINTS: {
1: {
Expand All @@ -407,6 +413,7 @@ class TuyaMoesCover0601(TuyaWindowCover):
Scenes.cluster_id,
TuyaManufacturerWindowCover,
TuyaWindowCoverControl,
TuyaPowerConfigurationCluster,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
}
Expand Down
Loading