Skip to content

Add support for Smart Standing Fan 2 Pro #195

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 13 commits into from
Jul 17, 2022
Merged

Conversation

AlexKalopsia
Copy link
Contributor

Hi there, today I got myself a Smart Standing Fan 2 Pro, so I spent some time adding support to it.
I have tested all the supported functions and they all work correctly.

Model: dmaker.fan.p33
Hardware version: esp8266
Firmware version: 2.1.3

https://www.mi.com/global/product/xiaomi-smart-standing-fan-2-pro/

@AlexKalopsia AlexKalopsia requested a review from syssi July 16, 2022 07:55
@AlexKalopsia
Copy link
Contributor Author

I have committed some changes, and I came to the conclusion that - as you suggested - it made more sense to inherit from XiaomiFanMiot

I initially thought that the attr names needed to be in line with what miot-spec would report in the JSON file, but that doesn't seem to be the case, so I aligned the names with the rest of the codebase. This potentially means that I can perhaps just use AVAILABLE_ATTRIBUTES_FAN_P5.

I have left some TODOs for which I might appreciate some help:

1 - The child lock command works correctly from HA, but the entity status keeps showing child_lock as null. I have honestly tried everything (making a specific async function for the P33, using the JSON variable name, but HA is set on it being null. Any idea what could be causing this?

2 - I noticed that fan.turn_on() doesn't manage to set the percentage. The set_percentage() function works fine though, so I am not sure if this is something that the component is unable to overwrite (ie the Fan just alweays reloads the latest speed, at least that's what the manual says)

I hope I am not giving you too many headaches with this, I appreciate the help

@syssi
Copy link
Owner

syssi commented Jul 16, 2022

  1. Do you know how to send raw commands to your device using miiocli from python-miio? This could help to get a better understanding of the different requests and responses. I assume you don't monitor/track the right property to update the child lock on every update.
  2. Could you try turn off your fan and set the percentage without turning the fan on? I assume the firmware of your device requires two commands (turn_on + set_percentage) to act properly.

Please add miio: debug to the logger to enable the debug output of the underlying library. So you can see all raw requests and responses: https://github.com/syssi/xiaomi_raw#debugging

@syssi
Copy link
Owner

syssi commented Jul 16, 2022

PS. You can ignore/change the attribute names of the miot specs. The IDs are the important keys.

@syssi
Copy link
Owner

syssi commented Jul 16, 2022

Did you fix the temperature=KeyError?

@AlexKalopsia
Copy link
Contributor Author

Do you know how to send raw commands to your device using miiocli from python-miio? This could help to get a better understanding of the different requests and responses. I assume you don't monitor/track the right property to update the child lock on every update.

Yes, that's how I am currently testing everything. I am 100% sure the child lock property is correct. It's (7, 1), and when I activate it, I can manually see that it is correctly acrivated/deactivated, and miiocli returns the correct bool. The weird thing is that now I added the lovelave-fan-card (https://github.com/ikaruswill/lovelace-fan-xiaomi) and by clicking on the button, the child_lock got finally correctly set. Now it works correctly, I am wondering if it's a matter of it not having been correctly initialized somehow.

Could you try turn off your fan and set the percentage without turning the fan on? I assume the firmware of your device requires two commands (turn_on + set_percentage) to act properly.

I can confirm that from off state, fan.set_percentage works correctly. Seems like on just overwrites it then, if that's how it is then I guess I'll leave a comment.

Please add miio: debug to the logger

Thank you!

Did you fix the temperature=KeyError?

Yes, it was one of those leftover properties that I didn't even need

@AlexKalopsia AlexKalopsia requested a review from syssi July 16, 2022 20:14
@AlexKalopsia
Copy link
Contributor Author

Did some more testing and I noticed that I had an issue with the delay timer (ZA5 was doing some minutes -> seconds conversion), so I took the time to test and fix it. It works correctly now.

@AlexKalopsia
Copy link
Contributor Author

All changes done. So much of it is a reminder to not code the entire day, I dunno what the hell I was thinking with all those enum conversions lol

Thanks for the help improving this PR

Copy link
Owner

@syssi syssi left a comment

Choose a reason for hiding this comment

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

I would be happy about a final test. If the implementation is working a expecting this is ready to get merged.

@syssi
Copy link
Owner

syssi commented Jul 17, 2022

Please ping me if you are ready with testing and sure everything is working as expected. I would like to prepare a new release this evening.

@AlexKalopsia
Copy link
Contributor Author

If with testing you mean "manually testing the device", I have tested it extensively since the last PR and it works correctly 👍

@syssi syssi merged commit b5e616e into syssi:develop Jul 17, 2022
@syssi
Copy link
Owner

syssi commented Jul 17, 2022

Thanks for your contribution! Feel free to prepare additional pull requests if you see room for improvements!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants