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 Avatto thermostats (Tuya) #3748

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from

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.16%. Comparing base (e349a0d) to head (4c30303).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #3748      +/-   ##
==========================================
+ Coverage   90.13%   90.16%   +0.03%     
==========================================
  Files         320      320              
  Lines       10473    10508      +35     
==========================================
+ Hits         9440     9475      +35     
  Misses       1033     1033              

☔ 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...

Comment on lines +26 to +30
FifteenMin = 0x00
ThirtyMin = 0x01
FortyFiveMin = 0x02
SixtyMin = 0x03
NinetyMin = 0x04
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think other enums include the number like _90_min or Min_90? Do we want to do this here and for the enums below where numbers are spelled out at the moment?

In the future, we'll try to make enums translatable with zigpy/zha#86.
These would act as the translation key then. Just fyi if this affects your decision.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can also merge them like this for now and streamline all enums in another PR, but we'd need to do that before the 2025.2.0 beta release date, so we don't mess up any actual HA entities.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I prefer the _90_min format, I'll update it shortly.

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