Created
August 20, 2016 20:01
-
-
Save AKiniyalocts/640e0ac79c17589e0bdb8c908ff4511a to your computer and use it in GitHub Desktop.
Python build light for greenhouse
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
import requests | |
import json | |
import time | |
import RPi.GPIO as GPIO | |
alive = True | |
while(alive): | |
headers = {'token': 'YOUR_TOKEN', 'release':'False'} | |
r = requests.get('https://app.greenhouseci.com/api/projects/YOUR_PROJECT_ID', headers) | |
response = r.json() | |
latest_build_dict = response['latest_build'] | |
status = latest_build_dict.get('status', 'not found') | |
print(status) | |
if status == 'finished': | |
print('Sleeping for 5 min... Nighty night... Zzzz....') | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setwarnings(False) | |
GPIO.setup(18,GPIO.OUT) | |
GPIO.output(18,GPIO.HIGH) | |
time.sleep(300) | |
elif status == 'not found': | |
alive = False | |
else: | |
print('Building! Refreshing every 30 seconds.........') | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setwarnings(False) | |
GPIO.setup(18,GPIO.OUT) | |
print "LED on" | |
GPIO.output(18,GPIO.HIGH) | |
time.sleep(1) | |
print "LED off" | |
GPIO.output(18,GPIO.LOW) | |
time.sleep(5) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment