garageStatus runs on garage, hosts updates webpage with garage door status
--- /dev/null
+#!/usr/bin/python3
+import RPi.GPIO as GPIO
+import requests, time
+from bs4 import BeautifulSoup
+
+global soup
+soup=''
+#yellow=37
+#green=36
+
+GPIO.setmode(GPIO.BOARD)
+GPIO.setup(37,GPIO.OUT)
+GPIO.setup(36,GPIO.OUT)
+
+#garage=requests.get('http://garage.local')
+
+def readData():
+ global soup
+ garage=requests.get('http://garage.local')
+ soup=BeautifulSoup((garage.text),features='html.parser')
+ return soup
+
+def check():
+ global soup
+ dstate=soup.find(id='dstate')
+ lstate=soup.find(id='lstate')
+ try:
+ if dstate.text=='CLOSED':
+ GPIO.output(36,False)
+ if dstate.text=='OPEN':
+ GPIO.output(36,True)
+ if lstate.text=='OFF':
+ GPIO.output(37,False)
+ if lstate.text=='ON':
+ GPIO.output(37,True)
+ except AttributeError:
+ print('oops')
+ pass
+
+while True:
+ readData()
+ check()
+ time.sleep(1)
soup=BeautifulSoup((fp),features='html.parser')
dstate=soup.find(id='dstate')
lstate=soup.find(id='lstate')
soup=BeautifulSoup((fp),features='html.parser')
dstate=soup.find(id='dstate')
lstate=soup.find(id='lstate')
if int(l)==0:
lstate.string='OFF'
if int(l)==1:
if int(l)==0:
lstate.string='OFF'
if int(l)==1:
while True:
readLine()
check()
while True:
readLine()
check()
+# print(d,l,dstate,lstate) #debug