Last active
May 25, 2020 23:59
-
-
Save coopermaruyama/fa6cb7c21d32b47f75942da06ff3241c to your computer and use it in GitHub Desktop.
Nest Thermostat: Win the temperature wars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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