Created
June 18, 2016 17:03
-
-
Save anderm3/378cd8eefb99a8479b63e19c86b0f085 to your computer and use it in GitHub Desktop.
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/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