I have a MOES Tuya lightswitch that is detected as ‘generic device’ in ZHA. Supposedly, it should have backlight, but it seems it can only be enabled trough the app. I can see that ZHA supports other similar devices, so I’m trying to simply find and set the right attribute.
(I’m really new to all HA stuff, maybe 10-15hrs in in total, but not new to programming, tinkering with phone firmwares etc, so I kinda have a vague idea of what I’m doing)
From what I understand this device is not supported in ZHA directly, but as a generic lightswitch it works fine, all buttons trigger both ways (to and from the dashboard) and I was able to do a few automations between a couple of these switches.
To find out what the backlight might be I had a look at ZHA device handles source code and I can see that it’s supposed to be cluster 6 (on_off) attribute 0x8001.
class TuyaZBOnOffAttributeCluster(TuyaEnchantableCluster, OnOff):
"""Tuya Zigbee On Off cluster with extra attributes."""
attributes = OnOff.attributes.copy()
attributes.update({0x8000: ("child_lock", t.Bool)})
attributes.update({0x8001: ("backlight_mode", SwitchBackLight)})
attributes.update({0x8002: ("power_on_state", PowerOnState)})
attributes.update({0x8004: ("switch_mode", SwitchMode)})
https://github.com/zigpy/zha-device-handlers/blob/4ea1668256396cf2254cd32a40bf785e698de6bd/zhaquirks/tuya/__init__.py#L966
I did a scan on the device with the toolkit and I can see the general structure is quite as I’d expect with 0x8001 and 0x8002 attributes where they are supposed to be as far as I understand.
However, when I read 0x8001 attribute it’s already set to 1 (on every button of every switch), which is somewhat suspicious. Also when I write pretty much anything into that attribute nothing happens.
I did confirm with the read that the write was successful, and writing directly into on_off attribute triggered the switch so writing seems to work fine, just the value itself doesn’t seem to trigger anything.
Is there a trick to writing those values, or should I be doing something extra after pushing the value in, idk, some sort of ‘commit’?
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=4098, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, 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": "0x0104",
"device_type": "0x0100",
"input_clusters": [
"0x0000",
"0x0003",
"0x0004",
"0x0005",
"0x0006",
"0xe000",
"0xe001"
],
"output_clusters": [
"0x000a",
"0x0019"
]
},
"2": {
"profile_id": "0x0104",
"device_type": "0x0100",
"input_clusters": [
"0x0003",
"0x0004",
"0x0005",
"0x0006",
"0xe000",
"0xe001"
],
"output_clusters": []
},
"3": {
"profile_id": "0x0104",
"device_type": "0x0100",
"input_clusters": [
"0x0003",
"0x0004",
"0x0005",
"0x0006",
"0xe000",
"0xe001"
],
"output_clusters": []
},
"4": {
"profile_id": "0x0104",
"device_type": "0x0100",
"input_clusters": [
"0x0003",
"0x0004",
"0x0005",
"0x0006",
"0xe000",
"0xe001"
],
"output_clusters": []
},
"242": {
"profile_id": "0xa1e0",
"device_type": "0x0061",
"input_clusters": [],
"output_clusters": [
"0x0021"
]
}
},
"manufacturer": "_TZ3000_mrduubod",
"model": "TS0014",
"class": "zigpy.device.Device"
}
Snippet from the full scan:
"0x8001": {
"attribute_id": "0x8001",
"attribute_name": "32769",
"value_type": [
"0x30",
"enum8",
"Discrete"
],
"access": "REPORT|WRITE|READ",
"access_acl": 7,
"attribute_value": 1
},
"0x8002": {
"attribute_id": "0x8002",
"attribute_name": "32770",
"value_type": [
"0x30",
"enum8",
"Discrete"
],
"access": "REPORT|WRITE|READ",
"access_acl": 7,
"attribute_value": 0