HomeKit Temperature "conversion"

I’ve had a pool sensor for some years, and it has worked fine on my frontend showing the correct temperature in degrees celsius. Setup is:


  - platform: mqtt
    state_topic: "pool/temperature"
    name: "Swimming Pool Temperature"
    unit_of_measurement: "°C"
    device_class: temperature

I’ve recently integrated with HomeKit.


  unit_system: metric

      - sensor.swimming_pool_temperature
      name: Pool Temperature

HomeKit displays the same (correct) temperature, without any unit (I’ve done further research - it seems like HomeKit never shows a unit):


When i ask Siri “what is the pool temperature” it replies “its -6 degrees celsius”

In other words, it thinks the temp coming from hass is “farenheit”, knows my iOS setting is for celsius, and converts 23F to -6C!

I have tried the following values for unit_of_measurement, none work (some are the same as above, some result in 0.0 on HomeKit):

  • celsius
  • Celsius
  • “celsius”
  • “Celsius”
  • “°C”
  • °C


I turned on debugging and here is some selected logs:

2019-09-25 11:18:19 DEBUG (MainThread) [homeassistant.components.homekit] Begin setup HomeKit
2019-09-25 11:18:21 DEBUG (SyncWorker_3) [pyhap.characteristic] set_value: Name to Home Assistant Bridge
2019-09-25 11:18:21 DEBUG (SyncWorker_3) [pyhap.characteristic] set_value: SerialNumber to default
2019-09-25 11:18:21 DEBUG (SyncWorker_3) [pyhap.characteristic] set_value: FirmwareRevision to 0.91.3
2019-09-25 11:18:21 DEBUG (SyncWorker_3) [pyhap.characteristic] set_value: Manufacturer to Home Assistant
2019-09-25 11:18:21 DEBUG (SyncWorker_3) [pyhap.characteristic] set_value: Model to Bridge
2019-09-25 11:18:21 DEBUG (SyncWorker_3) [pyhap.characteristic] set_value: SerialNumber to homekit.bridge
2019-09-25 11:18:25 DEBUG (SyncWorker_13) [homeassistant.components.homekit] Add "sensor.swimming_pool_temperature" as "TemperatureSensor"
2019-09-25 11:18:25 DEBUG (SyncWorker_13) [pyhap.characteristic] set_value: Name to Pool Temperature
2019-09-25 11:18:25 DEBUG (SyncWorker_13) [pyhap.characteristic] set_value: SerialNumber to default
2019-09-25 11:18:25 DEBUG (SyncWorker_13) [pyhap.characteristic] set_value: FirmwareRevision to 0.91.3
2019-09-25 11:18:25 DEBUG (SyncWorker_13) [pyhap.characteristic] set_value: Manufacturer to Home Assistant
2019-09-25 11:18:25 DEBUG (SyncWorker_13) [pyhap.characteristic] set_value: Model to Sensor
2019-09-25 11:18:25 DEBUG (SyncWorker_13) [pyhap.characteristic] set_value: SerialNumber to sensor.swimming_pool_temperature
2019-09-25 11:18:25 DEBUG (SyncWorker_13) [homeassistant.components.homekit] Driver start
2019-09-25 11:18:26 DEBUG (MainThread) [homeassistant.components.homekit.accessories] New_state: <state sensor.swimming_pool_temperature=23.1; unit_of_measurement=°C, friendly_name=Swimming Pool Temperature, device_class=temperature @ 2019-09-25T21:18:23.498451+10:00>
2019-09-25 11:18:26 DEBUG (SyncWorker_12) [pyhap.characteristic] set_value: CurrentTemperature to 23.0
2019-09-25 11:18:26 DEBUG (SyncWorker_12) [homeassistant.components.homekit.type_sensors] sensor.swimming_pool_temperature: Current temperature set to 23°C


When I change my iOS device settings temperature unit to Farenheit, HomeKit displays the correct value in Farenheit (73.0) BUT when you ask Siri what the temperature is it reports “23 degrees farenheit” so it does the same conversion!

Internal HomeKit storage is in celsius, and is correctly set by Hass and we see correct unit conversion in iOS, its only Siri that gets it wrong when you ask to report the value from HomeKit…

My conclusion is that in fact this may be a bug in Siri, and Hass and HomeKit are both doing things correctly.

Can anyone help? Has anyone ever had this work correctly (or not)?

What I can tell you is that I have several different type of temp sensors exposed to HomeKit and they work fine in Celsius. Siri also announces the correct value in Celsius. It might be some glitch with the mqtt temp sensor integration. I am just guessing. You may try to create a template sensor from the value and expose the template sensor into HomeKit instead of your pool sensor.

Thanks Peter. That’s very helpful. I’ll give it a try.

FWIW, every device I have is configured as an MQTT-based entity in Home Assistant (cover, lock, sensor, binary_sensor, light, switch, etc). I just asked Siri to report the indoor temperature (derived from the thermostat) and she said “It’s twenty-one degrees Celsius.”

As for the thermostat widget, I see it showing the current temperature as 21.0° without the C.

Thanks - do you mind posting your settings for these MQTT based devices? eg. what value to doyu have for unit_of_measurement and device_class?

It’s getting the indoor temperature from the climate component (MQTT HVAC) which doesn’t contain device_class or unit_of_measurement.

The only relevant setting I’m using is the system-wide unit_system which is set to metric.

  unit_system: metric

That’s it. :man_shrugging:

fezfox, I have the exact same problem. Did you manage a way to fix it?

p.s. It was functioning very well on IOS 12.4.1… After the upgrade for 13.0, and 13.1… the nightmares begin


I also have the same problems with the MQTT temperature sensor and xiaomi temperature sensors and i can confirm that this is happening after upgrading to IOS13.0 and 13.1.

The roomthermostat based on OTGW is reporting the correct value trough siri.

I have the impression that homekit overall preformance seems to be worser since > IOS13.

That may very well be the source of the issue because I’m still using 12.4.


I have searching in the code because I found the same issue …

Homekit for temperature sensors in celsius is using:

def temperature_to_homekit(temperature, unit):
    """Convert temperature to Celsius for HomeKit."""
    return round(temp_util.convert(temperature, unit, TEMP_CELSIUS) * 2) / 2

(From components/homekit/util.py)

So the problem is that is forcing a round with 0 decimals (by default, round uses 0 decimals), this should round with one decimal digit:

def temperature_to_homekit(temperature, unit):
    """Convert temperature to Celsius for HomeKit."""
    return round(temp_util.convert(temperature, unit, TEMP_CELSIUS) * 2, 1) / 2

I don’t understand. How is rounding responsible for Siri reporting the value in Fahrenheit? The stated problem is that Siri reports 23 C as -6.

I don’t think the rounding is the issue (though, it is worth pushing a change, since homekit supports 1/10th of degree, and that is rounding to half a degree).

My summary is

  1. hass is sending the correct value in celsius to homekit, and that is the correct unit to use as homekit stores all data internally as celsius
  2. homekit displays the value correctly, and converts it correctly if I alter my ios settings to (say) imperial units - ie. homekit interprets the stored value as celsius (again correctly)
  3. the only issue is siri, which seems to get the data from homekit and do its own conversion to celsius, thinking the stored value passed to siri from homekit is farenheit

So I think its a siri bug… unless anyone else thinks otherwise. We could report it to apple… but that’s like shouting outside the gates of mordor. :roll_eyes:

Today I tested the change that I proposed and now temperature sensors are showed with 1 decimal in HomeKit:

(from a MQTT temperature sensor from HA -tasmota-)

This is the PR: https://github.com/home-assistant/home-assistant/pull/27047

For the issue from @fezfox with Siri telling the temperature with “-6”, I have the same issue but I don’t have a solution yet:

@jgon Nice work. Don’t you think it should be

return round(temp_util.convert(temperature, unit, TEMP_CELSIUS) * 10) / 10

The mutiple by 2 and divide by 2 is just another way of rounding to half a degree.

Hence, HomeKit already showed .5 degree increments (as shown in your screenshot) but nothing else.

Yes … I didn’t know why was multiply and divide by 2 :upside_down_face:

I think those rounding operations could be avoided … for example in google assistant component only use round() with 1 decimal and I have checked that homekit is rounding to .0 or .5 … but the HomeKit document define a step value of 0.1:

I’m going to change it in de PR, thanks!

Also I’ve been doing tests with the issue with about “-6 ºC” with Siri, and I think that the problem is with HAP-py library … but I need to do more tests.

Let me know if there is any testing I can do to help

I am really excited about this but unfortunately as far as I know from experience the native Apple Home app shows all the reported temp values rounded to .5 and you can only see the exact values if you use some 3rd party Homekit app on iOS. For example when I move the slider on my HomeKit thermostat it jumps between 22.5 - 23 - 23.5 - 24 and so on, but the slider picks up values in between too, it’s just not visible. In other apps I can see the value is set to 23.8 but Home app shows 24 and Siri also reports 24. It’s the same for temp sensors.

I’m using mqtt climate entities (with attribute: target_temp_step: 0.1).
However my homekit always round the temperatures at 0.5 °C.
21,1 °C in HA → 21,0 °C in homekit
21,3 °C in HA → 21,5 °C in homekit
Isn’t there any solution that it just shows the correct temperature from HA in homekit?