Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # Raspberry Pi Zero in stock @ thepihut alarm for Rpi PC buzzer
- import RPi.GPIO as GPIO, feedparser, time
- USERNAME = "" # Gmail User Name
- PASSWORD = "" # Gmail Password
- GPIO.setmode(GPIO.BOARD)
- pin = 12
- GPIO.setup(pin, GPIO.OUT)
- pwm=GPIO.PWM(pin, 500)
- pwm.start(0)
- while True:
- try:
- found=False
- cur_mails = feedparser.parse("https://" + USERNAME + ":" + PASSWORD +"@mail.google.com/gmail/feed/atom")
- total=int(cur_mails["feed"]["fullcount"])
- if total > 0:
- for i in range(0,total):
- if cur_mails["entries"][i]["author_detail"]["email"] == "support@thepihut.com":
- title=cur_mails["entries"][i]["title"]
- if "Zero" in title or "zero" in title or "Stock" in title or "stock" in title:
- found=True
- if found:
- pwm.ChangeDutyCycle(50)
- else:
- pwm.ChangeDutyCycle(0)
- time.sleep(60)
- except Exception,e: # Probally a network conection error
- print e
- time.sleep(60)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement