Closed ToastySefac closed 1 year ago
Your device need being added in one quirk for working in ZHA and we have getting its working with most tuya dimmers but its little more work getting all in the right place. Look in this issue https://github.com/zigpy/zha-device-handlers/issues/1302 for the progress and if you can helping testing the quirk for getting it working OK and being added in zha as soon is possible then its many user like having it so there devices is working in ZHA.
I believe that you can simple change the DEVICE_TYPE
to make it work:
class TuyaSingleSwitchDimmerPlus(TuyaDimmerSwitch):
"""Tuya touch switch device."""
signature = {
# "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0,
# reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress|RxOnWhenIdle|MainsPowered|FullFunctionDevice: 142>,
# 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=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=True, *is_security_capable=False)",
MODELS_INFO: [
("_TZE200_swaamsoy", "TS0601"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMER_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
TuyaManufCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
TuyaOnOffMCU,
TuyaInWallLevelControl,
# LevelControl.cluster_id,
TuyaLevelControlManufCluster,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
}
}
}
The device also exposes 'normal' OnOff
and LevelControl
clusters. This quirk will ignore the 'normal' clusters and make use of MCU commands.
I've updated the file with your code above and get this error:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 335, in async_setup
result = await component.async_setup_entry(hass, self)
File "/usr/src/homeassistant/homeassistant/components/zha/__init__.py", line 99, in async_setup_entry
setup_quirks(config)
File "/usr/local/lib/python3.9/site-packages/zhaquirks/__init__.py", line 409, in setup
importer.find_module(modname).load_module(modname)
File "<frozen importlib._bootstrap_external>", line 529, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 1029, in load_module
File "<frozen importlib._bootstrap_external>", line 854, in load_module
File "<frozen importlib._bootstrap>", line 274, in _load_module_shim
File "<frozen importlib._bootstrap>", line 711, in _load
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/config/custom_zha_quirks/ts0601_dimmer.py", line 27, in <module>
class TuyaSingleSwitchDimmerPlus(TuyaDimmerSwitch):
File "/config/custom_zha_quirks/ts0601_dimmer.py", line 45, in TuyaSingleSwitchDimmerPlus
Identify.cluster_id,
NameError: name 'Identify' is not defined
Get all the import
from the previous version:
from typing import Optional, Union
from zigpy.profiles import zha
from zigpy.quirks import CustomCluster
import zigpy.types as t
from zigpy.zcl import foundation
from zigpy.zcl.clusters.general import Basic, GreenPowerProxy, Groups, Identify, LevelControl, OnOff, Ota, Scenes, Time
from zigpy.zcl.clusters.lighting import Color
from zhaquirks.const import (
DEVICE_TYPE,
.../....
Thanks. That's getting closer. I have the light turning on and off, but the dimming functionality is missing. It's also introduced color and temperature controls, which this physical device doesn't control (but that doesn't matter much).
2022-04-11 20:20:53 WARNING (MainThread) [zigpy.zcl] Unknown cluster 0xEF00
2022-04-11 20:20:53 WARNING (MainThread) [zigpy.zcl] Unknown cluster 0xEF00
2022-04-11 20:20:55 WARNING (MainThread) [zigpy.zcl] [0x6BCF:1:0xef00] No 'handle_set_data_response' tuya handler found for set_data_response(data=TuyaCommand(status=89, tsn=233, dp=6, data=TuyaData(dp_type=<TuyaDPType.VALUE: 2>, function=0, raw=b'\x00\x00\x00\x00', *payload=0)))
2022-04-11 20:20:59 WARNING (MainThread) [homeassistant.components.google_assistant.trait] Entity light.tze200_swaamsoy_ts0601_e365f4fe_level_light_color_on_off has incorrect color temperature 0
2022-04-11 20:21:01 WARNING (MainThread) [zigpy.zcl] [0x6BCF:1:0xef00] No 'handle_set_data_response' tuya handler found for set_data_response(data=TuyaCommand(status=89, tsn=234, dp=6, data=TuyaData(dp_type=<TuyaDPType.VALUE: 2>, function=0, raw=b'\x00\x00\x00\x00', *payload=0)))
2022-04-11 20:22:01 WARNING (MainThread) [zigpy.zcl] [0x6BCF:1:0xef00] No 'handle_set_data_response' tuya handler found for set_data_response(data=TuyaCommand(status=89, tsn=235, dp=6, data=TuyaData(dp_type=<TuyaDPType.VALUE: 2>, function=0, raw=b'\x00\x00\x00\x00', *payload=0)))
2022-04-11 20:23:01 WARNING (MainThread) [zigpy.zcl] [0x6BCF:1:0xef00] No 'handle_set_data_response' tuya handler found for set_data_response(data=TuyaCommand(status=89, tsn=236, dp=6, data=TuyaData(dp_type=<TuyaDPType.VALUE: 2>, function=0, raw=b'\x00\x00\x00\x00', *payload=0)))
2022-04-11 20:23:42 WARNING (MainThread) [homeassistant.components.google_assistant.trait] Entity light.tze200_swaamsoy_ts0601_e365f4fe_level_light_color_on_off has incorrect color temperature 0
2022-04-11 20:23:47 WARNING (MainThread) [homeassistant.components.google_assistant.trait] Entity light.tze200_swaamsoy_ts0601_e365f4fe_level_light_color_on_off has incorrect color temperature 0
2022-04-11 20:23:47 WARNING (MainThread) [homeassistant.components.google_assistant.trait] Entity light.tze200_swaamsoy_ts0601_e365f4fe_level_light_color_on_off has incorrect color temperature 0
2022-04-11 20:23:48 WARNING (MainThread) [homeassistant.components.google_assistant.trait] Entity light.tze200_swaamsoy_ts0601_e365f4fe_level_light_color_on_off has incorrect color temperature 0
2022-04-11 20:23:48 WARNING (MainThread) [homeassistant.components.google_assistant.trait] Entity light.tze200_swaamsoy_ts0601_e365f4fe_level_light_color_on_off has incorrect color temperature 0
2022-04-11 20:24:01 WARNING (MainThread) [zigpy.zcl] [0x6BCF:1:0xef00] No 'handle_set_data_response' tuya handler found for set_data_response(data=TuyaCommand(status=89, tsn=242, dp=6, data=TuyaData(dp_type=<TuyaDPType.VALUE: 2>, function=0, raw=b'\x00\x00\x00\x00', *payload=0)))
2022-04-11 20:24:24 WARNING (MainThread) [homeassistant.components.google_assistant.trait] Entity light.tze200_swaamsoy_ts0601_e365f4fe_level_light_color_on_off has incorrect color temperature 0
2022-04-11 20:24:28 WARNING (MainThread) [homeassistant.components.google_assistant.trait] Entity light.tze200_swaamsoy_ts0601_e365f4fe_level_light_color_on_off has incorrect color temperature 0
2022-04-11 20:24:31 WARNING (MainThread) [homeassistant.components.google_assistant.trait] Entity light.tze200_swaamsoy_ts0601_e365f4fe_level_light_color_on_off has incorrect color temperature 0
2022-04-11 20:24:33 WARNING (MainThread) [homeassistant.components.google_assistant.trait] Entity light.tze200_swaamsoy_ts0601_e365f4fe_level_light_color_on_off has incorrect color temperature 0
2022-04-11 20:24:33 WARNING (MainThread) [homeassistant.components.google_assistant.trait] Entity light.tze200_swaamsoy_ts0601_e365f4fe_level_light_color_on_off has incorrect color temperature 0
2022-04-11 20:24:38 WARNING (MainThread) [homeassistant.components.google_assistant.trait] Entity light.tze200_swaamsoy_ts0601_e365f4fe_level_light_color_on_off has incorrect color temperature 0
2022-04-11 20:24:40 WARNING (MainThread) [homeassistant.components.google_assistant.trait] Entity light.tze200_swaamsoy_ts0601_e365f4fe_level_light_color_on_off has incorrect color temperature 0
It seems that the quirk does not fit the device. Please, without turning HA off, reboot the switch and attach any traces it generates.
It's also introduced color and temperature controls, which this physical device doesn't control (but that doesn't matter much).
If not useful, the Color
cluster can be removed from the replacement part.
According to https://github.com/Koenkk/zigbee-herdsman-converters/pull/3004 most of the DPs match with our definition, so is not clear why didn't work.
In addition to the traces of the device restart (for example unplugging it and turning it back on), traces of when the physical device is operated would be very useful. Look at the logger config to get all the relevant traces:
It seems that the quirk does not fit the device. Please, without turning HA off, reboot the switch and attach any traces it generates.
I restarted the device by cutting the power at the mains power / fuse box. It has now restarted and is working perfectly. I will keep testing it over the next few days, but thank you for your help @javicalle . I really appreciate it!
If not useful, the
Color
cluster can be removed from the replacement part.
This worked as well.
For anyone else with this device, here is the final ts0601_dimmer.py contents:
"""Tuya based touch switch."""
from typing import Optional, Union
from zigpy.profiles import zha
from zigpy.quirks import CustomCluster
import zigpy.types as t
from zigpy.zcl import foundation
from zigpy.zcl.clusters.general import Basic, GreenPowerProxy, Groups, Identify, LevelControl, OnOff, Ota, Scenes, Time
from zigpy.zcl.clusters.lighting import Color
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.tuya import (
TuyaDimmerSwitch,
TuyaLevelControl,
TuyaManufacturerClusterOnOff,
TuyaManufacturerLevelControl,
TuyaManufCluster,
TuyaOnOff,
)
from zhaquirks.tuya.mcu import (
TuyaInWallLevelControl,
TuyaLevelControlManufCluster,
TuyaOnOff as TuyaOnOffMCU,
)
class TuyaSingleSwitchDimmerPlus(TuyaDimmerSwitch):
"""Tuya touch switch device."""
signature = {
# "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0,
# reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress|RxOnWhenIdle|MainsPowered|FullFunctionDevice: 142>,
# 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=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=True, *is_security_capable=False)",
MODELS_INFO: [
("_TZE200_swaamsoy", "TS0601"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMER_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
TuyaManufCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
TuyaOnOffMCU,
TuyaInWallLevelControl,
TuyaLevelControlManufCluster,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
}
}
}
I've tested this for a couple of days. Other than a warning in the logs, it is working perfectly, both through HA and physically. Are the warnings anything to worry about?
Logger: zigpy.zcl
Source: /usr/local/lib/python3.9/site-packages/zhaquirks/tuya/__init__.py:1388
First occurred: 4:18:15 PM (251 occurrences)
Last logged: 8:27:50 PM
[0x6BCF:1:0xef00] No 'handle_set_data_response' tuya handler found for set_data_response(data=TuyaCommand(status=9, tsn=54, dp=6, data=TuyaData(dp_type=<TuyaDPType.VALUE: 2>, function=0, raw=b'\x00\x00\x00\x00', *payload=0)))
[0x6BCF:1:0xef00] No 'handle_set_data_response' tuya handler found for set_data_response(data=TuyaCommand(status=9, tsn=55, dp=6, data=TuyaData(dp_type=<TuyaDPType.VALUE: 2>, function=0, raw=b'\x00\x00\x00\x00', *payload=0)))
[0x6BCF:1:0xef00] No 'handle_set_data_response' tuya handler found for set_data_response(data=TuyaCommand(status=9, tsn=56, dp=6, data=TuyaData(dp_type=<TuyaDPType.VALUE: 2>, function=0, raw=b'\x00\x00\x00\x00', *payload=0)))
[0x6BCF:1:0xef00] No 'handle_set_data_response' tuya handler found for set_data_response(data=TuyaCommand(status=9, tsn=57, dp=6, data=TuyaData(dp_type=<TuyaDPType.VALUE: 2>, function=0, raw=b'\x00\x00\x00\x00', *payload=0)))
[0x6BCF:1:0xef00] No 'handle_set_data_response' tuya handler found for set_data_response(data=TuyaCommand(status=9, tsn=80, dp=6, data=TuyaData(dp_type=<TuyaDPType.VALUE: 2>, function=0, raw=b'\x00\x00\x00\x00', *payload=0)))
The warnings are only informative that there is a config of the device (datapoint 6) that the implementation is not considering. It seems that device reports from datapoints 1, 2, 3 and 6.
DP 1 and 2 are the on_off
and current_level
and seems to be working OK.
DP 3 is configured by default to the dimming minimum_level
value. Not sure if is correct.
DP 6 is not configured (and ZHA complains about it). For the value it has, this could be the minimum_level
but I have not found conclusive information.
But it is also, according to the vendor device have a 'backlight status' function, other tuya devices have it at datapoint 15 but yours don't report at this DP, so no sure how can be configured (maybe one of the already known DP?).
Regards.
Any ideas as to what might be happening with this device? When I select a brightness, it jumps around wildly. I can't see any pattern to it.
I don't think it's a faulty device. I believe it's something happening within my Home Assitant/ConbeeII/ZHA setup because:
I can't say that would be the same behaviour, but some devices have a 'transition time' when you change the brightness. My guess would be that the behaviour is:
Debug logs would give more information of what is happening here. Also, is it just an UI issue or is the device behavior also erratic?
I think your guess might be right.
In instances where I make a large change (example: from 20% to 80%) and when it reverts back to the original value in the UI, the device's physical brightness does not change. So, it appears the UI updates itself to show the true current state reported by the device.
I can force it to get to the desired brightness if I tap/click the brightness level twice, it jumps a bit, but seems to retain the second one.
The device's behaviour is not erratic, just the UI.
Is your feature request related to a problem? Please describe. I have a Mercator Ikuu Light Dimmer (SSWD01) which identifies as a Tuya TS0601 Dimmer (_TZE200_swaamsoy). It interviews ok in ZHA, but once done, HA only gives a on/off option which doesn’t do anything.
Describe the solution you'd like I'd like to have it identify correctly and have standard options, such an on/off, dimmer brightness up/down, etc
Device signature - this can be acquired by removing the device from ZHA and pairing it again from the add devices screen. Be sure to add the entire content of the log panel after pairing the device to a code block below this line. { "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress|RxOnWhenIdle|MainsPowered|FullFunctionDevice: 142>, 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=False, is_full_function_device=True, is_mains_powered=True, is_receiver_on_when_idle=True, is_router=True, *is_security_capable=False)", "endpoints": { "1": { "profile_id": 260, "device_type": "0x0104", "in_clusters": [ "0x0000", "0x0003", "0x0004", "0x0005", "0x0006", "0x0008", "0x0300", "0xef00" ], "out_clusters": [ "0x000a", "0x0019" ] } }, "manufacturer": "_TZE200_swaamsoy", "model": "TS0601", "class": "zigpy.device.Device" }
Additional context
The model is in the Tuya "ts0601_dimmer.py" quirk file already. I've added the quirk to my custom folder and linked in configuration.yaml, but it doesn't seem to be helping.
Appreciate any help you could give. Thanks