-
Notifications
You must be signed in to change notification settings - Fork 703
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
Convert IKEA Starkvind fan speed attribute #3088
Convert IKEA Starkvind fan speed attribute #3088
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #3088 +/- ##
==========================================
+ Coverage 87.90% 87.94% +0.03%
==========================================
Files 300 300
Lines 9222 9222
==========================================
+ Hits 8107 8110 +3
+ Misses 1115 1112 -3 ☔ View full report in Codecov by Sentry. |
84e19eb
to
b1884c8
Compare
f7117d3
to
79de6c2
Compare
Added a test to make codecov happy. |
…posed Fixes home-assistant#97440 Previously starkvind exposed 10 speed settings and no modes, where 10% corresponded to auto mode and 20%-100% corresponded to fixed speeds. This patch correctly exposes auto mode as a mode. It also adds support for showing the actual fan speed while auto mode is enabled. Starkvind supports 9 fan speeds. Because 9 doesn't neatly fit into 100% I cheated a bit and divided the 100% into 10% increments, where trying to set the fan to 10% sets it to 20% instead. I believe that this gives the overall better user experience compared to having 11.11% increments. The 5 speed modes present on the physical interface of the device correspond to HA speed settings 20%, 40%, 60% and 100%. This patch depends on zigpy/zha-device-handlers#3088 being merged and released.
…posed Fixes home-assistant#97440 Previously starkvind exposed 10 speed settings and no modes, where 10% corresponded to auto mode and 20%-100% corresponded to fixed speeds. This patch correctly exposes auto mode as a mode. It also adds support for showing the actual fan speed while auto mode is enabled. Starkvind supports 9 fan speeds. Because 9 doesn't neatly fit into 100% I cheated a bit and divided the 100% into 10% increments, where trying to set the fan to 10% sets it to 20% instead. I believe that this gives the overall better user experience compared to having 11.11% increments. The 5 speed modes present on the physical interface of the device correspond to HA speed settings 20%, 40%, 60% and 100%. This patch depends on zigpy/zha-device-handlers#3088 being merged and released.
Alternatively it would also be possible to convert neither |
Any update on the review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the long wait. The quirk part should be good-to-go IMO.
Also thanks for adding tests!
(In the future, the quirk should be updated to use new-style zigpy AttributeDefs
though)
…posed Fixes home-assistant#97440 Previously starkvind exposed 10 speed settings and no modes, where 10% corresponded to auto mode and 20%-100% corresponded to fixed speeds. This patch correctly exposes auto mode as a mode. It also adds support for showing the actual fan speed while auto mode is enabled. Starkvind supports 9 fan speeds. Because 9 doesn't neatly fit into 100% I cheated a bit and divided the 100% into 10% increments, where trying to set the fan to 10% sets it to 20% instead. I believe that this gives the overall better user experience compared to having 11.11% increments. The 5 speed modes present on the physical interface of the device correspond to HA speed settings 20%, 40%, 60% and 100%. This patch depends on zigpy/zha-device-handlers#3088 being merged and released.
Proposed change
IKEA Starkvind has two similar attributes:
fan_mode
andfan_speed
.fan_mode
can take a value from 0-50 where 0 is off, 1 is auto and 10-50 are manual speed modes.fan_speed
can take a number from 10-50 or 0, where 0 is off and 10-50 is the fan speed.fan_speed
is read-only.If
fan_mode
is set to a manual mode that is not a multiple of 5 it is rounded to a multiple of 5, which can be seen by reading thefan_speed
attribute. For this reason The current quirk scales that 10-50 range to a 2-10 range, eliminating the undefined and duplicate (rounded) values.This patch applies the same downscaling to the
fan_speed
attribute, restoring the correspondence betweenfan_mode
andfan_speed
values.Native values: Set
fan_mode
to 30 =>fan_speed
reads 30Current state: Set
fan_mode
to 6 =>fan_speed
reads 30With patch: Set
fan_mode
to 6 =>fan_speed
reads 6Additional information
This will be followed up by a PR in home-assistant to eventually fix home-assistant/core#97440.
Because home-assistant currently only uses the
fan_mode
and not thefan_speed
attribute this does not depend on the corresponding home-assistant PR. Only the other way around.I also changed the
<
and>
to<=
and>=
to improve understandability of the code by mentioning the limit values and replaced/
with//
to prevent introducing floating point values.Checklist
pre-commit
checks pass / the code has been formatted using Black