Calling urllib from Python is easy enough to do. You could equally have a shell script which calls wget or curl -pi9 wrote: ↑Sat Feb 08, 2020 2:21 amI am thinking that I should create a crontab entry that calls a python script that would somehow call the appropriate url for the activity.
Of course the side effect of that is that it would be hard coded, so I am open for other ideas as long as they are relatively simple.
Code: Select all
import urllib HOST = "192.168.0.123" def WGet(filename): socket = urllib.urlopen("http://" + HOST + "/" + filename) pageSource = socket.read() socket.close() return pageSource def Open(): WGet("open") def Close(): WGet("close")
I am doing the same sort of thing, but controlling WeMo switches rather than curtain actuators. I use pywemo for the lower level WeMo interface, but the control system uses a Flask application to create and change entries in a sqlite database corresponding to the desired on and off times for each switch and a separate server application which reads the database entries and sends out the necessary commands. I have this working at home and at a remote location, where I can browse in and change settings as I wish. The Pis also collect and store sensor and weather data, and (for the home one) communicates with a Windows application which displays this.pi9 wrote: ↑Sat Feb 08, 2020 4:51 pmThanks for all the suggestions. I will try them hopefully soon. One thing to clarify is what I meant by hard coding. My present plan is to put the scheduled curtain openings in the crontab. Of course (at least to my understanding) is I will have to edit the crontab from linux. I would prefer to give my self the option of making those schedule changes from a configuration php page on the pi. I am not sure how this can be done or at least i don't yet have a thought on how to do it. I have a dedicated pi3 just for those IoT projects. Collecting sensor data mostly and now I would like to use it to control things. The database is getting big, but still ok i think. I have two years of 5 minutes increments of collected data.
Code: Select all
30 6 * * 1-5 /home/pi/lights.sh NIGHT HEX242430 NIGHT ON 0 8 * * 1-5 /home/pi/sunwait/sunwait wait rise offset 01:00 50N 0W ; /home/pi/lights.sh OFF 0 15 * * * /home/pi/sunwait/sunwait wait set offset 5 51.5084N 0.2746W ; /home/pi/lights.sh HEX454500 ON