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

Add Tuya QUERY_DATA command #2888

Merged
merged 2 commits into from
Jan 19, 2024
Merged

Add Tuya QUERY_DATA command #2888

merged 2 commits into from
Jan 19, 2024

Conversation

tschiex
Copy link
Contributor

@tschiex tschiex commented Jan 5, 2024

Proposed change

Some tuya devices require a query_data to be responsive and provide data.
As suggested by tjj, this just provides this ability to quirks.

Additional information

Contributes to fixing #2565

EDIT:
Follow-up PR that adds the "Tuya query data spell":

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
    Couldn't find a significant test.

Copy link

codecov bot commented Jan 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6b9516d) 87.56% compared to head (5917d1e) 87.56%.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #2888   +/-   ##
=======================================
  Coverage   87.56%   87.56%           
=======================================
  Files         293      293           
  Lines        8997     8998    +1     
=======================================
+ Hits         7878     7879    +1     
  Misses       1119     1119           

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

@@ -1488,6 +1489,9 @@ class TuyaNewManufCluster(CustomCluster):
ep_attribute: str = "tuya_manufacturer"

server_commands = {
TUYA_QUERY_DATA: foundation.ZCLCommandDef(
"query_data", {}, False, is_manufacturer_specific=True
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's no data structure for this command?
Can you point us to any command message or use case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are Tuya devices that will not start nor send information w/o DATA_QUERY messages. For these, a DATA_QUERY package has to be sent on startup and also later for polling: no information is sent except if a DATA_QUERY packet is sent.

See the forthcoming zha-quirk for an example of usage in ZHA. I followed the suggestion of TheJulianJES here.

See also the corresponding code in Z2MQTT here

@TheJulianJES TheJulianJES added the Tuya Request/PR regarding a Tuya device label Jan 15, 2024
@TheJulianJES TheJulianJES changed the title Tuya QUERY_DATA capability Add Tuya QUERY_DATA command Jan 19, 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.

LGTM, thanks!

@TheJulianJES TheJulianJES self-assigned this Jan 19, 2024
@TheJulianJES TheJulianJES merged commit ec898e2 into zigpy:dev Jan 19, 2024
28 checks passed
lgraf pushed a commit to lgraf/zha-device-handlers that referenced this pull request May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tuya Request/PR regarding a Tuya device
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants