The Nest Thermostat device will display on-screen if it's 'cooling' or 'heating'. How do I get this state through the Nest API?
The hvac_mode
property seems to simply show what the user's Thermostat is capable of controlling and doesn't change when either cooling or heating occurs.
For now, I'm using a simple but not flawless logic:
if (can_cool && target_temperature < ambient_temperature) --> isCooling
if (can_heat && target_temperature > ambient_temperature) --> isHeating
else --> isDoingNothing
By not flawless, I mean that I've encountered situations where this logic is incorrect. For example, in a given situation where the ambient_temperature
is 20 Celsius
and the target_temperature
is 21 Celsius
with can_heat
set to true
, my UI will say the Thermostat is heating, while it actually isn't.
This is probably because target and ambient temperatures are too close, but I don't know what the threshold is.
Is there another or better way to figure out heating and cooling states?
As of May 2015, the Nest API now officially reports the hvac_state property. The value will be one of either 'heating','cooling' or 'off'.
New fields in the data model: hvac_state. You'll use hvac_state to learn if the home HVAC system is actively heating, cooling or is off.