Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Device Support Request] TS0601 _TZE204_vawy74yh Smoke detector #3421

Open
Keffu3636 opened this issue Oct 12, 2024 · 7 comments
Open

[Device Support Request] TS0601 _TZE204_vawy74yh Smoke detector #3421

Keffu3636 opened this issue Oct 12, 2024 · 7 comments

Comments

@Keffu3636
Copy link

Problem description

Please provide support for the device TS0601 _TZE204_vawy74yh

Solution description

Looks like it is working with Z2M - https://www.zigbee2mqtt.io/devices/ZSS-HM-SSD01.html

Screenshots/Video

Screenshots/Video

[Paste/upload your media here]

Device signature

Device signature
[Paste the device signature here]

Diagnostic information

Diagnostic information
[Paste the diagnostic information here]

Logs

Logs
[Paste the logs here]

Custom quirk

Custom quirk
[Paste your custom quirk here]

Additional information

No response

@Keffu3636
Copy link
Author

Managed to patch something together and I'm getting attribute values now . Anyone with deeper knowledge please comment if I'm on the right track :) Thanks!

Sources used:
https://github.com/Koenkk/zigbee-herdsman-converters/blob/b405404c2d8db02d94feb3a114c9baf2bd2fcf4e/src/devices/moes.ts#L400
and most of the code I took from here:
#3249 (comment)
Many thanks to the authors.

import zigpy.types as t
from typing import Any, Type
from zigpy.profiles import zha 
from zigpy.quirks import CustomDevice, CustomCluster
from zigpy.zcl.clusters.general import (
    Basic,
    Groups,
    Identify,
    OnOff,
    Ota,
    PowerConfiguration,
    Scenes,
    Time,
)
from zigpy.zcl.clusters.security import IasZone
from zhaquirks.const import (
    DEVICE_TYPE,
    ENDPOINTS,
    INPUT_CLUSTERS,
    MODELS_INFO,
    OUTPUT_CLUSTERS,
    PROFILE_ID,
)
from zhaquirks.tuya.mcu import TuyaMCUCluster
from zhaquirks.tuya import (
    TuyaManufCluster,
    DPToAttributeMapping,
    EnchantedDevice,
    TuyaNoBindPowerConfigurationCluster,
)

ZONE_TYPE = 0x0001

class TuyaSmokeSensorCluster(TuyaMCUCluster):
    """Tuya manufacturer cluster for smoke sensor."""

    # Copy the attributes from the base class
    attributes = TuyaMCUCluster.attributes.copy()

    # Update the attributes with the custom ones for this smoke sensor
    attributes.update(
        {
            0xEF01: ("smoke", t.uint8_t, True),  # Smoke status
            0xEF09: ("self_test", t.uint8_t, True),  # Self-test result (Enum)
            0xEF0E: ("battery_state", t.uint8_t, True),  # Battery state (raw value)
            0xEF0F: ("battery", t.uint8_t, True),  # Battery level (raw value)
            0xEF10: ("silence", t.Bool, True),  # Silence alarm (On/Off)
        }
    )

    dp_to_attribute = {
        1: DPToAttributeMapping(
            TuyaMCUCluster.ep_attribute,
            "smoke",
        ),
        9: DPToAttributeMapping(
            TuyaMCUCluster.ep_attribute,
            "self_test",
        ),
        14: DPToAttributeMapping(
            TuyaMCUCluster.ep_attribute,
            "battery_state",
        ),
        15: DPToAttributeMapping(
            TuyaMCUCluster.ep_attribute,
            "battery",
        ),
        16: DPToAttributeMapping(
            TuyaMCUCluster.ep_attribute,
            "silence",
        ),
    }

    data_point_handlers = {
        1: "_dp_2_attr_update",
        9: "_dp_2_attr_update",
        14: "_dp_2_attr_update",
        15: "_dp_2_attr_update",
        16: "_dp_2_attr_update",
    }

class TuyaIasZone(CustomCluster, IasZone):
    """IAS Zone."""

    _CONSTANT_ATTRIBUTES = {ZONE_TYPE: IasZone.ZoneType.Fire_Sensor}

class MoesSmokeSensor(EnchantedDevice):
    """ZHA quirk for Moes ZSS-HM-SSD01 smoke sensor."""

    signature = {
        MODELS_INFO: [("_TZE204_vawy74yh", "TS0601")],
             ENDPOINTS: {
                 1: {
                    PROFILE_ID: zha.PROFILE_ID,
                    DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
                    INPUT_CLUSTERS: [
                        Groups.cluster_id,
                        Scenes.cluster_id,
                        TuyaMCUCluster.cluster_id,
                        Basic.cluster_id,
            ],
            OUTPUT_CLUSTERS: [
                Time.cluster_id,
                Ota.cluster_id,
            ],
        },
    },
}

    replacement = {
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
                INPUT_CLUSTERS: [
                    Groups.cluster_id,
                    Basic.cluster_id,
                    Scenes.cluster_id,
                    TuyaNoBindPowerConfigurationCluster,
                    TuyaSmokeSensorCluster,
            ],
                OUTPUT_CLUSTERS: [
                    Time.cluster_id,
                    Ota.cluster_id,
                ],
            },
        },
    }

image

Using ZHA-toolkit for entities, let's see how it is going to work.

@pulsar895
Copy link

Hello,

I've just made a pull request for the smoke detector to be seen: #3447

I hope that others a little more at ease than me will know how to add the battery status...

@Keffu3636
Copy link
Author

Sorry, but what does it mean exactly?

@pulsar895
Copy link

The modification I've proposed allows the device to indicate whether it detects smoke or not.
Adding battery status is beyond my capabilities. I hope someone will be able to translate from z2m to zha so we can get all the elements.

@Keffu3636
Copy link
Author

Any idea why I get enum8.undefined_0x01 as value when quering smoke? Battery is fine.

image
image

@Keffu3636
Copy link
Author

After HA restart it start to populate values correctly. It works, but I don't have much confidence in it :)

@Keffu3636
Copy link
Author

.. and when I triggered an actual alarm on a device itself I got num8.undefined_0x00 reading value for smoke attribute. Any ideas for quirk?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants