metbosch / homebridge-http-temperature

HomeBridge HomeKit Plugin for HTTP temperature endpoints
https://www.npmjs.com/package/homebridge-http-temperature
Apache License 2.0
33 stars 18 forks source link

Fahrenheit -> Celsius conversion #15

Closed tekdoc closed 6 years ago

tekdoc commented 6 years ago

My thermometer reports temperature data in Fahrenheit and temperature units on my iPhone are set to degrees Fahrenheit. Apparently homekit expects values in Celsius which results in for example, 68 degrees being displayed as 154.

It would be helpful to have a configuration option in the plugin for temperature units. If units are set to Fahrenheit, convert to Celsius before sending to homekit.

metbosch commented 6 years ago

@tekdoc This was previously mentioned in other issues but never implemented. If I upload the code in a new branch, could you test it? I have all may ecosystem working in Celsius.

metbosch commented 6 years ago

@tekdoc See branch https://github.com/metbosch/homebridge-http-temperature/tree/fix/15

tekdoc commented 6 years ago

Yes, it is working:

[12/11/2017, 7:55:00 PM] [Outside Temperature] Call to getState: waiting_response is "false" [12/11/2017, 7:55:00 PM] [Outside Temperature] Requesting temperature on "http://xxxxxxx.xxxxxx.xx/current_temp.php", method GET [12/11/2017, 7:55:00 PM] [Outside Temperature] HTTP successful response: 49 [12/11/2017, 7:55:00 PM] [Outside Temperature] Converted Fahrenheit temperature to celsius: 9.444444444444445

Thank you for your work on this plugin!

metbosch commented 6 years ago

Thanks for the info @tekdoc. I will test the new version on my installation which uses Celsius and update the npm publish version.