-
-
Notifications
You must be signed in to change notification settings - Fork 456
Description
To create a percent-item with a binding, the item has to be either Dimmer or Number:Dimensionless. The default unit of Number:Dimensionless is one. For file-based items (loaded from etc/openhab/items/.items file) without label, to render the label as percent, it is not sufficient to define the channel-type as <item-type unitHint="%"> and use {channel="…"}, in addition unit="%" must be set when the item is defined in text file. This mandatory unit="%" can be avoided by using Dimmer instead of Number:Dimensionless. The other way to avoid entering unit="%" on the item definition, is to define the channel type with <state readOnly="true" pattern="%d %%"/>. But then (theItem.state as QuantityType).getUnit().toString() still prints one, so it is illusion that this is in % unit. To have it hassle-free for the binding’s user for me it looks like the binding must always - in MainUI and documentation - suggest to use item type Dimmer, when the meaning is percent.
Active and apparent power are easy to misunderstand. For a channel-type with <item-type unitHint="VA">Number:Power</item-type>, when linked to a Number:Power item in a text file in its simplest form Number:Power item2 { channel="…" }, the item is rendered as (its label ends with) Watt.
In both cases with Watt and per cent, the default units hinted by the binding/channel type, would make sense for the user, if they are inherited by the items. The users really want to have there as unit VA, even if they do not understand that, in this concrete case as a matter of exception of how other items are defined in text files, unit="VA" must be used, but was not used, and even if the users do not understand yet what is the difference between apparent and active power.
Likewise, if a channel-type has a category, this channel-type is linked to an item, and the item does not define any category, the item should inherit the category (icon), instead of using default icons (e.g. for switch). This saves typing work to define a category in an item file, where both binding-author and binding-user would have agree on the same category.
This is much like the useTags - inheritance should happen only for the first linked channel.
- When a channel-type defines
unitHint="…"orcategoryand this channel-type is linked to an item, which does not define aunit="…"or an icon, then the item should inherit the unit and category from the channel-type.