steilerDev / homebridge-openhab2-complete

A homebridge plugin for openHAB, that has the expectation to fully support all Services offered by Apple's Homekit Accessory Protocol (HAP)
GNU General Public License v3.0
52 stars 16 forks source link

Temp Sensor reports in Fahrenheit but is treated like Celsius #35

Closed torpex77 closed 4 years ago

torpex77 commented 4 years ago

Fahrenheit temperatures reported by my temperature sensors are incorrect in the Home App.

I have a temperature sensor in openhab. It reports in degrees Fahrenheit. My phone Temperature Unit is set to Fahrenheit as well. However, the value displayed in the Home App is significantly incorrect.

For example, the sensor is reporting it's 83.4 in my garage. The Home App is telling me it's 182.

I think that HomeKit expects to receive temperature readings in Celsius, but instead the raw number is being sent over. Which the Home App then converts the number it assumes is Celsius into Fahrenheit. (83.4°C × 9/5) + 32 = 182.12°F

My Sensor in OpenHab: Number Garage_TriSensor_2_Temperature

My homebridge config:

{
  "name": "Garage_TriSensor_2_Temperature",
  "item": "Garage_TriSensor_2_Temperature"
}

The homebridge log file:

[7/20/2019, 10:19:39 AM] [openHAB2-Complete] Recognized number with potential unit (83.40), extracting only the number: 83.40
[7/20/2019, 10:19:39 AM] [openHAB2-Complete] Caching value 83.40 for Garage_TriSensor_2_Temperature
[7/20/2019, 10:19:39 AM] [openHAB2-Complete] Received new state for item Garage_TriSensor_2_Temperature: 83.40
[7/20/2019, 10:19:39 AM] [openHAB2-Complete] Received push with new state for item Garage_TriSensor_2_Temperature: 83.40
[7/20/2019, 10:19:39 AM] [openHAB2-Complete] Setting new transformed state for item Garage_TriSensor_2_Temperature: 83.4

My workaround is to create another item in OpenHab, then set up a rule to update it with degrees Celsius when my real sensor changes. But it would be nice if the TempSensor supported and converted Fahrenheit degrees.

Thanks,

Doug

torpex77 commented 4 years ago

I left out part of my homebridge config:

        {
          "type": "temp",
          "items": [
            {
              "name": "Garage_TriSensor_2_Temperature",
              "item": "Garage_TriSensor_2_Temperature"
            }
          ]
        }
steilerDev commented 4 years ago

I just implemented a potential fix for this (wasn't able to test it locally since I am currently traveling). Feel free to test the latest commit (b10ac33 ) on this.

Note: The Configuration syntax for 'temp' changed slightly.

steilerDev commented 4 years ago

P.S.: You have to now specify your 'tempUnit' as "Fahrenheit" inside the configuration, the default is still Celsius.