Last active
November 4, 2015 20:21
-
-
Save benwtr/123fd39b8134d30e89ea to your computer and use it in GitHub Desktop.
Ever wish your thermostat had a "turn heat on for x minutes" feature? Me too, but not enough to spend more than 5 minutes writing a script to do it
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
#!/usr/bin/env ruby | |
# Tell a nest thermostat to kick the heat on for n minutes | |
require 'nest_thermostat' | |
unless ARGV[0] | |
puts 'Usage: warmup.rb <minutes>' | |
exit 1 | |
end | |
nest = NestThermostat::Nest.new( | |
email: ENV['NEST_EMAIL'], | |
password: ENV['NEST_PASS'], | |
temperature_scale: :celsius | |
) | |
seconds_to_warm = (ARGV[0].to_i * 60) + 30 | |
before_temp = nest.temperature | |
warm_temp = nest.current_temperature + 1 | |
nest.temperature = warm_temp | |
sleep seconds_to_warm | |
# reset to previous temp unless the thermostat has been changed by something else | |
nest.temperature = before_temp unless nest.temperature != warm_temp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment