zigpy / zha-device-handlers

ZHA device handlers bridge the functionality gap created when manufacturers deviate from the ZCL specification, handling deviations and exceptions by parsing custom messages to and from Zigbee devices.
Apache License 2.0
751 stars 688 forks source link

[Device Support Request] TZE200_fwoorn8y #2129

Closed antoweb closed 4 months ago

antoweb commented 1 year ago

Is your feature request related to a problem? Please describe. Is possible to write a quirk for the device i subject? Attached are diagnostic information

Describe the solution you'd like A clear and concise description of what you want to happen.

Device signature ```yaml Paste the device signature here. Don't remove the extra line breaks outside the ``` marks. ```
Diagnostic information ```yaml { "home_assistant": { "installation_type": "Home Assistant OS", "version": "2023.1.7", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.10.7", "docker": true, "arch": "aarch64", "timezone": "Europe/Rome", "os_name": "Linux", "os_version": "5.15.76-v8", "supervisor": "2022.12.1", "host_os": "Home Assistant OS 9.4", "docker_version": "20.10.19", "chassis": "embedded", "run_as_root": true }, "custom_components": { "iphonedetect": { "version": "1.4.0", "requirements": [] }, "tuya_local": { "version": "2022.1.2", "requirements": [ "pycryptodome~=3.16.0", "tinytuya==1.9.1" ] }, "hacs": { "version": "1.30.0", "requirements": [ "aiogithubapi>=22.10.1" ] }, "candy": { "version": "1.0.0", "requirements": [ "backoff~=2.0", "aiolimiter~=1.0" ] }, "shelly": { "version": "1.0.2", "requirements": [ "pyShelly==1.0.2", "paho-mqtt==1.6.1", "websocket-client" ] }, "smartir": { "version": "1.17.6", "requirements": [ "aiofiles==0.6.0" ] }, "arpscan_tracker": { "version": "1.0.6", "requirements": [] }, "xiaomi_miot": { "version": "0.7.5", "requirements": [ "construct==2.10.56", "python-miio>=0.5.6", "micloud>=0.3" ] }, "alexa_media": { "version": "4.5.3", "requirements": [ "alexapy==1.26.4", "packaging>=20.3", "wrapt>=1.12.1" ] }, "ble_monitor": { "version": "11.4.1", "requirements": [ "pycryptodomex>=3.14.1", "janus>=1.0.0", "aioblescan>=0.2.14", "btsocket>=0.2.0", "pyric>=0.1.6.3" ] }, "sonoff": { "version": "3.3.1", "requirements": [ "pycryptodome>=3.6.6" ] } }, "integration_manifest": { "domain": "zha", "name": "Zigbee Home Automation", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/zha", "requirements": [ "bellows==0.34.6", "pyserial==3.5", "pyserial-asyncio==0.6", "zha-quirks==0.0.90", "zigpy-deconz==0.19.2", "zigpy==0.53.0", "zigpy-xbee==0.16.2", "zigpy-zigate==0.10.3", "zigpy-znp==0.9.2" ], "usb": [ { "vid": "10C4", "pid": "EA60", "description": "*2652*", "known_devices": [ "slae.sh cc2652rb stick" ] }, { "vid": "1A86", "pid": "55D4", "description": "*sonoff*plus*", "known_devices": [ "sonoff zigbee dongle plus v2" ] }, { "vid": "10C4", "pid": "EA60", "description": "*sonoff*plus*", "known_devices": [ "sonoff zigbee dongle plus" ] }, { "vid": "10C4", "pid": "EA60", "description": "*tubeszb*", "known_devices": [ "TubesZB Coordinator" ] }, { "vid": "1A86", "pid": "7523", "description": "*tubeszb*", "known_devices": [ "TubesZB Coordinator" ] }, { "vid": "1A86", "pid": "7523", "description": "*zigstar*", "known_devices": [ "ZigStar Coordinators" ] }, { "vid": "1CF1", "pid": "0030", "description": "*conbee*", "known_devices": [ "Conbee II" ] }, { "vid": "10C4", "pid": "8A2A", "description": "*zigbee*", "known_devices": [ "Nortek HUSBZB-1" ] }, { "vid": "0403", "pid": "6015", "description": "*zigate*", "known_devices": [ "ZiGate+" ] }, { "vid": "10C4", "pid": "EA60", "description": "*zigate*", "known_devices": [ "ZiGate" ] }, { "vid": "10C4", "pid": "8B34", "description": "*bv 2010/10*", "known_devices": [ "Bitron Video AV2010/10" ] } ], "codeowners": [ "@dmulcahey", "@adminiuga", "@puddly" ], "zeroconf": [ { "type": "_esphomelib._tcp.local.", "name": "tube*" }, { "type": "_zigate-zigbee-gateway._tcp.local.", "name": "*zigate*" }, { "type": "_zigstar_gw._tcp.local.", "name": "*zigstar*" }, { "type": "_slzb-06._tcp.local.", "name": "slzb-06*" } ], "dependencies": [ "file_upload" ], "after_dependencies": [ "onboarding", "usb", "zeroconf" ], "iot_class": "local_polling", "loggers": [ "aiosqlite", "bellows", "crccheck", "pure_pcapy3", "zhaquirks", "zigpy", "zigpy_deconz", "zigpy_xbee", "zigpy_zigate", "zigpy_znp" ], "is_built_in": true }, "data": { "ieee": "**REDACTED**", "nwk": 50992, "manufacturer": "_TZE200_fwoorn8y", "model": "TS0601", "name": "_TZE200_fwoorn8y TS0601", "quirk_applied": false, "quirk_class": "zigpy.device.Device", "manufacturer_code": 4417, "power_source": "Battery or Unknown", "lqi": 153, "rssi": null, "last_seen": "2023-01-24T15:14:53", "available": true, "device_type": "EndDevice", "signature": { "node_descriptor": "NodeDescriptor(logical_type=, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=, mac_capability_flags=, manufacturer_code=4417, maximum_buffer_size=66, maximum_incoming_transfer_size=66, server_mask=10752, maximum_outgoing_transfer_size=66, descriptor_capability_field=, *allocate_address=True, *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)", "endpoints": { "1": { "profile_id": 260, "device_type": "0x0402", "in_clusters": [ "0x0000", "0x0001", "0x0500" ], "out_clusters": [ "0x000a", "0x0019" ] } } }, "active_coordinator": false, "entities": [ { "entity_id": "sensor.sensore_portone_battery", "name": "_TZE200_fwoorn8y TS0601" }, { "entity_id": "binary_sensor.sensore_portone", "name": "_TZE200_fwoorn8y TS0601" } ], "neighbors": [], "routes": [], "endpoint_names": [ { "name": "IAS_ZONE" } ], "user_given_name": "Sensore Portone", "device_reg_id": "365222b8b5d4cc9930d83addc54e88a7", "area_id": "scale", "cluster_details": { "1": { "device_type": { "name": "IAS_ZONE", "id": 1026 }, "profile_id": 260, "in_clusters": { "0x0001": { "endpoint_attribute": "power", "attributes": { "0x0020": { "attribute_name": "battery_voltage", "value": 0 }, "0x0021": { "attribute_name": "battery_percentage_remaining", "value": 0 } }, "unsupported_attributes": { "0x0031": { "attribute_name": "battery_size" }, "0x0033": { "attribute_name": "battery_quantity" } } }, "0x0500": { "endpoint_attribute": "ias_zone", "attributes": { "0x0000": { "attribute_name": "zone_state", "value": 0 }, "0x0001": { "attribute_name": "zone_type", "value": 40 }, "0x0002": { "attribute_name": "zone_status", "value": 0 }, "0x0010": { "attribute_name": "cie_addr", "value": [ 54, 80, 192, 36, 0, 75, 18, 0 ] } }, "unsupported_attributes": {} }, "0x0000": { "endpoint_attribute": "basic", "attributes": { "0x0004": { "attribute_name": "manufacturer", "value": "_TZE200_fwoorn8y" }, "0x0005": { "attribute_name": "model", "value": "TS0601" } }, "unsupported_attributes": {} } }, "out_clusters": { "0x0019": { "endpoint_attribute": "ota", "attributes": {}, "unsupported_attributes": {} }, "0x000a": { "endpoint_attribute": "time", "attributes": {}, "unsupported_attributes": {} } } } } } } ```
Additional logs ``` Paste any additional debug logs here. Don't remove the extra line breaks outside the ``` marks. ```

