Search code examples
androidnest-api

Unable to set target temperature to Nest Thermostat from Android SDK


I am writing an Android application to control a Nest thermostat. I was able to connect to it just fine and I can read the correct target temperature (turning the nob on the thermostat updates my TextView).

However, when I try to write the target temperature like this, nothing happens:

String thermostatID = mThermostat.getDeviceId();
mNest.thermostats.setTargetTemperatureF(thermostatID, 70);

I tried setting the HVAC mode first, in case I needed that, but this didn't work either:

String thermostatID = mThermostat.getDeviceId();
mNest.thermostats.setHVACMode(thermostatID, "cool");
mNest.thermostats.setTargetTemperatureF(thermostatID, 70);

The Textview flashes 70 for a brief second, but then shoots back up to 77 which is the target temperature that was set by the actual thermostat. Is this an issue with the SDK code for setTargetTemperatureF, or am I missing something simple here?


Solution

  • The permissions for the Nest thermostat are set on the Nest website. Visit https://developer.nest.com/products and sign in. You will be given a list of your products, all you need to do is select one and scroll down to permissions.

    Note that after you change permissions, your mobile (or various platform) application will need to rerun authentication for this change to take place.