-
-
Notifications
You must be signed in to change notification settings - Fork 428
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 UnitUtils.shouldUseUnitHint #4478
Comments
I am not a core maintenance but IMHO they are correct guidelines. I would just add one another: set unitHint when you know the default unit can't be the best choice for a particular channel. And this is something that cannot be determined by a generic method. |
Example: |
Looking through https://www.openhab.org/docs/concepts/units-of-measurement.html again, it feels like for a lot of dimensions a unitHint might well be useful, but only within the same system. I.e. for a Length, if the device is providing units in ft, and the current unit system is in imperial, the unitHint is still useful because the magnitude of the unit is very important, instead of the default of in. But if openHAB is in metric, neither ft nor in is useful, so all bets are off. So... maybe this additional guideline--which only works for dynamically channels-- if the proposed unit is in the same measurement system as openHAB's system settings, always use that as the unitHint. If it's not, then don't propose a unitHint at all. But perhaps this suggests either core or MainUI should be applying that logic across all channels when creating items, then it would work for static channel definitions as well. |
A |
I've been adding
unitHint
to several of my bindings. First I did mqtt.homie, which just does a straight "if the upstream system provided a unit, then use that as the unitHint." Now I've been adding to several other channels in mqtt.homeassistant which are more well-defined, and I've realized that a binding actually shouldn't provide aunitHint
in most scenarios. So, correct me if I'm wrong here:one
is never useful)Assuming these are the correct guidelines in the first place, I suggest codifying it in
UnitUtils
so that bindings that present dynamic channels (basically anything that bridges from another ecosystem - mqtt, zwave, etc.) can automatically determine if the channel they create should present a unit hint, instead of always forcing the device's units on the user.I opened as an issue to get confirmation from @openhab/core-maintainers that this seems reasonable before I simply go and write this method myself.
The text was updated successfully, but these errors were encountered: