Thermostat API ambient_temperature does not match Nest app's ambient_temperature


#1

I have a customer that gave a screenshot of his app. The current temperature shown is 78F. However, the Nest API is telling me that the ambient temperature is 77F. The API updates to 78F about 15 minutes later though. Is there some weird rounding bug going on here?

This customer also has a room sensor. The API response doesn’t take into account, or average in, the room sensor temperature, right?


#2

I did some research internally and yes, this is due to a rounding error in the API. And correct, the Nest temperature sensors do not appear in the API or affect the data you pull from the API.


#3

Thanks! Are there any tips on ways to avoid this? Maybe only use the F value or only use the C value?


#4

@jbumgardner Do you have any updates on when this will be resolved? If nothing specific, do you know if we’re talking days, weeks, or months?


#5

This is a long-standing bug that probably won’t be resolved at this point. C is less granular so I would just continue to use F and be aware that it may be off a degree for a short period of time.


#6

“Probably won’t be resolved at this point,” meaning the API will never be fixed and you expect it to always have this rounding error?

As a developer, that’s shocking to me. I can’t imagine being aware of a bug and not correcting it.

Also, it’s already very limiting to only get temperatures as integers via the API. Now knowing they’re not even calculated correctly makes it even worse.


#7

“Bug”/“error” were the wrong words to use here, since it ultimately has to do with the rounding we chose to implement, and it was a deliberate design choice that there are no plans to change. Sorry to cause confusion.

It’s basically related to the same thing we discussed a few months back:


#8

It seems the answer in the thread that you referenced conflicts with the rounding you’re saying exists now.

You’re saying the API rounds down (i.e. Math.floor) by design, which is why the API trails what the actual thermostat detects. (The original question said the thermostat was rounding up to 78ºF while the API was still reporting 77ºF, which means it wasn’t rounding up properly.)

However, in the previous reply, you said the API was performing a Math.round, which would round down for less than 0.5 and round up for 0.5 or greater.

If the rounding down is by design, then I assumed the previous reply was an error. But, you referenced it as saying it’s related to this, so that would seem to indicated that the rounding down is an error. I’m sorry to be a pest, but can you please clarify?

Reading the ambient temperature is an insanely vital function of a thermostat. I think it’s really important for developers to understand exactly how it’s supposed to be working. (It certainly is in my case.)


#9

It’s the rounding that causes the discrepancy since the API and apps all perform their own rounding separate from each other, and not all at the exact same time. There are a variety of reasons one could lag behind the other.

The ambient temperature shown in the API is not inaccurate, and I completely understand that it’s not granular enough for everyone and every use case, but that was how the API was designed, so developers should keep that in mind.

As for mismatches between ambient temp in the API and current temp in the apps/thermostat, I would like to know if you or anyone else is actually seeing this happen frequently. I only have this one reported example and it’s a hard thing to reproduce. If it’s happening often, I’d be happy to investigate further.


#10

I was actually going fully based off of the responses above that indicated the API rounding is what led to that behavior.

I just tested by monitoring the float ambient temperature in Technical Information > Sensors and it seems that the API is rounding up/down as expected (That is, it does appear to be using Math.round() rather than Math.floor().)

So, that’s definitely good to know. Thank you for clarifying!