home-assistant / homebridge-homeassistant

DEPRECATED in favor of native HomeKit support. -  Homebridge plugin for Home Assistant
https://www.home-assistant.io/components/homekit/
Other
683 stars 144 forks source link

Support for F temperature defaults #222

Closed faspina closed 6 years ago

faspina commented 7 years ago

My temps are being converted as if they are default to C , in other words the temperature in HomeKit shows as 162. There was a another thread on this I was wondering if it could be fixed.

Hackashaq666 commented 7 years ago

same issue here

danielwelch commented 7 years ago

I've been having this same problem ever since using the homebridge addon, and in the interest of moving this along I took a shot at it. As a disclaimer, I knew nothing about the homebridge or HAP-NodeJS library internals until like an hour ago, so could be off base.

First, it seems that this is a problem with displaying the temperatures within iOS. For example, when i set the temperature to 165 degrees F in HomeKit, my thermostat is (appropriately?) set to 74 degrees F.

Digging around the HAP-NodeJS library, I came across this comment which mentions that the HomeKit Protocol deals only in Celsius, and relies on the iOS-side application to convert temperatures to Fahrenheit. I'm suspecting the temperature is being sent to HomeKit (in my case, the current temperature of 74 is sent) along with the Characteristic.TemperatureDisplayUnits.FAHRENHEIT, which then converts the 74 to 165. Same for minTemp/maxTemp.

If this is what's actually causing the problem, it seems like the following could work:

  1. check if the Home Assistant data uses Fahrenheit (as is done currently here)
  2. if so, convert the temperatures obtained from Home Assistant (state attributes current_temperature, min_temp, max_temp) from Fahrenheit to Celsius
  3. set Characteristic.TemperatureDisplayUnits.FAHRENHEIT on the ThermostatService. I assume this tells the iOS frontend to convert the numbers to Fahrenheit.

Any thoughts? Or am I totally off?

AmpacheUser commented 7 years ago

Having this issue as well with a Radio Thermostat.

robbiet480 commented 6 years ago

Fixed via #231