Skip to content

Instantly share code, notes, and snippets.

@KellyMahan
Created March 16, 2015 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KellyMahan/ca95af6f614086581a45 to your computer and use it in GitHub Desktop.
Save KellyMahan/ca95af6f614086581a45 to your computer and use it in GitHub Desktop.
garage = Winker.devices.find{|d| d.name == "Garage Door"}
#i dont have a garage door to check this but I think this would be the correct update to send.
#assuming position is the correct attribute and a value between 0 and 1. and 0 is closed 1 is open.
if garage.position > 0 and garage.updated_at < 10.minutes.ago #check for position and last update time
garage.update(desired_state: {position: 0})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment