Skip to content
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

Fix TuyaNewManufCluster set_time time synchronization #3652

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

ad0p
Copy link

@ad0p ad0p commented Dec 29, 2024

Proposed change

Changing set_time to be sent as is_manufacturer_specific=False. This is aligned with z2m behavior and fixes broken synchronization on Tyua thermostats.

Additional information

Symptoms:
Avatto ZWT100 thermostat time synchronization is not working with HA using ZHA integration. When tested with z2m, synchronization works correctly. I compared both implementations and found that z2m is sending set_time command with is_manufacturer_specific=False, while ZHA is sending it with is_manufacturer_specific=True. With proposed change, Tuya time synchronization works correctly.

zigpy.zcl log example:

2024-12-29 02:23:10.058 DEBUG (MainThread) [zigpy.zcl] [0x5090:1:0xef00] Sending request header: ZCLHeader(frame_control=FrameControl<0x05>(frame_type=<FrameType.CLUSTER_COMMAND: 1>, is_manufacturer_specific=True, direction=<Direction.Client_to_Server: 0>, disable_default_response=0, reserved=0, *is_cluster=True, *is_general=False), manufacturer=4417, tsn=7, command_id=36, *direction=<Direction.Client_to_Server: 0>)

z2m log example:

[2024-12-21 20:12:06] �[34mdebug�[39m: zh:ember: ~~~> [ZCL to=0xa4c138753b223995:16528 apsFrame={"profileId":260,"clusterId":61184,"sourceEndpoint":1,"destinationEndpoint":1,"options":4416,"groupId":0,"sequence":0} header={"frameControl":{"reservedBits":0,"frameType":1,"direction":0,"disableDefaultResponse":false,"manufacturerSpecific":false},"transactionSequenceNumber":15,"commandIdentifier":36}]

Checklist

  • The changes are tested and work correctly
  • pre-commit checks pass / the code has been formatted using Black
  • Tests have been added to verify that the new code works - no new code, just fixing boolean

Copy link

codecov bot commented Dec 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.84%. Comparing base (1718afe) to head (fb39a03).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #3652   +/-   ##
=======================================
  Coverage   89.84%   89.84%           
=======================================
  Files         322      322           
  Lines       10371    10371           
=======================================
  Hits         9318     9318           
  Misses       1053     1053           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TheJulianJES TheJulianJES added Tuya Request/PR regarding a Tuya device needs review This PR should be reviewed soon, as it generally looks good. labels Dec 29, 2024
Copy link
Collaborator

@TheJulianJES TheJulianJES left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know if there are devices that do not work when changing this?

@TheJulianJES TheJulianJES changed the title Fix TuyaNewManufCluster set_time time synchronization Fix TuyaNewManufCluster set_time time synchronization Dec 30, 2024
@ad0p
Copy link
Author

ad0p commented Dec 31, 2024

Do we know if there are devices that do not work when changing this?

Unfortunately, I have no other Tyua device with time support to test that, @TheJulianJES. I suppose this is not broadly used, most devices don't need that.

@mellowism , I've seen that you have tested Tuya Namron thermostat here. Would you mind looking at this change?

It would be very helpful to know the behavior for Namron thermostat:
a) time synchronization works only with current implementation (is_manufacturer_specific=True)
b) time synchronization works only with proposed fix (is_manufacturer_specific=False)
c) time synchronization works with both ?
d) time synchronization doesn't work at all

I used the following command to switch from is_manufacturer_specific=True to is_manufacturer_specific=False

sudo docker exec -it homeassistant sed -i 's/"set_time", {"time": TuyaTimePayload}, False, is_manufacturer_specific=True/"set_time", {"time": TuyaTimePayload}, False, is_manufacturer_specific=False/g' /usr/local/lib/python3.13/site-packages/zhaquirks/tuya/__init__.py

To switch back to True:

sudo docker exec -it homeassistant sed -i 's/"set_time", {"time": TuyaTimePayload}, False, is_manufacturer_specific=False/"set_time", {"time": TuyaTimePayload}, False, is_manufacturer_specific=True/g' /usr/local/lib/python3.13/site-packages/zhaquirks/tuya/__init__.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review This PR should be reviewed soon, as it generally looks good. Tuya Request/PR regarding a Tuya device
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants