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.mc2 #895

Merged
merged 8 commits into from
Jan 5, 2021
Merged

Add support for zhimi.heater.mc2 #895

merged 8 commits into from
Jan 5, 2021

Conversation

bafonins
Copy link
Contributor

This PR adds support for Xiaomi Mi Smart Space Heater S (zhimi.heater.mc2).

References: #880
miot spec: https://miot-spec.org/miot-spec-v2/instance\?type\=urn:miot-spec-v2:device:heater:0000A01A:zhimi-mc2:1

Details Product: Screenshot 2020-12-25 at 15 21 09

Mi Home UI:
ui1
ui2

Added unit tests as well as tested the new heater module on an actual device.

Please let me know if I missed anything.

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.

Looks fairly straightforward to me, only a minor change needed before this can be merged. Thanks for the PR!

miio/heater_miot.py Show resolved Hide resolved

@property
def countdown_time(self) -> int:
"""Countdown time."""
Copy link
Owner

Choose a reason for hiding this comment

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

What does this indicate? Time until the device gets turned off? Maybe the property naming should follow the same format as in heater?

Copy link
Contributor Author

@bafonins bafonins Dec 29, 2020

Choose a reason for hiding this comment

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

Exactly. The countdown_time field defines the number hours before the device goes off.
The problem here is that the spec defines this field as countdown_time while for miio heater it is delay_off_countdown. Shall I overwrite countdown_time to match the field name in heater (delay_off_countdown)?

Copy link
Owner

Choose a reason for hiding this comment

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

Okay, looking at the current code base, there are several instances of delay_off_countdown which returns the value in seconds.

So I'd say yes, it's better use that same naming scheme (and return the value in seconds even when the precision is much lower) just to be consistent.

miio/heater_miot.py Outdated Show resolved Hide resolved
@bafonins
Copy link
Contributor Author

@rytilahti fixed according to your comments. let me know if I missed anything

miio/heater_miot.py Outdated Show resolved Hide resolved
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.

One last very minor change and this is good to go. Thanks for the PR! 🥇

miio/heater_miot.py Outdated Show resolved Hide resolved
@rytilahti rytilahti merged commit 48544a4 into rytilahti:master Jan 5, 2021
@ee02217
Copy link

ee02217 commented Jan 10, 2021

This is great! Thanks!
How about adding support to Home Assistant integration? 👍

@rytilahti rytilahti mentioned this pull request Mar 13, 2021
xvlady pushed a commit to xvlady/python-miio that referenced this pull request May 9, 2021
* Add support for zhimi.heater.mc2

* fixup! Fix docstring for HeaterMiot

* fixup! Add zhimi.heater.mc2 to readme

* fixup! Fix miot spec link

* fixup! Add response example for heater

* fixup! Rename brightness property of miot heater

* fixup! Allow setting delay countdown in seconds

* Add model info to docstring

Co-authored-by: Teemu R <[email protected]>
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