From: jimmy Date: Sat, 3 Aug 2024 20:37:23 +0000 (-0500) Subject: garageCheck runs on device to turn on/off LEDs (Myserver) X-Git-Url: https://vault307.fbx.one/gitweb/garage_door_sensor.git/commitdiff_plain/HEAD?ds=sidebyside;hp=2f834b0f175c10abb28ec7ebaa8612e85b004377 garageCheck runs on device to turn on/off LEDs (Myserver) garageStatus runs on garage, hosts updates webpage with garage door status --- diff --git a/garageCheck.py b/garageCheck.py new file mode 100755 index 0000000..a2ef51a --- /dev/null +++ b/garageCheck.py @@ -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) diff --git a/garageStatus.py b/garageStatus.py index 265a49f..1264903 100755 --- a/garageStatus.py +++ b/garageStatus.py @@ -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)