robertklep / name.klep.homekitty

HomeyKit 3.0
15 stars 5 forks source link

Google Nest Thermostat HomeKit Temperature Conversion Unit of Measurement Issue #105

Open mkormendy opened 3 months ago

mkormendy commented 3 months ago

I have a Google Nest Thermostat added to my Homey via the Google Nest application. The Google Nest device is set to Fahrenheit, and so is my HomeKit too. I have HomeKitty exposing the Nest Thermostat to HomeKit, but I'm seeing a bit of a conversion issue. For example, the current temperature is 76º F but for some reason, that's being read as a Celsius number of 76º C to which is being displayed on my HomeKit Thermostat current temperature as 1169º F.

Wondering if there's a fix for this.

See below:

49304A51-8D26-4D80-9655-401A8F043913_1_102_o

D20CEE3D-2CBA-4015-AE10-43B2768AF5A6_1_102_o

FFB9EBCB-5FAF-45E4-B9D2-CCA9FCD4BE27_1_102_o

4615E77B-4917-4424-8CC0-4C52328CE83B_1_102_o

27A5A64E-8C06-4D21-B601-867C00EE454C_1_102_o

robertklep commented 3 months ago

My guess is that this is an issue with the Nest app.

Can you find the device here: https://tools.developer.homey.app/tools/devices

And then check if the temperature capabilities (measure_temperature and/or target_temperature) are set to the temperature in F?

mkormendy commented 3 months ago

Yes both of them are set to 76°

robertklep commented 3 months ago

That's not right, Homey internally should always store temperatures in Celcius, that's how the capability is defined:

image

Which means that the Nest app is importing the temperature but doesn't check its scale and (apparently) assumes it's Celcius. Since HomeKitty also assumes Celcius (because the capability definition says so), iOS thinks that the supplied temperature is in C and converts it to F, causing an incorrect temperature to be shown.

I can't fix this in HomeKitty.

mkormendy commented 2 months ago

Let me reach out to the homey nest app developers and reference this issue as an example. What's interesting is that the Homey mobile app sees the thermostat temperature for cooling as Fahrenheit as well as the local weather temperature too at the top of the app. I'm not sure if this is automatically adjusted based on iOS system settings, but I can't seem to find a preference setting for this in the mobile app either.

image

image

robertklep commented 2 months ago

I'm fairly sure that the app uses your Homey's location to determine which temperature scale to use.

However, it's a bit unexpected that the Homey app shows the correct temperature, because I would think that it also, just like HomeKitty, also assumes that Celcius is used internally. Which would mean it would also convert the 76° to 169°.

What I'm just noticing though is that only the measured temperature is set incorrectly in your initial screenshot, the target temperature looks okay:

image

That's weird.

mkormendy commented 2 months ago

Yeah that is also very odd. I was on my phone earlier when I was looking at the homey devices properties page and only saw the numbers for the thermostat .. but here's a snap of the full details:

Screenshot 2024-08-29 at 10 38 08 AM
robertklep commented 2 months ago

I took a look at the code of the Nest app, and it looks like it uses the ambient temperature in Celcius, as provided by the Nest API, to set measure_temperature, which means the app is doing the right thing.

However, that doesn't explain why the developer tools is showing the temperature in Fahrenheit. It might be possible that the developer tools converts these values based on the user's locale, but I doubt it.

It could also be that the Nest API is providing an incorrect value, but I have no way of checking this.

I've asked one of the Athom developers on Slack if they can provide some clarification on what I'm seeing.

robertklep commented 2 months ago

Can you check and see if this version fixes your problem?

https://homey.app/a/name.klep.homekitty/test/

mkormendy commented 2 months ago

Installed the update, and now the temperature units are the same in the Home app, albeit both now converted improperly somewhere. And I also noticed the following:

F7F6D821-CC87-412E-9852-8A0ADA6BA228_4_5005_c A5D25B65-4D25-404D-A697-3E5EF02FB187_4_5005_c D8B921A6-4758-4563-9F78-504E88098DD9_4_5005_c A21B64EB-A676-45E7-B19A-CD0A3EE27A40_4_5005_c 0034BB2C-CBCF-4343-877C-43FA3051A40A_4_5005_c 15D63882-1117-40BC-AADA-D5AA1B570125_4_5005_c

Screenshot 2024-08-30 at 12 38 25 PM
robertklep commented 2 months ago

There are various issues here:

mkormendy commented 2 months ago

The first two points, I understand, however the last point, I'm not sure what to do about. Should I tell the Nest app devs that their custom capability makes it difficult for other apps to work with their app in Homey?

robertklep commented 2 months ago

I assume that they don't use the standard thermostat_mode capability for a reason, but you can always ask them.

