Skip to content

Commit

Permalink
Merger TS004Fs to EnchantedDevice. (#2046)
Browse files Browse the repository at this point in the history
* Merger TS004Fs to EnchantedDevice.

Merger all device classes of TS004f to EnchantedDevice and adding one more found DS.
All function is tested after deleting and reset and removing the battery and adding them they is getting the magic function then doing one new joining. All commands looks OK in the log but have not testing the DA then its not changed.

* Delete unused asyncio.
  • Loading branch information
MattWestb authored Dec 31, 2022
1 parent ca37203 commit 2e627e4
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions zhaquirks/tuya/ts004f.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Tuya TS004F devices."""
from __future__ import annotations

import asyncio
import logging

from zigpy.profiles import zha
Expand Down Expand Up @@ -60,11 +59,12 @@
TURN_ON,
)
from zhaquirks.tuya import TuyaSmartRemoteOnOffCluster, TuyaZBOnOffAttributeCluster
from zhaquirks.tuya.mcu import EnchantedDevice

_LOGGER = logging.getLogger(__name__)


class TuyaSmartRemote004FROK(CustomDevice):
class TuyaSmartRemote004FROK(EnchantedDevice, CustomDevice):
"""Tuya Smart (rotating) Knob device."""

signature = {
Expand Down Expand Up @@ -183,27 +183,16 @@ class TuyaSmartRemote004FROK(CustomDevice):
}


class TuyaSmartRemote004FDMS(CustomDevice):
class TuyaSmartRemote004FDMS(EnchantedDevice, CustomDevice):
"""Tuya 4 btton dimmer switch / remote device."""

def __init__(self, *args, **kwargs):
"""Initialize with task."""
super().__init__(*args, **kwargs)

self._init_plug_task = asyncio.create_task(self.spell())

async def spell(self) -> None:
"""Initialize device so that all endpoints become available."""
basic_cluster = self.endpoints[1].in_clusters[0]

attr_to_read = [4, 0, 1, 5, 7, 0xFFFE]
await basic_cluster.read_attributes(attr_to_read)
_LOGGER.debug("Device class is casting Tuya Magic Spell")

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, maximum_outgoing_transfer_size=82, descriptor_capability_field=0, *allocate_address=True, *complex_descriptor_available=False, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=True, *is_full_function_device=False, *is_mains_powered=False, *is_receiver_on_when_idle=False, *is_router=False, *is_security_capable=False, *is_valid=True, *logical_type=<LogicalType.EndDevice: 2>, *user_descriptor_available=False)",
# SizePrefixedSimpleDescriptor(endpoint=1, profile=260, device_type=260, device_version=1, input_clusters=[0, 1, 3, 4, 6, 4096], output_clusters=[25, 10, 3, 4, 5, 6, 8, 4096])
MODELS_INFO: [("_TZ3000_xabckq1v", "TS004F")],
MODELS_INFO: [
("_TZ3000_xabckq1v", "TS004F"),
("_TZ3000_czuyt8lz", "TS004F"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
Expand Down Expand Up @@ -328,7 +317,7 @@ async def spell(self) -> None:
}


class TuyaSmartRemote004F(CustomDevice):
class TuyaSmartRemote004F(EnchantedDevice, CustomDevice):
"""Tuya 4-button New version remote device."""

signature = {
Expand Down

0 comments on commit 2e627e4

Please sign in to comment.