Skip to content

Add Avatto thermostats (Tuya) #3748

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

Merged
merged 7 commits into from
Jan 25, 2025

Conversation

prairiesnpr
Copy link
Collaborator

@prairiesnpr prairiesnpr commented Jan 22, 2025

Proposed change

Adds Tuya ZWT198/ZWT100-BH Avatto wall thermostats

  • _TZE204_lzriup1j
  • _TZE200_viy9ihs7
  • _TZE204_xnbkhhdr
  • _TZE284_xnbkhhdr

Closes: #3627
Closes: #3212
Closes: #2589
Closes: #3482
Closes: #3326

Additional information

Based on: Koenkk/zigbee2mqtt#25752
and https://github.com/Koenkk/zigbee-herdsman-converters/blob/40e72bc2515deb67ef35dddab04437342b7b3eb9/src/devices/tuya.ts#L7027

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

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.43%. Comparing base (d9481d3) to head (3333cf8).
Report is 3 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #3748      +/-   ##
==========================================
+ Coverage   90.40%   90.43%   +0.03%     
==========================================
  Files         320      320              
  Lines       10490    10525      +35     
==========================================
+ Hits         9483     9518      +35     
  Misses       1007     1007              

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

@delaosa
Copy link

delaosa commented Jan 22, 2025

I've tested this quirk with my_TZE284_xnbkhhdr, it works quite well however the time is not set on the device, it keeps trying to sync, due that there are a excessive number of messages". In Z2M this device works flawless (time is synced and no excessive number of messages). This devices is configured with "respondToMcuVersionResponse: false", as I've also seen in another issue it makes a difference :

Important: respondToMcuVersionResponse should be false otherweise there are an avalanche of commandMcuVersionResponse messages every second.

@prairiesnpr
Copy link
Collaborator Author

@delaosa Thanks for the feedback! This should address both of your points.

@delaosa
Copy link

delaosa commented Jan 23, 2025

I cannot test it since .add_to_registry(replacement_cluster=NoManufTimeNoVersionRespTuyaMCUCluster) is not supported in my HA installation, guessing this feature hasn't be released yet. However I've tested updating TUYA_SET_TIME command in tuya/mcu/init.py with is_manufacturer_specific=False and time sync is working. Thanks!

Updating temperature or turning off/on the thermostat from HA is not working, to fix it I've added the following code to 'TuyaThermostat' class:

    async def write_attributes(self, attributes, manufacturer=None):
        """Overwrite to force manufacturer code."""

        return await super().write_attributes(
            attributes, manufacturer=foundation.ZCLHeader.NO_MANUFACTURER_ID
        )
  

@prairiesnpr prairiesnpr marked this pull request as ready for review January 23, 2025 19:44
@TheJulianJES TheJulianJES added Tuya Request/PR regarding a Tuya device needs review This PR should be reviewed soon, as it generally looks good. labels Jan 23, 2025
Comment on lines +353 to +358
.tuya_switch(
dp_id=103,
attribute_name="factory_reset",
translation_key="factory_reset",
fallback_name="Factory reset",
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess this could be changed to a button (in the future)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Likely, I was also wondering if we should even expose a factory reset by default...

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.

PR seems fine otherwise.

@TheJulianJES TheJulianJES changed the title Add Avatto Thermostats (Tuya) Add Avatto thermostats (Tuya) Jan 24, 2025
@prairiesnpr prairiesnpr force-pushed the add-thermostat-_TZE200_viy9ihs7 branch from 4c30303 to 3333cf8 Compare January 25, 2025 12:39
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.

thanks!

@TheJulianJES TheJulianJES merged commit 160d900 into zigpy:dev Jan 25, 2025
9 checks passed
@prairiesnpr prairiesnpr deleted the add-thermostat-_TZE200_viy9ihs7 branch January 25, 2025 21:24
@jaisinghdhaliwal
Copy link

I appear to get an error:

Traceback (most recent call last): File "/usr/local/lib/python3.13/site-packages/zhaquirks/__init__.py", line 479, in setup spec.loader.exec_module(module) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^ File "<frozen importlib._bootstrap_external>", line 1026, in exec_module File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed File "/config/zha_quirks/tuya_thermostat.py", line 414, in <module> .add_to_registry(replacement_cluster=NoManufTimeNoVersionRespTuyaMCUCluster) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: TuyaQuirkBuilder.add_to_registry() got an unexpected keyword argument 'replacement_cluster'

Changing .add_to_registry(replacement_cluster=NoManufTimeNoVersionRespTuyaMCUCluster) to .add_to_registry() results in the quirk successfully loading however temperature controls do not upload to the thermostat.

@prairiesnpr
Copy link
Collaborator Author

This will be available in 2025.2.

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
4 participants