There's not much you, or I, can do about this to get the device working properly in HomeKit though, at least not without resorting to something like a virtual/"advanced" device that provides a mapping between the custom capability to a regular capability: you would basically create a virtual thermostat device and set up flows that will update it when you change the actual thermostat, and also the other way around, when you change the virtual thermostat (from iOS) you update the actual thermostat.

mkormendy commented 2 months ago

Interesting .. I'm not exactly sure how to contact the developers of this to speak with them about it.

robertklep commented 2 months ago

Contact info can usually be found on the app page in the app store.

mkormendy commented 2 months ago

Okay, I have found it, it is Athom BV that made it .. I submitted a request and received the automated response below:

Hi Michael,

Thanks for reaching out! Your request (124695) has been received and is being reviewed by our support staff.

Our estimated response time is 3 business days.

robertklep commented 2 months ago

Expect an answer that blames HomeKitty 🫣

robertklep commented 1 month ago

@mkormendy I'm still waiting for something at Athom to respond to my findings, but it's becoming more and more difficult for developers like me to get any response (many issues get reported but go unanswered, as Athom seems to prioritise new features).

mkormendy commented 1 month ago

Do I need to also chime in on slack and or the github post?

robertklep commented 1 month ago

@mkormendy thanks for the offer, but not necessary 😊 Did you ever get a response from Athom support about this?

mkormendy commented 1 month ago

I did not. 😞

robertklep commented 1 month ago

At least you're getting a nice dashboard 😛

suqbus commented 1 month ago

I'm not sure if it's allowed to write here but on my side my Nest thermostat is always off in Homekit while it is in heating mode. If I put it on heating mode from Homekit it always returns to off mode on HomeKit, while it is in heating mode on Homey and in the Nest app.

robertklep commented 1 month ago

@suqbus this is probably related to the Nest app not using the standard thermostat_mode capability but a custom one, and HomeKitty doesn't support custom capabilities ☹️

suqbus commented 1 month ago

Last winter, however, everything worked perfectly. I turned off the thermostat for the summer and it was when I turned it on this week that I realized this new problem. Maybe the Nest app made changes to this recently?

robertklep commented 1 month ago

@suqbus that's very possible, I don't see any relevant changes to the thermostat code in HomeKitty that could explain this.

mkormendy commented 2 days ago

Looking at the Homey Pro updates changelog v12.2.0, they had some temperature fixes for an issue that could cause temperature conversion from Celsius to Fahrenheit to return an invalid value. Does that help correct our problem?

robertklep commented 2 days ago

@mkormendy I got a diagnostics report from another user about this issue, and they are running v12.2.1. I'll try and see if I can force my Homey to use F as a unit so I can at least reproduce the issue.

I also bumped up my issue about this once again. It's only been almost two three months... 🤷🏼‍♂️

GavinMcNabb commented 2 days ago

That was me, I also found this same issue with their builtin Alexa Integration. I did submit a support ticket with them for that, I'll let you know if I hear anything.

robertklep commented 1 day ago

@mkormendy it looks like the SDK isn't causing this issue, I set my Homey's location to the US and my virtual thermostat device is showing the correct temperature in Fahrenheit now.

There was one small potential issue that might be causing a double conversion that I fixed, check out the new test release: https://homey.app/a/name.klep.homekitty/test/

You may have to "unpublish" your thermostat device from Homekit, and publish it again. You can do that from the configuration screen for the Homekitty app.

mkormendy commented 1 day ago

Unfortunately I don't think it had any effect.

robertklep commented 1 day ago

Looking back at your comment here, I was wrong in assuming that the value shown on the "devices" page should have been in Celcius. I put my Homey in Fahrenheit mode and it was showing the value in F on that page, even though internally it was returning the proper value (in Celcius), so the devices page isn't showing the actual capability value, but a localised one.

I just realise that I only tested with the target temperature though, and looking back at this conversation the issue was with the measured temperature. So I'll do some more testing.

robertklep commented 1 day ago

Okay, measured temperature is also working. It does look like it still expects that apps use °C under the hood, but from what I've seen the Nest app does so.

So at the moment I have no idea on what's causing this issue 😞

mkormendy commented 1 day ago

Can you provide a switch in the app that a user can select that will perform a re-calculation to ºF for thermostats? For one-off manual setups?

robertklep commented 1 day ago

I can't do that, because I don't know what's causing the issue and if it applies to all thermostats or just a specific brand.

mkormendy commented 1 day ago

Let the user determine that, they can turn it on if they are seeing the issue.

mkormendy commented 1 day ago

In the Homey mobile app, I am seeing the temperature correctly. image

robertklep commented 1 day ago

I can't reproduce the problem, both the Homey app and the Home app on iOS are showing the correct temperatures. I don't have an actual Nest thermostat that I can use to test things with.

robertklep commented 1 day ago

What we can try is that you make some changes to your thermostat's target temperature, then create a diagnostics report for Homekitty from the Homey app. Homekitty logs a fair amount of data, perhaps there's a clue in there.