Additional context Add any other context or screenshots about the feature request here.

antoweb commented 1 year ago

I have used the same quirk of _TZE200_pay2byax changing just line 84 to: MODELS_INFO: [("_TZE200_fwoorn8y", "TS0601")], Attach are the python quirk to rename in py and copy in \config\custom_zha_quirks ts0601_TZE200_fwoorn8y_magnet.txt

TheJulianJES commented 1 year ago

I have used the same quirk of _TZE200_pay2byax changin just line 84 to: ...

And does the device work with that custom quirk?

antoweb commented 1 year ago

Yes work but without illuminance and battery. Work just the open/close door (the most important) i dont know python if tehre is someone that want to edit this script for add illuminance and battery state is welcome :-)

antoweb commented 1 year ago

Ok work also the battery sensor. Just illuminance is missing

javicalle commented 1 year ago

The quirk here have the iluminance implemented: https://github.com/zigpy/zha-device-handlers/issues/1502#issuecomment-1378743535

If not working, enable the debug logs and attach them.

antoweb commented 1 year ago

Yes thanks but for this model must be modify the line 86

from: MODELS_INFO: [("_TZE200_pay2byax", "TS0601")],

to: MODELS_INFO: [("_TZE200_fwoorn8y", "TS0601")],

javicalle commented 1 year ago

