-
Notifications
You must be signed in to change notification settings - Fork 749
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
[Technical Support] General discussion regarding Tuya TRVs - for people implementing the quirks #1183
Comments
https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/tuya/__init__.py#L559 Your way does the same, but in shorter path. |
PS: this is setting the ZHA cards min and max setpoint temperature and not in the device (if the device is supporting it perhaps), But setting it OK is making the device is not getting out of range data and getting problem and the GUI is looking nicer. |
@jacekk015 Basically you code does exactly the same, only around ;] @MattWestb yes, exactly. Saswell device does not have any override of the default min/max setpoints. |
The same with my Siterwell i think only "Moes" types have it in the TRV as attributes. |
@jacekk015 @MattWestb I just sniffed the scheduling with ZBOSS for the Saswell but I wonder if there is any point in implementing it since ZHA/HA does not seem to have any usable interface for it, does it? How the scheduling is implemented UI-wise for Moes/Beca? |
Beca received Schedule on the attributes level. You can see that post. |
You mean from "Manage Clusters"? Searched the Beca thread for some screenshots but couldnt find any from the scheduler |
yes |
How do I enable Preset dropdown in thermostat like this? I have added this to my quirk:
Also I have implemented all the mapping and events but still no Preset dropdown. What am I missing? |
Moes is doing it in ZHA MaxSmart ans Seiter is having doing the same but its not merged in ZHA. |
This is crazy system design.. you have access to zigpy classes only but ZHA creates entities... and they wonder why people prefer Z2M over native ZHA... |
I think the best way is Zigpy is only having one quirk that is tunneling all DP commands to ZHA or one other integration and all magic is being done there for not having being squeezed true Zigbee commands and having access to all HA good things. |
One with presets for siterwell TRVs. |
@MattWestb this way there always will be problems. I think that it should be possible to control what entities with what names and properties are created by ZHA in HA from the quirk level. This would be universal. |
I agree with you but as long the maintainer dont agree its nt possible getting it implanted. I was suggesting adding "extra attributes" with ZHA-quirk as manufacture for adding the extra function but no luck. |
Quirks are for translating Zigbee clusters that are not spec compliant to compliant clusters. Think of them like translators. They have nothing to do with HA itself and they can technically benefit any software that leverages Zigpy. There are other automation systems that use Zigpy already. The only deviation from this is device action triggers and they may be moved in the future. |
David is it one wrong thinking making one quirk that is tunneling all tuya DP commands and is doing the device handling one level over Zigpy (perhaps ZHA or some other extension) then its very complex devices (not all but most). Can you also making one comment how the best way getting all devices that is having getting new or updated support in updating request but cant being merged (it was 14 devices but 3 more is added last days) ? All tuya TRVs is being looked on only the original Moes is not completely rewritten but is also in the pipe if all is going well. The original quirk for my siterwell TRV is loosing half of its function and some of the implanted is broken. All is fixed in the updated quirk plus little extra function is putted in with good coding in the quirk. If we is not making somthing we can deleting all tuya TRVs then its so bad supported in ZHA and i thinking it very bad for all in the end. Thanks in advance !!! |
That's actually wrong since 20 minutes or so: |
New device is first priory but Siterwell and Saswell TRVs is very urgent getting working OK then they is having basic functionality (setting and reporting temperature) and with luck little more and users is being very disappointed if cant using all good stuff in there devices. The good thing is deCONZ is not merging any new devices for the summer (only some extra ID is added the last days but no new devices) so they is having larger problems. Also good thing getting all tuya TRVs using the same coding style an being easier making changes and adding functions. Also shall all tuya TRVs being in one large (MEGA) quirk or being spitted in families ? In the end its the maintainer must saying with road shall being used for getting all devices good integrated in ZHA. Have Alexei some thinking ? |
Siterwell you have in your hands, Matt. Saswell I don't touch because @PLTorrent is coding it. I can help if asked. Since some time I've wrote Maxsmart, Beca, Siterwell and extended Moes. Mostly I use Python for converters like Excel->Excel or CSV->SQL Server Every programmer should tell that one MEGA file gives MEGA hard approach to maintain. |
Is it possible making one handle in the quirk that can being used for selecting version of presets in ZHA, like variable If getting updating of all "old" TRVs i think its better splitting them but then need writing tests for all. Today its the normal Moes and Siterwell that have test code implanted and its being broken if changing the code. |
If you is deep diving in the Zigbee documents you is getting the same problems then its many hundred of devs and engineers that have putting all parts together and and in the end all manufactures is doing there variant of it but then tuya is doing all there way outside the standard. For MAxSmarts TRVs, are you planing implanting: I have flagging: If all TRVs that supporting Scheduled in the TRV and if the data format is the same i think its good using the same attribute for all Scheduled functions so its possible using the same Scheduled "application" in ZHA in the future. |
Now I would feel stupid if I would not add those functions to the TRVs I own myself ;-) Moes, Beca, Maxsmart.
|
Its still tuya devices and need earning there name !! That was bad for us :-(( |
I pretty much have it ready bar the scheduling since there is no viable way to present it in HA. Also lack of Presets for this TRV is blocking me. @jacekk015 your feedback/guidance was most helpful and impressive. As for the scheduling on Sas it is done via one endpoint and weekdays are bitmasked so it is possible to send settings for any number of days in case the schedule for those days is to be the same. Then the device confirms with a separate (different) endpoint for each day. ;) And finally all the switches have the same on_off name so unaware user will have no way of knowing which switch is changing what so without entity renaming/suffixing in ZHA it is just a mess |
System mode auto is if you have one climatic that can heating and cooling. |
@MattWestb thanks for explanation ;] |
Saswell SEA802 quirk: Currently only supports SEA802. Additionaly changed climate.py with added Saswell: climate.zip Want to test it a bit more, but for future reference should I open a new issue with this or put it into previous closed issues regarding this TRV? Also those I have no way of testing and they have different endpoint config from _TZE200 ("_TYST11_KGbxAXL2", "GbxAXL2"), TBD:
|
Sas have released devices first with TYST11 Zigbee modules (that have hidden tuya cluster) and then little later the same device with TZE200 Zigbee module with one exception is GbxAXL2 but all looks having the same tuya MCU. The local temperature calibration (if its implanted) is used for getting the device reporting local temperature more often by sending updated of it to the device from one automation. The matrix with one new found that not being added: Saswell | SEA801 | _TYST11_KGbxAXL2 | GbxAXL2 | ✅ Sas II | 798 Also adding preset to ZHA is one braking thing if not the quirk is not in place in Zigpy or the old quirk is left there also if the TYST11 is not moved to the new quirk. |
The code looks very nice and clean !!!! Hope users can getting all extras working without getting crazy if the not named endpoints / cluster but you have doing one good guide :-)) Can you explaining the If you like getting little more battery information you can using this from tuya INIT: zha-device-handlers/zhaquirks/tuya/__init__.py Lines 735 to 746 in 014175e
Great work done !!I trying putting i the tuya TRV matrix. |
Thank you!
Yes
This device only reports battery low via uint8 on/off field, no reporting of battery voltage, etc. so IMHO no point in adding that. |
@PLTorrent Nicely coded, nice code re-usage. I feel a bit lazy looking now ;-) |
@PLTorrent Is the Sas have |
BTW In case you wouldn't be happy with lazy room temp monitoring, and your TRV responds with local temp after calibration or local temp command, you could create a task and query TRV for local temp occasionally. I did it for Maxsmart, because sometimes it reports often, and sometimes after hours.
and somewhere below
|
Thank you!
It is not.
I do not want to go in this direction, since it means shortened battery life. I do not use TRV for reporting room temperature anyway, so no need for that IMHO. |
@PLTorrent For OnOff map_attribute could be simplified:
0,1 are both ways converted automatically between False/True |
Its looks most TRVs is using none, 3 or many presets in ZHA.
Beca and some other is using more like:
I was thinking is it better using 2 "standard presets" for devices and better having one for every TRV-quirk that need it ? "Standard presets" is using lesser classes / code but its little confusing then all is mixes up. |
@MattWestb not sure what you have in mind. If you mean climate.py from ZHA then there is only the 6 presets version for MOES family. The Saswell needs only 3 presets if we want the presets used but it is not implemented in ZHA. Can be done without presets using on_off switches only. Don't know about other thermostats though. |
I knowing and Beca is having one extra (then Moes) but is not using one (or 2) of the Moes one. The bad thing with presets is that for the moment we must adding new devices in the quirk and ZHA but that i can also living with. In the end its tuya devices and its all the time coming new versions that working little different so its not possible making one "tuya standard" for all of them. More ideas and feedback is very welcome. |
Was looking little in the updated tuya dev docks and i think its some interesting things that can helping our mess with some tuya devices.
Command 0x03 is not implanted and shall not being used for normal working devices but i think it can being good using for getting the data from the device then debugging how the device is working and the code is reacting with the device but i think it shall not being used for getting update from devices (like my Siter TRV that only reporting every hour). Its more interesting information of MCU <-> Zigbee module communication but its little out of scope for our work them most we cant see or changing but can being good to knowing how tuya is working behind the DP protocol. Perhaps querying the MCU version can helping with devices that looks behaving differently with the dame device IDs. Also little interesting tuya is having 2 types of Zigbe serial firmware, One for sleeping end devices (our TRVs) one one for routers that is having the radio on all the time and then different versions for the Zigbee module the manufacturer is using. I dont knowing if the device ID is written in the Zigbee module or if its querying it on startup from the zuya MCU but its still interesting to understanding little more of tuya devices that can helping fixing some strange problems user and there devices is having |
0x03 is needed, for example, for Tuya siren - tried to code this but I can't do this remotely - don't have this device. Koenkk/zigbee-herdsman@e0b6cea |
I have one similar case with switching mode of the tuya TS004F dimmer switch that can changing mode by writing one attribute then the device is in configure mode. |
Hey @MattWestb thanks for your comment asking about writing tests. I do have experience in writing py.test code. Is there anything specific that you were looking for? |
@jacekk015 have making much code for new and updating all tuya TRV and we have doing some PRs but we cant getting them thru then we dont knowing how to do the test code. I hope we can getting pushed in the right direction and getting the tests in place with some help and knowledge for some with experience. I hope @jacekk015 is still having interest getting the test being done and his great work getting in side the mainline code and users dont need patching HA containers and installing external quirks for getting there TRVs working in ZHA. |
Hey, I have had a first look at the tests and commented over on the pull request. @jacekk015 in the PR you said
These have taken from the raw message logs. So you set up a test which checks that the given message results in the desired behaviour. For example, I captured these log message from pressing a button on the remote I'm trying to implement:
The raw message is the last parameter shown on the first message. I made a test for the button event like this: ZCL_TUYA_1001_SWITCH_ON = b'\x01\x1c\xfd\x00'
@pytest.mark.parametrize("quirk", (zhaquirks.tuya.ts1001.TuyaDimRemote1001,))
async def test_ts1001_state_report(zigpy_device_from_quirk, quirk):
"""Test ts1001 4 button switch."""
switch_dev = zigpy_device_from_quirk(quirk)
switch_cluster = switch_dev.endpoints[1].out_clusters[OnOff.cluster_id]
switch_listener = ClusterListener(switch_cluster)
hdr, args = switch_cluster.deserialize(ZCL_TUYA_1001_SWITCH_ON)
switch_cluster.handle_message(hdr, args)
# We expect to have seen an event sent and a command (response to device)
assert len(switch_listener.cluster_commands) == 1
assert len(switch_listener.events_sent) == 1
assert len(switch_listener.attribute_updates) == 0
assert switch_listener.events_sent[0][0] == SHORT_PRESS The test sets up a mock device and cluster, and then sends the message to the cluster. The ClusterListener is just a helper class that subscribes to messages and remembers which messages it has seen. |
Hey, I have had a first look at the tests and commented over on the pull request. I need some input on that - I don't have the device and I need to know how best to handle the missing temperature offset setting in the tests. Does anyone here have one of these? @jacekk015 in the PR you said
These have taken from the raw message logs. So you set up a test which checks that the given message results in the desired behaviour. For example, I captured these log message from pressing a button on the remote I'm trying to implement:
The raw message is the last parameter shown on the first message. I made a test for the button event like this: ZCL_TUYA_1001_SWITCH_ON = b'\x01\x1c\xfd\x00'
@pytest.mark.parametrize("quirk", (zhaquirks.tuya.ts1001.TuyaDimRemote1001,))
async def test_ts1001_state_report(zigpy_device_from_quirk, quirk):
"""Test ts1001 4 button switch."""
switch_dev = zigpy_device_from_quirk(quirk)
switch_cluster = switch_dev.endpoints[1].out_clusters[OnOff.cluster_id]
switch_listener = ClusterListener(switch_cluster)
hdr, args = switch_cluster.deserialize(ZCL_TUYA_1001_SWITCH_ON)
switch_cluster.handle_message(hdr, args)
# We expect to have seen an event sent and a command (response to device)
assert len(switch_listener.cluster_commands) == 1
assert len(switch_listener.events_sent) == 1
assert len(switch_listener.attribute_updates) == 0
assert switch_listener.events_sent[0][0] == SHORT_PRESS The test sets up a mock device and cluster, and then sends the message to the cluster. The ClusterListener is just a helper class that subscribes to messages and remembers which messages it has seen. I've also been working on making some test fixtures to set things up and make it easier to write some tests. |
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. |
@PLTorrent The latest HA Update seems to have broken this quirk: Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 365, in async_setup
result = await component.async_setup_entry(hass, self)
File "/usr/src/homeassistant/homeassistant/components/zha/__init__.py", line 101, in async_setup_entry
setup_quirks(config)
File "/usr/local/lib/python3.10/site-packages/zhaquirks/__init__.py", line 409, in setup
importer.find_module(modname).load_module(modname)
File "<frozen importlib._bootstrap_external>", line 548, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 1063, in load_module
File "<frozen importlib._bootstrap_external>", line 888, in load_module
File "<frozen importlib._bootstrap>", line 290, in _load_module_shim
File "<frozen importlib._bootstrap>", line 719, in _load
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/config/quirks/trv_saswell.py", line 21, in <module>
from zhaquirks.tuya.ts0601_trv_sas import BATTERY_REPORTED
ImportError: cannot import name 'BATTERY_REPORTED' from 'zhaquirks.tuya.ts0601_trv_sas' (/usr/local/lib/python3.10/site-packages/zhaquirks/tuya/ts0601_trv_sas.py) Could you be so kind and try to fix this? |
Hi,
As @MattWestb and @jacekk015 suggested I open a technical topic for all the tech questions regarding the implementation of the quirks for Tuya TRV.
And to start off here is a first one: Changing the range of available temperature settings. For current Saswell quirk (https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/tuya/ts0601_trv_sas.py) the temp range is set to 7-30 (default) however the device uses 5 -30. The setting used in quirk is not being applied.
The way I managed to change this is:
this is not working:
Do you know of any other/better way of doing this?
PS. Check if this is working correctly for Moes/Beca TRV as those seem to read those values from TRV but, are those values implemented in HA?
The text was updated successfully, but these errors were encountered: