openhab-google-assistant icon indicating copy to clipboard operation
openhab-google-assistant copied to clipboard

Humidity metadata should automatically detect if humidity item's range 0-1 or 0-100 (or make it configurable)

Open Flowdalic opened this issue 1 year ago • 18 comments

Homematic thermostats in OpenHAB report the humidity in the range between 0 and 1 (I am sure this is true for other humidity sensors as well). To expose it via openhab-google-assistant, I need to create another item that maps the value between 0 and 1, to an integer between 0 and 100. Otherwise, Google Home constantly displays a humidity of 1%.

It would be great if I did not had to duplicate the item just for openhab-google-assistant, and if it would instead automatically determine if humidity is reported between 0 and 1 and map this value accordingly. If an automatism isn't feasible, then it should be at least made configurable.

Flowdalic avatar May 25 '24 18:05 Flowdalic

Hi, thanks for raising that. I would assume that this is a rather easy thing to implement, if we would just assume any number between 0-1 is not an actual percentage but needs conversion. Otherwise, we would allow edge case to create false representations. So a configuration option would be the safe solution to go for. Also that should be implemented rather easy. I will put it on the list. :)

michikrug avatar May 27 '24 20:05 michikrug

I guess this would solve your issue: https://github.com/openhab/openhab-google-assistant/pull/405/commits/d3031224dbc9df5281f1985679a16f8c65d3e5e4

michikrug avatar May 28 '24 22:05 michikrug

Thanks 👍

Does setting the option to 'float' automatically imply a range from 0 to 1? If so, the this should be clearly stated, because it could also mean that values like 41.76 are also supported. Maybe change the option name to "float (range 0-1)". Would we also need an option "float (range 0-100)"?

Flowdalic avatar May 29 '24 06:05 Flowdalic

Actually it does not matter what you write in there if it is just different from "percent" to trigger the transformation 🙄😅

What could be a proper value/name?

michikrug avatar May 29 '24 18:05 michikrug

I would like to keep the config as short as possible, but still meaningful. So float is short but not explicit enough.

In general, all numbers are supported but rounded as Google wants it like that. So also with percent a floating point would be fine.

michikrug avatar May 29 '24 18:05 michikrug

I just had another idea. Maybe just let the user define the maximum and calculate the rest.

E.g. humidityMaxValue:1 or default 100

It would be always assumed that the target value will be between 0 and 100 and calculated accordingly

Thoughts?

michikrug avatar May 29 '24 18:05 michikrug

Ultimately, I wonder if this needs a setting at all, or if it could be automatic instead. If the value has a dot, then it's a float. If the value is below 1 then it's range is between 0 and 1.

Flowdalic avatar May 29 '24 20:05 Flowdalic

Changed to configuration option to maxHumidity defaulting to 100

In your case you should set this to 1

It is already included in the latest v4 release, so you should be able to test this rightaway

michikrug avatar May 31 '24 19:05 michikrug

Changed to configuration option to maxHumidity defaulting to 100

Thanks for your work on openhab-google-assistant. If I understand correctly, then this setting would fix the issue I reported.

However, I am curious, why have this setting at all and not automatically scale values correctly? If the value is <= 1 then multiply it by 100 to get the value in the range between 1 and 100. It is usually beneficial towards UX if a setting can be avoided.

Flowdalic avatar Jun 01 '24 16:06 Flowdalic

Sure that would work, but what if there is actually a humidity of 1% reported. Then this logic would report 100%, which is not correct.

michikrug avatar Jun 01 '24 17:06 michikrug

While a relative humidity of 1% is possible, it is hardly common. Therefore, I doubt that this would be a real problem in practice. And the option to select the range could still be provided, if it is really needed. However, it would work for most users out of the box.

Flowdalic avatar Jun 01 '24 21:06 Flowdalic

Is this already integrated in the stable release?

Homematic thermostats in OpenHAB report the humidity in the range between 0 and 1 (I am sure this is true for other humidity sensors as well). To expose it via openhab-google-assistant, I need to create another item that maps the value between 0 and 1, to an integer between 0 and 100. Otherwise, Google Home constantly displays a humidity of 1%.

It would be great if I did not had to duplicate the item just for openhab-google-assistant, and if it would instead automatically determine if humidity is reported between 0 and 1 and map this value accordingly. If an automatism isn't feasible, then it should be at least made configurable.

How does your current "solution" look like? I have the same issue with another humidity sensor, how did you configure the "mapping"-item?

juju1337 avatar Jun 05 '24 13:06 juju1337

Is this already integrated in the stable release?

Yes, was rolled out with the v4 release last Friday

michikrug avatar Jun 05 '24 16:06 michikrug

Where should the percent/float config be available? In the item config? Or GA Metadata? If yes, only for Thermostat or also for Humidity Sensor? I can't see it (yet?), after updating my installation to 4.1.3 (in docker).

juju1337 avatar Jun 05 '24 19:06 juju1337

It's available for all devices with a humidity value.

As for any config related the the GA integration this goes into metadata.

The integration is not at all part of the openHAB software itself. So updating it will not influence anything related to this integration. It's completely standalone.

For the new configuration options you need to enter the metadata manually using the code tab.

There has not been an update made for the UI configuration part.

michikrug avatar Jun 05 '24 20:06 michikrug

Ok, so I have an item linked to a channel of my humidity sensor, showing me a value from 0...1 in OpenHAB UI. I now add GA metadata to this item (e.g. GA Humidity Sensor). How does the (initially empty) config{} section have to look like to map it to 0..100% for GA?

juju1337 avatar Jun 05 '24 20:06 juju1337

config:
 maxHumidity: 1

michikrug avatar Jun 06 '24 05:06 michikrug

Works like a charm, thx!

juju1337 avatar Jun 06 '24 06:06 juju1337