org.openhab.binding.zigbee icon indicating copy to clipboard operation
org.openhab.binding.zigbee copied to clipboard

Add missing UoMs

Open giannello opened this issue 5 years ago • 21 comments

Add missing item-type qualification for illuminance and humidity

giannello avatar Aug 07 '20 12:08 giannello

Thanks. Have you tested these changes and you confirm it works? I'm not completely sure that humidity is dimensionless either - it's a percentage so probably should be a PercentType don't you think?.

cdjackson avatar Aug 07 '20 13:08 cdjackson

Tested it on my setup, works fine.

As far as I understand, PercentType is not a valid Item type (https://www.openhab.org/docs/concepts/items.html#items), so in this context using Number:Dimensionless and hardcoding the unit to % is the right approach. Maybe @kaikreuzer can confirm.

giannello avatar Aug 11 '20 18:08 giannello

As far as I understand, PercentType is not a valid Item type

I think you are getting mixed up. Remember, bindings know nothing about items - we only care about States and PercentType is of course valid - as per the reference you provided.

Relative humidity is defined in percentage - I think this should be therefore a PercentType given it is a percentage, but maybe there's a better option?

cdjackson avatar Aug 11 '20 22:08 cdjackson

Remember, bindings know nothing about items - we only care about States and PercentType is of course valid - as per the reference you provided.

Yet the xml entry is called item-type.

Relative humidity is defined in percentage - I think this should be therefore a PercentType given it is a percentage, but maybe there's a better option?

Absolutely willing to go with the best option, but I see similar configuration also in other bindings (https://github.com/openhab/openhab-addons/blob/2.5.x/bundles/org.openhab.binding.openweathermap/src/main/resources/ESH-INF/thing/channel-types.xml#L232).

Let's wait for external help, I'll try PercentType locally in the meantime.

giannello avatar Aug 12 '20 07:08 giannello

Yes, I was getting at the states that the binding uses - the two are obviously linked 👍

Really this should be a system channel so that everyone does the same thing rather than choosing a random binding to align with.

I'm a bit loath to change just for the sake of it - the best option really would be to have a "full set" of common system channels so that everyone is 100% aligned.

cdjackson avatar Aug 12 '20 08:08 cdjackson

Anyway, I see the other point now - the Converters should be updated too, I'm currently testing a change. Don't merge yet.

giannello avatar Aug 12 '20 10:08 giannello

Ok, but I don't want to randomly change this. Currently this will work fine and I don't really see the need to just change this.

What is the actual problem? If I search through the Addons repo, there is a split of different channel configrations for humidity and I would suggest that we should make a system channel, and change this once - not twice.

I should say - I'm happy enough with illuminance - that's clearer.

cdjackson avatar Aug 12 '20 10:08 cdjackson

I see - I will remove the changes to RH and wait for a better implementation, then.

giannello avatar Aug 12 '20 11:08 giannello

Rebased, found and fixed a few channels that were not correctly initialized.

giannello avatar Aug 17 '20 12:08 giannello

Did these changes require you to redefine your items to the new type?

cdjackson avatar Aug 18 '20 16:08 cdjackson

Did these changes require you to redefine your items to the new type?

The channels need to be re-discovered, in order to show the new type. I don't have any manually-defined item.

The Things linked to those channels will keep on working without changes (and without UoM) until their type is properly defined, due to automagic conversion.

giannello avatar Aug 20 '20 18:08 giannello

Thanks. That's what I thought. I think we should park this for now and possibly add it in the OH3 branch which should be coming soon. Otherwise we break everyones system and require them to rediscover everything.

cdjackson avatar Aug 20 '20 18:08 cdjackson

Fine for me.

On a side note, I've checked multiple bindings dealing with humidity, and all of them are using Number:Dimensionless with a fixed % unit, so I guess until something major changes, that's the way to define relative humidity :)

giannello avatar Aug 20 '20 18:08 giannello

Thanks. Yes, I also did a search so I concur. I still think it would be good to add this to system channels so I might look at that for OH3.

cdjackson avatar Aug 20 '20 19:08 cdjackson

@giannello I've rebased this as we discussed a while back, and we now have some merge conflicts. Please can you take a look and update accordingly. Thanks.

cdjackson avatar Oct 03 '20 18:10 cdjackson

There is actually a system channel for humidity in percentage: https://www.openhab.org/docs/developer/bindings/thing-xml.html#system-state-channel-types system.atmospheric-humidity

Hilbrand avatar Jan 02 '21 22:01 Hilbrand

Hi all, what is needed to finish this out? I also have a local commit changing relative humidity to Number:Dimensionless, but figure we should merge this instead. I can chase down conflicts as long as we all agree on the path forward.

Should we maintain our own channel type for humidity and just change the definition (and converter) to use Number:Dimensionless, or adopt the system.atmospheric-humidity type? I anticipate there could be some debate over whether "indoor relative humidity" is the same as "atmospheric humidity".

lucasec avatar Jun 05 '22 19:06 lucasec

I don't think it needs any major changes - just rebasing and resolving issues. The big problem is this will break everyones system which is less nice.

If we're going to break everything, we might as well use the system channel for humidity. Humidity is humidity - indoors and outdoors so there shouldn't be different channel types.

cdjackson avatar Jun 05 '22 20:06 cdjackson

Oddly, there is a system type for temperature but it explicitly says "Outdoor Temperature". That's where my concern was rooted. Otherwise I would say wholesale we should adopt those types across the board including for temperature.

lucasec avatar Jun 06 '22 00:06 lucasec

IMHO "channel types" should be abstract enough to be reusable - so "temperature" is a channel type. The "channel" can then be of type "temperature", and called "indoor temperature" or "outdoor temperature" - or "water temperature" - who knows. We shouldn't have types for every possible place someone might want to measure a temperature...

Anyway, that's a core problem. I added the ability to customise type labels a long time ago (in ESH) for the Zigbee and ZWave bindings to provide this separation between channel types and the actual channels, but I guess this is not being used.

For Zigbee I prefer not to stick with generic types. I don't care too much about the label being used in the type as that can be customised in the channel definition.

cdjackson avatar Jun 06 '22 00:06 cdjackson

I opened a new PR in https://github.com/openhab/org.openhab.binding.zigbee/pull/765.

For now I pushed up the humidity channel as I have it currently implemented, but we can continue discussion there/change as necessary.

lucasec avatar Jun 06 '22 05:06 lucasec