zha-device-handlers
zha-device-handlers copied to clipboard
Adds support for HC-T020 thermostat
Proposed change
Adds basic support for Tuya HC-T020 Zigbee thermostat, addressing #2441
Aliexpress link: https://www.aliexpress.us/item/3256803286637740.html?gatewayAdapt=glo2usa4itemAdapt
With this, it's possible to read current temperature, set temperature and know if the device is currently heating or idle. It's the minum necessary to be able to use it in Home Assistant for basic automations.
Additional information
It's heavily based on the MoesBHT quirk
Checklist
- [x] The changes are tested and work correctly
- [x]
pre-commitchecks pass / the code has been formatted using Black - [ ] Tests have been added to verify that the new code works
Codecov Report
Attention: Patch coverage is 49.20635% with 32 lines in your changes are missing coverage. Please review.
Project coverage is 86.53%. Comparing base (
6ff75e7) to head (b7355d1). Report is 119 commits behind head on dev.
| Files | Patch % | Lines |
|---|---|---|
| zhaquirks/tuya/ts0601_gas_heating.py | 49.20% | 32 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## dev #2466 +/- ##
==========================================
- Coverage 86.80% 86.53% -0.28%
==========================================
Files 280 281 +1
Lines 8571 8634 +63
==========================================
+ Hits 7440 7471 +31
- Misses 1131 1163 +32
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@TheJulianJES any suggestions on what else to do to get this reviewed and incorporated?
I have this successfully working with one device. I had to fix a regression today which appeared after HA core update to 2023.8.0 which included zha_quirks 0.0.102, but that's solved now.
If you can give me any guidance / pointers on what else should be done, I'd appreciate it.
First of all, thanks for your PR!
The already existing code for the Tuya thermostats is somewhat of a mess and I'm not very familiar with it.
For example, everything related to Bus could be cleaned up, as that doesn't need to be used anymore.
Updating an attribute on the thermostat cluster can be done like this now:
self.endpoint.thermostat.update_attribute(
Thermostat.AttributeDefs.local_temperature.id,
local_temp,
)
A method defined in a(n underlying) CustomCluster can also be called like that (just instead of update_attribute, use the method name).
Like you mentioned, the code is very similar to the Moes quirk (which could/should also be cleaned up).
Lastly, this PR doesn't have any tests for the newly added code (test_tuya.py as somewhat of an example).
This is also not done for some other Tuya thermostat, so I'll have to ask what we should do about this.
(If you could write code that tests the quirk/"emulates the thermostat", that would be beneficial of course)
The ts0601_electric_heating.py is for thermostats. TRVs is in ts0601_trv.py and some have getting own that have different implementations but its always possible changing names on the files for getting it more logic like ts0601_haozee.py so its looks like this one ts0601_trv_sas.py.
Thanks @TheJulianJES and @MattWestb I have to admit I'm completely new to ZHA and the quirks, but I can give a shot at adding tests and perhaps using a more modern approach by following your pointers.
@MattWestb I didn't understand the suggestion implied by your comment. Are you suggesting any changes in the file naming perhaps?
@adamantivm It was more for Julian and the other maintainers for getting information and searing the quirk naming. I have done some renaming of tuya quirks but the responsibility is by the maintainers and i can only suggesting changes and must living with how its being done.
Edit: Your naming is very good but 2 of my examples shall being renamed i think.
perhaps putting the Thermostat in front so its being sorted OK
Like ts0601_thermostat_gas_heating.py
@TheJulianJES I think ts0601_electric_heating.py shall being ts0601_thermostat_electric_heating.py or ts0601_thermostat_electric.py and ts0601_haozee.py ts0601_trv_haozee.py.
I dont do renaming PR then i cant fixing if i braking the test linked to them.
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.