Well, the right way to do it would be to add your device like this:

        MODELS_INFO: [
            ("_TZE200_fwoorn8y", "TS0601"),
            ("_TZE200_pay2byax", "TS0601"),
        ],

Your quirk does not implement DP=101 and the suggested one does. Have you tried it? Without the debug logs we can't know where is the problem and we can't help you.

antoweb commented 1 year ago

Yes i have tried and works good..thanks for the suggestion to add the device

javicalle commented 1 year ago

Great! Do you mind to create the PR with the working code?

antoweb commented 1 year ago

Wath is PR?

javicalle commented 1 year ago

PR states for "Pull Request" the way to propose changes to the library mainstream. Don't worry if you are not familiar.

Could you check that this version is working and fixes your device:

ts0601_magnet.py ```python """Tuya contact sensor device.""" import math from typing import Dict from zigpy.profiles import zha from zigpy.quirks import CustomDevice from zigpy.zcl.clusters.general import Basic, Ota, Time from zigpy.zcl.clusters.measurement import IlluminanceMeasurement from zigpy.zcl.clusters.security import IasZone from zhaquirks import DoublingPowerConfigurationCluster from zhaquirks.const import ( DEVICE_TYPE, ENDPOINTS, INPUT_CLUSTERS, MODELS_INFO, OUTPUT_CLUSTERS, PROFILE_ID, ZONE_TYPE, ) from zhaquirks.tuya import TuyaLocalCluster, TuyaDPType from zhaquirks.tuya.mcu import ( DPToAttributeMapping, TuyaAttributesCluster, TuyaMCUCluster, ) class ContactSwitchCluster(TuyaAttributesCluster, IasZone): """Tuya ContactSwitch Sensor.""" _CONSTANT_ATTRIBUTES = {ZONE_TYPE: IasZone.ZoneType.Contact_Switch} def _update_attribute(self, attrid, value): self.debug("_update_attribute '%s': %s", attrid, value) super()._update_attribute(attrid, value) class TuyaPowerConfigurationCluster( TuyaLocalCluster, DoublingPowerConfigurationCluster ): """PowerConfiguration cluster for battery-operated tuya devices reporting percentage.""" class TuyaIlluminanceMeasurement(IlluminanceMeasurement, TuyaLocalCluster): """Tuya local IlluminanceMeasurement cluster.""" class ContactSwitchManufCluster(TuyaMCUCluster): """Tuya Manufacturer Cluster with ContactSwitch Sensor data points.""" dp_to_attribute: Dict[int, DPToAttributeMapping] = { 1: DPToAttributeMapping( ContactSwitchCluster.ep_attribute, "zone_status", dp_type=TuyaDPType.ENUM, ), 2: DPToAttributeMapping( DoublingPowerConfigurationCluster.ep_attribute, "battery_percentage_remaining", # 0x0021 dp_type=TuyaDPType.VALUE, ), 101: DPToAttributeMapping( TuyaIlluminanceMeasurement.ep_attribute, "measured_value", dp_type=TuyaDPType.VALUE, converter=lambda x: 10000 * math.log10(x) + 1, ), } data_point_handlers = { 1: "_dp_2_attr_update", 2: "_dp_2_attr_update", 101: "_dp_2_attr_update", } class TuyaContactSensor(CustomDevice): """Tuya contact sensor device.""" signature = { # NodeDescriptor(logical_type=, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=, mac_capability_flags=, manufacturer_code=4417, maximum_buffer_size=66, maximum_incoming_transfer_size=66, server_mask=10752, maximum_outgoing_transfer_size=66, descriptor_capability_field=, *allocate_address=True, *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)] # device_version=1 # SizePrefixedSimpleDescriptor(endpoint=1, profile=260, device_type=1026, device_version=1, # input_clusters=[0, 1, 1280], # output_clusters=[10, 25]) MODELS_INFO: [ ("_TZE200_fwoorn8y", "TS0601"), ("_TZE200_pay2byax", "TS0601"), ], ENDPOINTS: { 1: { PROFILE_ID: zha.PROFILE_ID, DEVICE_TYPE: zha.DeviceType.IAS_ZONE, INPUT_CLUSTERS: [ Basic.cluster_id, DoublingPowerConfigurationCluster.cluster_id, IasZone.cluster_id, ], OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id], } }, } replacement = { ENDPOINTS: { 1: { INPUT_CLUSTERS: [ Basic.cluster_id, TuyaPowerConfigurationCluster, ContactSwitchCluster, ContactSwitchManufCluster, TuyaIlluminanceMeasurement, ], OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id], } } } ```
patrickdass93 commented 1 year ago

How do I add this to HA? I can test to see if it works.

javicalle commented 1 year ago

How do I add this to HA? I can test to see if it works.

You would need enable the local quirk folder in your installation. There is a good guide to configure it:

Once configured, create in your custom_zha_quirks folder (i.e.) a ts0601_magnet.py file with the suggested code. Save changes and repair your device. Check if the device signature has changed.

patrickdass93 commented 1 year ago

I got this error when restarting HA

Logger: homeassistant.config_entries
Source: custom_zha_quirks/ts0601_magnet.py:54
First occurred: 12:36:10 PM (1 occurrences)
Last logged: 12:36:10 PM

Error setting up entry socket://192.168.0.219:6638 for zha
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 382, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/zha/__init__.py", line 100, in async_setup_entry
    setup_quirks(config)
  File "/usr/local/lib/python3.10/site-packages/zhaquirks/__init__.py", line 409, in setup
    importer.find_module(modname).load_module(modname)
  File "<frozen importlib._bootstrap_external>", line 548, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 1063, in load_module
  File "<frozen importlib._bootstrap_external>", line 888, in load_module
  File "<frozen importlib._bootstrap>", line 290, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 719, in _load
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_zha_quirks/ts0601_magnet.py", line 50, in <module>
    class ContactSwitchManufCluster(TuyaMCUCluster):
  File "/config/custom_zha_quirks/ts0601_magnet.py", line 54, in ContactSwitchManufCluster
    1: DPToAttributeMapping(
TypeError: DPToAttributeMapping.__init__() missing 1 required positional argument: 'dp_type'
javicalle commented 1 year ago

Sorry, new version incoming... I have added all the dp_type=TuyaDPType.XXXX in the DPToAttributeMapping definitions.

patrickdass93 commented 1 year ago

Hi @javicalle

There's still an error.

Logger: homeassistant.config_entries
Source: custom_zha_quirks/ts0601_magnet.py:57
First occurred: 1:36:47 PM (1 occurrences)
Last logged: 1:36:47 PM

Error setting up entry socket://192.168.0.219:6638 for zha
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 382, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/zha/__init__.py", line 100, in async_setup_entry
    setup_quirks(config)
  File "/usr/local/lib/python3.10/site-packages/zhaquirks/__init__.py", line 409, in setup
    importer.find_module(modname).load_module(modname)
  File "<frozen importlib._bootstrap_external>", line 548, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 1063, in load_module
  File "<frozen importlib._bootstrap_external>", line 888, in load_module
  File "<frozen importlib._bootstrap>", line 290, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 719, in _load
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_zha_quirks/ts0601_magnet.py", line 50, in <module>
    class ContactSwitchManufCluster(TuyaMCUCluster):
  File "/config/custom_zha_quirks/ts0601_magnet.py", line 57, in ContactSwitchManufCluster
    dp_type=TuyaDPType.ENUM,
NameError: name 'TuyaDPType' is not defined
TheJulianJES commented 1 year ago

Make sure you're importing TuyaDPType from zhaquirks.tuya. For example: from zhaquirks.tuya import TuyaLocalCluster, TuyaDPType

patrickdass93 commented 1 year ago

Thank you @TheJulianJES that worked.

@javicalle Unfortunately, I do not get the sensor to show data

image
{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2023.2.5",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.10.7",
    "docker": true,
    "arch": "aarch64",
    "timezone": "Asia/Kuala_Lumpur",
    "os_name": "Linux",
    "os_version": "5.15.84-v8",
    "supervisor": "2023.01.1",
    "host_os": "Home Assistant OS 9.5",
    "docker_version": "20.10.22",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {
    "sonoff": {
      "version": "3.4.0",
      "requirements": [
        "pycryptodome>=3.6.6"
      ]
    },
    "hacs": {
      "version": "1.30.1",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "wyzeapi": {
      "version": "0.1.17",
      "requirements": [
        "wyzeapy==0.5.16"
      ]
    },
    "ui_lovelace_minimalist": {
      "version": "v1.1.6-hotfix",
      "requirements": [
        "aiofiles==0.8.0",
        "aiogithubapi>=22.2.4"
      ]
    },
    "localtuya": {
      "version": "5.0.0",
      "requirements": []
    },
    "ble_monitor": {
      "version": "11.7.1",
      "requirements": [
        "pycryptodomex>=3.14.1",
        "janus>=1.0.0",
        "aioblescan>=0.2.14",
        "btsocket>=0.2.0",
        "pyric>=0.1.6.3"
      ]
    },
    "tuya_local": {
      "version": "2022.2.3",
      "requirements": [
        "pycryptodome~=3.17",
        "tinytuya==1.10.2"
      ]
    },
    "mass": {
      "version": "2023.2.1",
      "requirements": [
        "music-assistant==1.8.7.4"
      ]
    }
  },
  "integration_manifest": {
    "domain": "zha",
    "name": "Zigbee Home Automation",
    "config_flow": true,
    "documentation": "https://www.home-assistant.io/integrations/zha",
    "requirements": [
      "bellows==0.34.7",
      "pyserial==3.5",
      "pyserial-asyncio==0.6",
      "zha-quirks==0.0.92",
      "zigpy-deconz==0.19.2",
      "zigpy==0.53.0",
      "zigpy-xbee==0.16.2",
      "zigpy-zigate==0.10.3",
      "zigpy-znp==0.9.2"
    ],
    "usb": [
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*2652*",
        "known_devices": [
          "slae.sh cc2652rb stick"
        ]
      },
      {
        "vid": "1A86",
        "pid": "55D4",
        "description": "*sonoff*plus*",
        "known_devices": [
          "sonoff zigbee dongle plus v2"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*sonoff*plus*",
        "known_devices": [
          "sonoff zigbee dongle plus"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*tubeszb*",
        "known_devices": [
          "TubesZB Coordinator"
        ]
      },
      {
        "vid": "1A86",
        "pid": "7523",
        "description": "*tubeszb*",
        "known_devices": [
          "TubesZB Coordinator"
        ]
      },
      {
        "vid": "1A86",
        "pid": "7523",
        "description": "*zigstar*",
        "known_devices": [
          "ZigStar Coordinators"
        ]
      },
      {
        "vid": "1CF1",
        "pid": "0030",
        "description": "*conbee*",
        "known_devices": [
          "Conbee II"
        ]
      },
      {
        "vid": "10C4",
        "pid": "8A2A",
        "description": "*zigbee*",
        "known_devices": [
          "Nortek HUSBZB-1"
        ]
      },
      {
        "vid": "0403",
        "pid": "6015",
        "description": "*zigate*",
        "known_devices": [
          "ZiGate+"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*zigate*",
        "known_devices": [
          "ZiGate"
        ]
      },
      {
        "vid": "10C4",
        "pid": "8B34",
        "description": "*bv 2010/10*",
        "known_devices": [
          "Bitron Video AV2010/10"
        ]
      }
    ],
    "codeowners": [
      "@dmulcahey",
      "@adminiuga",
      "@puddly"
    ],
    "zeroconf": [
      {
        "type": "_esphomelib._tcp.local.",
        "name": "tube*"
      },
      {
        "type": "_zigate-zigbee-gateway._tcp.local.",
        "name": "*zigate*"
      },
      {
        "type": "_zigstar_gw._tcp.local.",
        "name": "*zigstar*"
      },
      {
        "type": "_slzb-06._tcp.local.",
        "name": "slzb-06*"
      }
    ],
    "dependencies": [
      "file_upload"
    ],
    "after_dependencies": [
      "onboarding",
      "usb",
      "zeroconf"
    ],
    "iot_class": "local_polling",
    "loggers": [
      "aiosqlite",
      "bellows",
      "crccheck",
      "pure_pcapy3",
      "zhaquirks",
      "zigpy",
      "zigpy_deconz",
      "zigpy_xbee",
      "zigpy_zigate",
      "zigpy_znp"
    ],
    "is_built_in": true
  },
  "data": {
    "ieee": "**REDACTED**",
    "nwk": 33974,
    "manufacturer": "_TZE200_fwoorn8y",
    "model": "TS0601",
    "name": "_TZE200_fwoorn8y TS0601",
    "quirk_applied": false,
    "quirk_class": "zigpy.device.Device",
    "manufacturer_code": 4417,
    "power_source": "Battery or Unknown",
    "lqi": null,
    "rssi": null,
    "last_seen": "2023-02-24T13:54:54",
    "available": true,
    "device_type": "EndDevice",
    "signature": {
      "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>, manufacturer_code=4417, maximum_buffer_size=66, maximum_incoming_transfer_size=66, server_mask=10752, maximum_outgoing_transfer_size=66, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *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)",
      "endpoints": {
        "1": {
          "profile_id": 260,
          "device_type": "0x0051",
          "in_clusters": [
            "0x0000",
            "0x0004",
            "0x0005",
            "0xef00"
          ],
          "out_clusters": [
            "0x000a",
            "0x0019"
          ]
        }
      }
    },
    "active_coordinator": false,
    "entities": [],
    "neighbors": [],
    "routes": [],
    "endpoint_names": [
      {
        "name": "SMART_PLUG"
      }
    ],
    "user_given_name": "Contact - Washing Machine",
    "device_reg_id": "cd4c0af2eabcda5714cd1d6b74b0b7b2",
    "area_id": "wash_area",
    "cluster_details": {
      "1": {
        "device_type": {
          "name": "SMART_PLUG",
          "id": 81
        },
        "profile_id": 260,
        "in_clusters": {
          "0x0004": {
            "endpoint_attribute": "groups",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0005": {
            "endpoint_attribute": "scenes",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0xef00": {
            "endpoint_attribute": null,
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0000": {
            "endpoint_attribute": "basic",
            "attributes": {
              "0x0004": {
                "attribute_name": "manufacturer",
                "value": "_TZE200_fwoorn8y"
              },
              "0x0005": {
                "attribute_name": "model",
                "value": "TS0601"
              }
            },
            "unsupported_attributes": {}
          }
        },
        "out_clusters": {
          "0x0019": {
            "endpoint_attribute": "ota",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x000a": {
            "endpoint_attribute": "time",
            "attributes": {},
            "unsupported_attributes": {}
          }
        }
      }
    }
  }
}
javicalle commented 1 year ago

@patrickdass93 Your device signature doesn't match at all with the quirk. Please attach the product or vendor link.

Maybe that (quick and untested) quirk could work for you:

ts0601_magnet.py ```python """Tuya contact sensor device.""" import math from typing import Dict from zigpy.profiles import zha from zigpy.quirks import CustomDevice from zigpy.zcl.clusters.general import ( Basic, Groups, Ota, Scenes, Time, ) from zigpy.zcl.clusters.measurement import IlluminanceMeasurement from zigpy.zcl.clusters.security import IasZone from zhaquirks import DoublingPowerConfigurationCluster from zhaquirks.const import ( DEVICE_TYPE, ENDPOINTS, INPUT_CLUSTERS, MODELS_INFO, OUTPUT_CLUSTERS, PROFILE_ID, ZONE_TYPE, ) from zhaquirks.tuya import TuyaLocalCluster from zhaquirks.tuya.mcu import ( DPToAttributeMapping, TuyaAttributesCluster, TuyaMCUCluster, ) class ContactSwitchCluster(TuyaAttributesCluster, IasZone): """Tuya ContactSwitch Sensor.""" _CONSTANT_ATTRIBUTES = {ZONE_TYPE: IasZone.ZoneType.Contact_Switch} def _update_attribute(self, attrid, value): self.debug("_update_attribute '%s': %s", attrid, value) super()._update_attribute(attrid, value) class TuyaPowerConfigurationCluster( TuyaLocalCluster, DoublingPowerConfigurationCluster ): """PowerConfiguration cluster for battery-operated tuya devices reporting percentage.""" class TuyaIlluminanceMeasurement(IlluminanceMeasurement, TuyaLocalCluster): """Tuya local IlluminanceMeasurement cluster.""" class ContactSwitchManufCluster(TuyaMCUCluster): """Tuya Manufacturer Cluster with ContactSwitch Sensor data points.""" dp_to_attribute: Dict[int, DPToAttributeMapping] = { 1: DPToAttributeMapping( ContactSwitchCluster.ep_attribute, "zone_status", ), 2: DPToAttributeMapping( DoublingPowerConfigurationCluster.ep_attribute, "battery_percentage_remaining", # 0x0021 ), 101: DPToAttributeMapping( TuyaIlluminanceMeasurement.ep_attribute, "measured_value", converter=lambda x: 10000 * math.log10(x) + 1, ), } data_point_handlers = { 1: "_dp_2_attr_update", 2: "_dp_2_attr_update", 101: "_dp_2_attr_update", } class TuyaContactSensor_var02(CustomDevice): """Tuya contact sensor device.""" signature = { MODELS_INFO: [ ("_TZE200_fwoorn8y", "TS0601"), ], ENDPOINTS: { 1: { PROFILE_ID: zha.PROFILE_ID, DEVICE_TYPE: zha.DeviceType.SMART_PLUG, INPUT_CLUSTERS: [ Basic.cluster_id, Groups.cluster_id, Scenes.cluster_id, ContactSwitchManufCluster.cluster_id, ], OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id], } }, } replacement = { ENDPOINTS: { 1: { INPUT_CLUSTERS: [ Basic.cluster_id, Groups.cluster_id, Scenes.cluster_id, TuyaPowerConfigurationCluster, ContactSwitchCluster, ContactSwitchManufCluster, TuyaIlluminanceMeasurement, ], OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id], } } } ```
patrickdass93 commented 1 year ago

@javicalle is this what you mean by product link?

javicalle commented 1 year ago

@javicalle is this what you mean by product link?

Yes, that is. The site don't tell anything about device capabilities so no sure if it will report illuminace, battery or anything else. Probably (if the device gets the quirk) that new entities are not populated. If so, it will be better to create a new issue and work from it with your logs.

patrickdass93 commented 1 year ago

It should report contact(open/closed) and battery level.

javicalle commented 1 year ago

Well, it's a matter of see if the device gets the quirk and what DPs is using... Thes the proposed quirk and enable the debud logs if not working.

PS: you can expand the 'ts0601_magnet.py' block imagen

antoweb commented 1 year ago

Hello, after last update HA to 2023.3 this quirks generate error and all Zigbee Integration cannot load. i have to remove from custom_zha_quirks any solution?

github-actions[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 4 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.