OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) Raspi as Wifi Bridge, Logger and Web Server Re: Re: Raspi as Wifi Bridge, Logger and Web Server

#24484

kenbob
Member

I do not have much programming experience, but just enough to get the job done. So please don’t laugh. 😀

I added a timeout when it opens the URL for the opensprinkler and an exception in case it cannot connect with it at all. If it errors out it goes directly to the top of Main() after 1 second. I spent days trying to figure out why it would lock up, until I started debugging it. I also removed most everything under (if __name__ == “__main__”:), because I was getting errors. Otherwise it gets the job done.

When I go to the Raspi URL it automatically redirects to the Sprinklers.php and shows me the logs. I love the fact that it shows me the entire schedule for the week.

from urllib2 import Request, urlopen, URLError
req = Request (“http://10.0.0.11/sn0”)

try:
state = urlopen(req, timeout = 2).read()
except Exception:
time.sleep(1)
pass
main()