openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.9k stars 3.59k forks source link

[mqtt.homie] Autodetect °F and °C unit, and provide a QuantityType #8076

Closed ccutrer closed 2 years ago

ccutrer commented 4 years ago

If a Homie property contains a $unit attribute of °C or °F, OpenHAB should detect this and create a channel that provides a QuantityType with the proper temperature unit attached. This will allow OpenHAB to automatically convert say a provided C unit to F if OpenHAB is configured to use F generally. Note that Homie 3.0.0 doesn't explicitly list °C as a recommended unit, but does have it as an example. Homie 4.0.0 (which the binding says "3.0.0 or better") does explicitly list °C as a recommended unit (and I have several devices that provide °F, and one that provides °C).

Your Environment

ccutrer commented 2 years ago

I believe this is fixed by #10727; testing....

ccutrer commented 2 years ago

Woohoo! It does! I have an Item:

Number:Temperature PrimaryWaterHeater_OutletWaterTemp "Primary Water Heater Outlet Water [%.1f °F]" <temperature_hot> (gPrimaryWaterHeater, gInflux) { channel="mqtt:homie300:mosquitto:waterheater:abc#current_2Dtemperature", expire="60s", alexa="CurrentTemperature" }

in MQTT its value is 40.5, with a $unit of °C. In OpenHAB its state is coming through as 123.575 °F!!