-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[mqtt.homeassistant] Fix multi-speed fans #17813
Conversation
* fix step math so that the state description represents the step scaled to 0-100% * introduce a format override to PercentageValue - Home Assistant expects integers in several places. for a true percentage, most devices were accepting a floating point just fine, but if there's a device (like a 3-speed fan) that has a command template that translates the speeds to some other string value, and uses a lookup to do that, it's important that the value we send to that template is an integer * fix that the value template for fan state is state_value_template, not value_template like almost everything else Signed-off-by: Cody Cutrer <cody@cutrer.us>
@openhab/core-maintainers: is there any guidance on the preferred way to model a multi-speed fan (with discrete speeds between 0 and some number less than 100 - usually, between 2 and 10)? I see four options:
The latter two have a little bit of precedent when dealing with a light bulb that supports dimming (or color) and color temperature. My experience with those things is it can be very inconsistent if the color temperature channel goes to NULL or UNDEF when the light is OFF, or if it stays at its previous value (and what it would return to if it turns back on). It's also inconsistent if sending a command to the color temperature channel will turn the bulb on if it's currently off. In a slightly different way, there is precedent with color temperature to model as a Dimmer and a Number. So... thoughts? All of these questions could probably use some explanation and reasoning in the FAQ at https://www.openhab.org/docs/developer/addons/faq.html#modelling-channels. |
@lsiepel : regardless of any responses to my above questions, I think this PR is ready for review - it maintains the current modeling, while fixing issues with some fans. |
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.
Thanks, LGTM.
Created a new issue to not loose your question.
* fix step math so that the state description represents the step scaled to 0-100% Signed-off-by: Cody Cutrer <cody@cutrer.us>
* fix step math so that the state description represents the step scaled to 0-100% Signed-off-by: Cody Cutrer <cody@cutrer.us> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
The original implementation for a fan with speeds was written without an actual device, and just guessing from Home Assistant's limited documentation. Now I actually have a 3-speed fan, and I can see how it's expecting to behave. In short, "percentage" is actually "speed", and it just defaults to a range of 0-100, but if it advertises as say 0-3, it actually wants 0-3, not 0, 33, 66, and 100.