Skip to content

Instantly share code, notes, and snippets.

@coopermaruyama
Last active May 25, 2020 23:59
Show Gist options
  • Save coopermaruyama/fa6cb7c21d32b47f75942da06ff3241c to your computer and use it in GitHub Desktop.
Save coopermaruyama/fa6cb7c21d32b47f75942da06ff3241c to your computer and use it in GitHub Desktop.
Nest Thermostat: Win the temperature wars
// Sick of another person always changing the temperature?
// This will set your desired temperature every few seconds :)
// 1. Go to https://home.nest.com
// 2. Login
// 3. Pull up thermostat page
// 4. Open console (cmd + alt + J)
// 5. Paste this in, set wantTemp to whatever you want
function setTemp(want) {
if (typeof want !== 'number') { throw Error('want must be a number'); }
var curr = document.querySelector('[data-test=thermozilla-controller-content-temperature-high]').innerText;
var elUp = document.querySelector('[data-test=thermozilla-controller-controls-increment-button]');
var elDown = document.querySelector('[data-test=thermozilla-controller-controls-decrement-button]');
var temp = Number(curr);
if (temp < want && elUp) {
elUp.click();
console.log('went up');
}
if (temp > want && elDown) {
elDown.click();
console.log('went down');
}
var newTemp = Number(document.querySelector('[data-test=thermozilla-controller-content-temperature-high]').innerText);
if (newTemp !== want) {
// recurse
setTemp(want);
}
};
var wantTemp = 70; // set this
setInterval(function() {
setTemp(wantTemp);
}, 10e3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment