]> vault307.fbx.one Git - garage_door_sensor.git/commitdiff
garageCheck runs on device to turn on/off LEDs (Myserver) experimental
authorjimmy <jimipunk88@gmail.com>
Sat, 3 Aug 2024 20:37:23 +0000 (15:37 -0500)
committerjimmy <jimipunk88@gmail.com>
Sat, 3 Aug 2024 20:37:23 +0000 (15:37 -0500)
garageStatus runs on garage, hosts updates webpage with garage door status

garageCheck.py [new file with mode: 0755]
garageStatus.py

diff --git a/garageCheck.py b/garageCheck.py
new file mode 100755 (executable)
index 0000000..a2ef51a
--- /dev/null
@@ -0,0 +1,43 @@
+#!/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)
index 265a49fc0e0b5e1d8ff58548a8c773ea34e60cc7..126490344150c5bacffba46db79065cbada19d98 100755 (executable)
@@ -29,7 +29,7 @@ def check():
         soup=BeautifulSoup((fp),features='html.parser')
     dstate=soup.find(id='dstate')
     lstate=soup.find(id='lstate')
-    fp.close()
+   # fp.close()
     if int(l)==0:
         lstate.string='OFF'
     if int(l)==1:
@@ -53,5 +53,5 @@ def check():
 while True:
     readLine()
     check()
-    print(d,dstate)
+#    print(d,l,dstate,lstate) #debug
     time.sleep(.5)