stefan-kaestle / openhab2-addons

Add-ons for openHAB 2.x
Eclipse Public License 2.0
16 stars 1 forks source link

Use Units Of Measurement, avoid Units.ONE #72

Closed GerdZanker closed 3 years ago

GerdZanker commented 3 years ago

I recommend to use always the Units Of Measurement to benefit from the conversion support.

The binding code uses the units already for all temperatures from my point of view. But for the Twinguard air purity and humidity no unit is used therefore the conversion is sometimes strange, e.g. to format the humidity as "%" doesn't work.

So instead of

    updateState(CHANNEL_HUMIDITY, new QuantityType<Dimensionless>(state.humidity, Units.ONE));
    updateState(CHANNEL_PURITY, new QuantityType<Dimensionless>(state.purity, Units.ONE));

it should be

    updateState(CHANNEL_HUMIDITY, new QuantityType<Dimensionless>(state.humidity, Units.PERCENT));
    updateState(CHANNEL_PURITY, new QuantityType<Dimensionless>(state.purity, Units.PARTS_PER_MILLION));

and Units.ONE should never be used anymore.

coeing commented 3 years ago

Sure, having a type there is always better than the dimensionless fallback. Do you have an official source where the dimensions of the data is defined by Bosch? I have not found one yet.

GerdZanker commented 3 years ago

I just compared the logged DEBUG output with the values and units in Bosch Smart Home App.

coeing commented 3 years ago

I just compared the logged DEBUG output with the values and units in Bosch Smart Home App.

Smart! :) Will check your pull request immediately.

GerdZanker commented 3 years ago

PR #73 improves this issues