openhab / openhab-addons

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

[hydrawise] Temperature not converting properly to Imperial Units #16824

Open ajaysanan opened 1 month ago

ajaysanan commented 1 month ago

I have the Hydrawise app set to utilize "Fahrenheit & Inches" and am using similar Imperial units in OpenHab. It looks like the binding should correctly follow UoM but it doesn't for the temperature. Instead, it reports all temperatures far too high (Fahrenheit converted to Fahrenheit). For example, the forecast high temperature is listed as 202.9999999 F.

Expected Behavior

Current Behavior

The DEBUG log shows the following transformation:

2024-05-30 21:14:32.891 [DEBUG] [l.handler.HydrawiseControllerHandler] - TEMP forecast1 temperaturehigh °F 94.99999999999994 2024-05-30 21:14:32.892 [DEBUG] [l.handler.HydrawiseControllerHandler] - updateState updating hydrawise:controller:hydrawiseaccount:66402:forecast1#temperaturehigh 94.99999999999994 °C

If I change the Hydrawise app to "Celsius and mm" everything behaves correctly. The Celsius temperature is then converted correctly to Fahrenheit.

Possible Solution

Just learning java but is there one extra backslash causing it to always set it as Celsuis?

https://github.com/openhab/openhab-addons/blob/5a73c99b170b3725a01b14fb93518ef9d081e636/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/handler/HydrawiseControllerHandler.java#L384-L388

Steps to Reproduce (for Bugs)

Context

Your Environment

OpenHAB 4.1.2 running on Windows Server

digitaldan commented 1 month ago

Hi, i'll take a look at this over the weekend, but i agree it looks like i might of fat fingered an extra backslash in there. ;-)

ajaysanan commented 1 month ago

Thanks. Is there any particular reason the temperature.unit has to be explicitly set while other measures like the volume (flow meter) isn't? Now that I look at it, the flow numbers are also wrong. That app shows flow as 3920 gallons for the week. The log when the app units are set to imperial shows:

2024-05-30 21:14:32.885 [DEBUG] [l.handler.HydrawiseControllerHandler] - updateState updating hydrawise:controller:hydrawiseaccount:66402:sensor1#waterflow 3924.2758211933506 l

When I change to metric it reads 14855 l, which is correct. When set to Imperial, it is changing the number to gallons but leaving the unit as liters. The wind speed is correctly reporting as mph or kph. I can't comment on the precipitation because it just reports as 0.0 with no units.

digitaldan commented 2 weeks ago

I never tested that (just blindly implemented it) since its not something i monitor. Its likely its an oversight on my part with how UoM works in openHAB. I'm hoping to have some time next week to fix this and a few other issues in the binding.