-
Notifications
You must be signed in to change notification settings - Fork 727
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] Tuya TS0001 relay #1118
Comments
I have making one PR for adding back light for some switches and also adding changing some switches sending light commands or clicks that all is on the on/off cluster but is not being merged. I have funding that some tuya devices is using switch mode on cluster 0xE001 zigpy/zigpy#823 (comment) but your devices is not having that. So it can it have implanting it on the On/Off cluster but we dont knowing what attribute tuya is using or they is using it on the 0xE000 cluster but have hidden the cluster and must being added in the quirk for working or they have doing it in one other not known way. Then you is having one tuya ZBGW and can controlling the device it wold being great if you can sniffing it so we can see how they is doing it if you is having some device for doing sniffing (TI CC-2531 or one EM35X / EFR21MG with NCP firmware). |
No, mine device has 0xE001 cluster. It looks like 0xD030 attribute will make a trick, I'll check it. |
I've posted wrong ZigBee information after applying my quick and dirty quirk. Here is raw information:
|
OK i was missing that then you was not having it in the replace in the quirk so that is great !! Try implanting it like its done with the power state and i think it will working OK. My intention is getting it in tuya INI and then adding it to TS011F and TS0121 and also the TS001X quirk but i dont have any one for testing it and the devs have not merger it. This is interesting !!! And i think its needed on new quirk TS000X for your device :-))) |
Then you is making the new 0xE001 you can doing some extra attributes like 0x03, 0x04 and so on and looking if you is getting response from the device and if the function is changed. |
I've tried to make it in this way
but received an error:
where I have to take attributes? |
I looking how it was made in the first implementation before i was moving it to tuya INIT. |
from the original implementation in the TS1021:
that is not doing one new cluster but is updating the on/off cluster.
I think the latest is nor like you like to have and changing the cluster_id = Good naming you can do later the most importent is you is getting the function working. |
I can confirm - it works:
|
GREAT !!Wot is the Then you have making it working and merger the PR i can moving it to the tuya INI and only using linking in your quirk but you can doing it from the beginning if you like but i ts little trickier edeting the INIT then it must being done in the HA container. Great work done !! |
Have no idea. I just respect existing code and use the rule "don't touch anything" |
BTW, in both ts011f_plug.py and ts0121_plug.py have wrong cluster numbers and wrong device_type in "# <SimpleDescriptor" comments. device_type must be 266. In input_clusters number 9 is needless. |
Its some quirks that is no fitting at all (i think the TS113F is one of them) and that is very bad then trying adding other devices with little different cluster settings. Look little how other is made and copy it and changing the information its the best. The profiles / device type you is can finding here: https://github.com/zigpy/zigpy/blob/dev/zigpy/profiles/zha.py You must finding one good name for the "new made cluster" that all other devices can using in the future !!! |
I was thinking putting somthing like this in tuya INIT:
But i dont knowing if its working OK with initiating the cluster. @jacekk015 you is knowing how to do it right. I like adding one new tuya cluster to INIT that can sending and receiving this attributes and its looks working OK in local quirks. Thanks in advance !!! |
There already is SwitchMode enum in INIT. I think it's better to name it ExternalSwitchType:
|
And maybe it's better to move constant 0xE001 to constants section, right before TUYA_CLUSTER_ID = 0xEF00 |
I think its very good not mixing the variables and getting strange collisions with the naming !! I trying making all "noraml" tuya Zigbee with names so easy can see its tuya and Zigbee and not the DP devices things belonging. I was thinking putting the 0xE001 early in the INIT after this: zha-device-handlers/zhaquirks/tuya/__init__.py Lines 19 to 23 in 242d5f3
|
In line 23:
and in the new cluster:
Looks little long but i think its better doing as the original is being done. |
I think, anyway, it should be TYPE not MODE |
More users have the same problem like you but 3 times more #1145 :-) |
I have making some adding in INIT and moved both "PITA" clusters there:
And adding definitions for both:
The INIT is one updated version with renamed cluster so need also updating the ts011f_plug.py and ts0121_plug.py in the container or ZHA is not loading. And one new The TS011F Its loading in my test and production system and i can controlling the power restore state and back light (but not back light shown on the device like yours) but is not having switch mode implanted but other user have TS011F devices that having that. Can you testing if i have making your device OK and its working and also taking one fast look on the 3 gang if its looks OK then i can testing it on the user. Also more feedback on the copy and pace code is very welcome !! |
Unfortunately, I'm not able to check it. There is a problem with import. Statement:
causes error since in original zha-device-handlers/zhaquirks/tuya/__init__.py not defines such classes. I've tried to change import to
but the error is "ImportError: attempted relative import with no known parent package" in such case. |
In witch quirk or is it in the INIT that is giving the error ? |
I've tried it in custom_quirks. Ok, I'll try to work with HA container |
TS011F and TS0121 must being patched for the new named (in the new INIT) of the power state cluster in the container. After that you can have copy of this in the custom folder (I was first deleting them in the container and its working 2). |
Yes, my TS0001 works well with this code. Only one issue. Original device type is zha.DeviceType.ON_OFF_LIGHT. If we keep it in replacement section, there are two entities: I've resolved it by changing it in replacement to zha.DeviceType.ON_OFF_PLUG_IN_UNIT:
With this change, there is only one entity. |
@MattWestb, is it possible to expose these attributes as entities with config category in ZHA? |
I putting it in the replace and then testing the 3 gang on the new user :-)) ZHA is showing some attributes like battery voltage, type and number of batteries in the battery card (ZHA have starting saving all attributes in the device DB so the system is having them). |
|
I think you can doing custom quirks that is exposed as switched and can sending attribute thru bus and getting its status from the bus like is made in tuya TRVs. Or you is implanting one nice device card for ZHA :-)) |
Merged :-)) |
You got two entities but one is disabled. When you play with settings that affect the entity domain (light vs switch in this case), HA creates new entities for you and the old ones are left disabled. You can delete them and will not be created again unless you change the zha.Devicetype again. In fact, zha.DeviceType.ON_OFF_LIGHT is the right one becase it was the original device type and what HA is using in current installations and because the device is designed to handle lights.
|
There is a way to set the externalswitchtype w/o editing HA code. From "manage Zigbee device", clusters tab, select "TuyaZBExternalSwitchTypeCluster (Endpoint id: 1, Id: 0xe001, Type: in)", "Attributes" tab, "external_switch_type (id: 0xd030)". Now, clicking "Read attribute" should give "ExternalSwitchType.Momentary". A drop down for noobs like me would be perfect, but at least it's doable :) |
Is your feature request related to a problem? Please describe.
Just received Tuya TS0001 relay,
https://www.aliexpress.com/item/1005002482791975.html
It hasn't quirk, so works just basically.
In Tuya Smart application, it has power outage behavior and external switch type settings. The first setting is already implemented for plugs TS011F and TS0121, so it could implemented without problems. Switch type setting haven't been implemented yet.
Here is a screenshot from Tuya Smart application:
Describe the solution you'd like
The external switch type attribute could be added.
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.
Additional context
@MattWestb may be you know attribute id for external switch type?
The text was updated successfully, but these errors were encountered: