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 support for zhimi.heater.za2 #1301

Merged
merged 8 commits into from
Jan 22, 2022
Merged

Conversation

PRO-2684
Copy link
Contributor

This PR adds support to zhimi.heater.za2.
heater_miot_za2.py's code is modified from heater_miot.py. Compared to already supported mc2 model, za2 can monitor relative humidity, so I added relative_humidity function.
P.S. Comment is wrong at heater_miot.py, line 21. Should be # Physical Control Locked (siid=5).

@rytilahti
Copy link
Owner

rytilahti commented Jan 16, 2022

Hi and thanks for the PR!

Instead of creating a separate class that would necessitate separate tests etc., please just extend the existing implementation as they are from the same manufacturer and they do not differ that much.

You can do that by basing your PR on top of #1302, and introducing _mappings that is a dict containing model-keyed mappings. The correct mapping will then be chosen automatically run-time :-)

For the extra relative_humidity, you can check if the value is there and mark it as Optional in the container to keep the API for both types of models:

    @property
    def relative_humidity(self) -> int:
        """Current relative humidity."""
        return self.data.get("relative_humidity")

@PRO-2684
Copy link
Contributor Author

On za2, LedBrightness 0 means "On (Bright)", 1 means "On (Dim)", 2 means "Off". How should this conflict be solved?

@PRO-2684
Copy link
Contributor Author

@rytilahti This should work now. But as I modified the class LedBrightness, users may encounter compatibility issues.

@PRO-2684 PRO-2684 marked this pull request as ready for review January 18, 2022 00:55
Copy link
Owner

@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

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

Just two more things and this is good to go!

Btw, you can run the linting tests also locally by executing pre-commit run -a or tox -e lint, this way you can fix them without waiting for me to approve the run on CI.

miio/heater_miot.py Outdated Show resolved Hide resolved
miio/heater_miot.py Outdated Show resolved Hide resolved
@PRO-2684
Copy link
Contributor Author

I've run the tests and it shall be fine now.

Copy link
Owner

@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

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

Please fix the tests and update README.md, and then this is good to go! 🎉

miio/heater_miot.py Outdated Show resolved Hide resolved
@rytilahti
Copy link
Owner

rytilahti commented Jan 21, 2022

Oh, looks like the tests are still failing. Btw, you can also run the tests locally by executing pytest or tox :-)

@rytilahti rytilahti mentioned this pull request Jan 21, 2022
@PRO-2684
Copy link
Contributor Author

The reason why the tests are not passed is that the dummy test cases are based on mc2, but I chose to fall back on the strictest restriction in times of unrecognized models, including dummy.

@codecov-commenter
Copy link

codecov-commenter commented Jan 22, 2022

Codecov Report

Merging #1301 (03492a0) into master (17e713a) will decrease coverage by 0.04%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1301      +/-   ##
==========================================
- Coverage   82.34%   82.30%   -0.05%     
==========================================
  Files         106      106              
  Lines       11404    11417      +13     
  Branches     1354     1357       +3     
==========================================
+ Hits         9391     9397       +6     
- Misses       1821     1825       +4     
- Partials      192      195       +3     
Impacted Files Coverage Δ
miio/heater_miot.py 87.35% <66.66%> (-7.24%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 17e713a...03492a0. Read the comment docs.

@rytilahti
Copy link
Owner

This is good to go, thanks @PRO-2684!

@rytilahti rytilahti merged commit e58ad5e into rytilahti:master Jan 22, 2022
rytilahti added a commit that referenced this pull request Feb 17, 2022
This release adds support for several new devices (see details below, thanks to @PRO-2684, @peleccom, @ymj0424, and @supar), and contains improvements to Roborock S7, yeelight and gateway integrations (thanks to @starkillerOG, @Kirmas,>

Python 3.6 is no longer supported, and Fan{V2,SA1,ZA1,ZA3,ZA4} utility classes are now removed in favor of using Fan class.

[Full Changelog](0.5.9.2...0.5.10)

**Breaking changes:**

- Split fan.py to vendor-specific fan integrations [\#1304](#1304) (@rytilahti)
- Drop python 3.6 support [\#1263](#1263) (@rytilahti)

**Implemented enhancements:**

- Improve miotdevice mappings handling [\#1302](#1302) (@rytilahti)
- airpurifier\_miot: force aqi update prior fetching data [\#1282](#1282) (@rytilahti)
- improve gateway error messages [\#1261](#1261) (@starkillerOG)
- yeelight: use and expose the color temp range from specs [\#1247](#1247) (@Kirmas)
- Add Roborock S7 mop scrub intensity [\#1236](#1236) (@shred86)

**New devices:**

- Add support for zhimi.heater.za2 [\#1301](#1301) (@PRO-2684)
- Dreame F9 Vacuum \(dreame.vacuum.p2008\) support [\#1290](#1290) (@peleccom)
- Add support for Air Purifier 4 Pro \(zhimi.airp.va2\) [\#1287](#1287) (@ymj0424)
- Add support for deerma.humidifier.jsq{s,5} [\#1193](#1193) (@supar)

**Merged pull requests:**

- Add roborock.vacuum.a23 to supported models [\#1314](#1314) (@rytilahti)
- Move philips light implementations to integrations/light/philips [\#1306](#1306) (@rytilahti)
- Move leshow fan implementation to integrations/fan/leshow/ [\#1305](#1305) (@rytilahti)
- Split fan\_miot.py to vendor-specific fan integrations [\#1303](#1303) (@rytilahti)
- Add chuangmi.remote.v2 to chuangmiir [\#1299](#1299) (@rytilahti)
- Perform pypi release on github release [\#1298](#1298) (@rytilahti)
- Print debug recv contents prior accessing its contents [\#1293](#1293) (@rytilahti)
- Add more supported models [\#1292](#1292) (@rytilahti)
- Add more supported models [\#1275](#1275) (@rytilahti)
- Update installation instructions to use poetry [\#1259](#1259) (@rytilahti)
- Add more supported models based on discovery.py's mdns records [\#1258](#1258) (@rytilahti)
@rytilahti rytilahti mentioned this pull request Feb 17, 2022
rytilahti added a commit that referenced this pull request Feb 17, 2022
This release adds support for several new devices (see details below, thanks to @PRO-2684, @peleccom, @ymj0424, and @supar), and contains improvements to Roborock S7, yeelight and gateway integrations (thanks to @starkillerOG, @Kirmas, and @shred86).
Thanks also to everyone who has reported their working model information, we can use this information to provide better discovery in the future and this release silences the warning for known working models.

Python 3.6 is no longer supported, and Fan{V2,SA1,ZA1,ZA3,ZA4} utility classes are now removed in favor of using Fan class.

[Full Changelog](0.5.9.2...0.5.10)

**Breaking changes:**

- Split fan.py to vendor-specific fan integrations [\#1304](#1304) (@rytilahti)
- Drop python 3.6 support [\#1263](#1263) (@rytilahti)

**Implemented enhancements:**

- Improve miotdevice mappings handling [\#1302](#1302) (@rytilahti)
- airpurifier\_miot: force aqi update prior fetching data [\#1282](#1282) (@rytilahti)
- improve gateway error messages [\#1261](#1261) (@starkillerOG)
- yeelight: use and expose the color temp range from specs [\#1247](#1247) (@Kirmas)
- Add Roborock S7 mop scrub intensity [\#1236](#1236) (@shred86)

**New devices:**

- Add support for zhimi.heater.za2 [\#1301](#1301) (@PRO-2684)
- Dreame F9 Vacuum \(dreame.vacuum.p2008\) support [\#1290](#1290) (@peleccom)
- Add support for Air Purifier 4 Pro \(zhimi.airp.va2\) [\#1287](#1287) (@ymj0424)
- Add support for deerma.humidifier.jsq{s,5} [\#1193](#1193) (@supar)

**Merged pull requests:**

- Add roborock.vacuum.a23 to supported models [\#1314](#1314) (@rytilahti)
- Move philips light implementations to integrations/light/philips [\#1306](#1306) (@rytilahti)
- Move leshow fan implementation to integrations/fan/leshow/ [\#1305](#1305) (@rytilahti)
- Split fan\_miot.py to vendor-specific fan integrations [\#1303](#1303) (@rytilahti)
- Add chuangmi.remote.v2 to chuangmiir [\#1299](#1299) (@rytilahti)
- Perform pypi release on github release [\#1298](#1298) (@rytilahti)
- Print debug recv contents prior accessing its contents [\#1293](#1293) (@rytilahti)
- Add more supported models [\#1292](#1292) (@rytilahti)
- Add more supported models [\#1275](#1275) (@rytilahti)
- Update installation instructions to use poetry [\#1259](#1259) (@rytilahti)
- Add more supported models based on discovery.py's mdns records [\#1258](#1258) (@rytilahti)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants