Skip to content

Instantly share code, notes, and snippets.

@anderm3
Created June 18, 2016 17:03
Show Gist options
  • Save anderm3/378cd8eefb99a8479b63e19c86b0f085 to your computer and use it in GitHub Desktop.
Save anderm3/378cd8eefb99a8479b63e19c86b0f085 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
from gpiozero import Button
from twilio.rest import TwilioRestClient
import logging
import time
logging.basicConfig(filename='/var/log/button.log',level=logging.DEBUG)
account_sid = "abcxyz"
auth_token = "secret"
client = TwilioRestClient(account_sid, auth_token)
min80 = 4800 # 80 min in seconds
min40 = 2400 # 40 min in seconds
def SendMessage():
client.messages.create(body="Please check on the laundry",
to="+15551212",
from_="+15551234")
def Blue():
logging.info('Blue button pressed')
time.sleep(min80)
SendMessage()
def Green():
logging.info('Green button pressed')
time.sleep(min40)
SendMessage()
button5 = Button(5)
button13 = Button(13)
while True:
button5.when_pressed = Green
button13.when_pressed = Blue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment