-
Notifications
You must be signed in to change notification settings - Fork 758
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] Lonsonho 2CH Zigbee Dimmer Module (_TZ3210_wdexaypg) #1840
Comments
It would be nice if you can include a link to the device manufacturer or to the site vendor to be able to identify the device. A little more info about what is working and what no, or what do you expect from the device is necessary to try to 'quirk' it. It's just the on/off not working? Doesn't the dimming function? Or is another your issue? |
Hi @javicalle, I've updated the main issue to include a link to the product itself. As for the device itself, it works through HA without any problems with typically dimming, on/off functionality, but when using it at the wall switch (which is a rocker), I cannot turn it on and end up resetting the device. I'm hoping that there is the ability to update this, similar to https://www.zigbee2mqtt.io/devices/TS110E_2gang.html#lonsonho-ts110e_2gang. |
Ok, the it seems that you need just to configure the 2 steps: configure local quirk and configure your device. ts110e.py"""Tuya Dimmer TS110E."""
from typing import Any, Optional, Union
from zigpy.profiles import zha
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 zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.tuya import (
NoManufacturerCluster,
TuyaDimmerSwitch,
TuyaZBExternalSwitchTypeCluster,
)
TUYA_LEVEL_ATTRIBUTE = 0xF000
TUYA_BULB_TYPE_ATTRIBUTE = 0xFC02
TUYA_MIN_LEVEL_ATTRIBUTE = 0xFC03
TUYA_MAX_LEVEL_ATTRIBUTE = 0xFC04
TUYA_CUSTOM_LEVEL_COMMAND = 0x00F0
class TuyaLevelPayload(t.Struct):
"""Tuya Level payload."""
level: t.uint16_t
transtime: t.uint16_t
class TuyaBulbType(t.enum8):
"""Tuya bulb type."""
LED = 0x00
INCANDESCENT = 0x01
HALOGEN = 0x02
class F000LevelControlCluster(NoManufacturerCluster, LevelControl):
"""LevelControlCluster that reports to attrid 0xF000."""
server_commands = LevelControl.server_commands.copy()
server_commands[TUYA_CUSTOM_LEVEL_COMMAND] = foundation.ZCLCommandDef(
"moveToLevelTuya",
(TuyaLevelPayload,),
is_manufacturer_specific=False,
)
attributes = LevelControl.attributes.copy()
attributes.update(
{
# 0xF000
TUYA_LEVEL_ATTRIBUTE: ("manufacturer_current_level", t.uint16_t),
# 0xFC02
TUYA_BULB_TYPE_ATTRIBUTE: ("bulb_type", TuyaBulbType),
# 0xFC03
TUYA_MIN_LEVEL_ATTRIBUTE: ("manufacturer_min_level", t.uint16_t),
# 0xFC04
TUYA_MAX_LEVEL_ATTRIBUTE: ("manufacturer_max_level", t.uint16_t),
}
)
# 0xF000 reported values are 10-1000, convert to 0-254
def _update_attribute(self, attrid, value):
if attrid == TUYA_LEVEL_ATTRIBUTE:
self.debug(
"Getting brightness %s",
value,
)
value = (value + 4 - 10) * 254 // (1000 - 10)
attrid = 0x0000
super()._update_attribute(attrid, value)
async def command(
self,
command_id: Union[foundation.GeneralCommand, int, t.uint8_t],
*args,
manufacturer: Optional[Union[int, t.uint16_t]] = None,
expect_reply: bool = True,
tsn: Optional[Union[int, t.uint8_t]] = None,
**kwargs: Any,
):
"""Override the default Cluster command."""
self.debug(
"Sending Cluster Command. Cluster Command is %x, Arguments are %s",
command_id,
args,
)
# move_to_level, move, move_to_level_with_on_off
if command_id in (0x0000, 0x0001, 0x0004):
# getting the level value
if kwargs and "level" in kwargs:
level = kwargs["level"]
elif args:
level = args[0]
else:
level = 0
# convert dim values to 10-1000
brightness = level * (1000 - 10) // 254 + 10
self.debug(
"Setting brightness to %s",
brightness,
)
return await super().command(
TUYA_CUSTOM_LEVEL_COMMAND,
TuyaLevelPayload(level=brightness, transtime=0),
manufacturer=manufacturer,
expect_reply=expect_reply,
tsn=tsn,
)
return super().command(command_id, *args, manufacturer, expect_reply, tsn)
class DimmerSwitchWithNeutral1Gang(TuyaDimmerSwitch):
"""Tuya Dimmer Switch Module With Neutral 1 Gang."""
signature = {
MODELS_INFO: [("_TZ3210_ngqk6jia", "TS110E")],
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=257
# input_clusters=[0, 4, 5, 6, 8, 57345]
# output_clusters=[10, 25]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
TuyaZBExternalSwitchTypeCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
242: {
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
# input_clusters=[]
# output_clusters=[33]
PROFILE_ID: 41440,
DEVICE_TYPE: 97,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
F000LevelControlCluster,
TuyaZBExternalSwitchTypeCluster,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
242: {
PROFILE_ID: 41440,
DEVICE_TYPE: 97,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
class DimmerSwitchWithNeutral2Gang(TuyaDimmerSwitch):
"""Tuya Dimmer Switch Module With Neutral 2 Gang."""
signature = {
MODELS_INFO: [("_TZ3210_wdexaypg", "TS110E")],
ENDPOINTS: {
# 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=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=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=True, *is_security_capable=False
# )
1: {
# input_clusters=["0x0000","0x0003","0x0004","0x0005","0x0006","0x0008","0xef00"]
# output_clusters=["0x000a","0x0019"]
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
TuyaZBExternalSwitchTypeCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
2: {
# input_clusters=["0x0003","0x0004","0x0005","0x0006","0x0008","0xef00"]
# output_clusters=[]
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
TuyaZBExternalSwitchTypeCluster.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
242: {
# input_clusters=[]
# output_clusters=["0x0021"]
PROFILE_ID: 41440,
DEVICE_TYPE: 97,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
F000LevelControlCluster,
TuyaZBExternalSwitchTypeCluster,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
F000LevelControlCluster,
TuyaZBExternalSwitchTypeCluster,
],
OUTPUT_CLUSTERS: [],
},
242: {
PROFILE_ID: 41440,
DEVICE_TYPE: 97,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
} There is a guide about enabling custom quirks: Create a new Once the device has loaded the quirk, you could change the |
Thanks for your help with this @javicalle, I've loaded up a custom quirk and according to the diagnostics it is loading correctly, however I don't seem to have the
|
On further inspection as I've had a few goes now, it looks like the setting isn't coming through, the device diagnostics come back as:
|
Hi, your device is NOT loading the quirk. Check the HA startup log for any error related to the quirk file. |
Ahh, I've found more information:
Will investigate this a little more. |
My bad, I have mistaken the cluster 🤦🏻♂️ |
The problem is with the If you replace the cluster with the |
That seems that will require some extra work: |
Aww, that is a shame! My WAF is going through the floor 😉 Thanks for all your help with this. Looks like I will have to play a little more. |
Look at the |
The |
I'm pretty sure that this is the attribute but I don't know why you can't update its value. References: |
I can't find any problem in the code. Can you enable the debug log and attach them? Please attach the logs from changing the value in HA and also the logs from interacting with the phisycal device (switching, dimming, etc) |
Hopefully I've got everything in this log, there is a fair old amount of information coming through! Debug Logs both through HA and Physical switch
Physical switching logs
it looks like even after setting the bulb_type, moving the physical switch puts it in a reconnect state. (From my understanding) |
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. |
Is your feature request related to a problem? Please describe.
Support new device as listed here - https://www.aliexpress.com/item/1005003012298844.html?spm=a2g0o.order_list.0.0.47e11802nmAbGl
Describe the solution you'd like
Support for this device, including the ability to change how it toggles on/off at the switch.
Device signature
Diagnostic information
Additional logs
Thanks in advance, I had a go at this but butchered it.
The text was updated successfully, but these errors were encountered: