0

So, here is what I am looking to accomplish. I have a Pi with an Apache webserver running with a home automation page. I also have a relay board and multiple lights hooked up, (using the GPIO pins on the Pi).

I would like the end user to be able to log into the website and be able to set up timers to turn the relays on and off. I can set up scripts to accomplish the on/off part for the relays but I need to know how the user can set specific times to run those scrips via the website.

I can use Cron on the backend. But that is too complicated for an average user of the page, (my family). Is there a simple Cron web-based GUI to schedule with from the web interface?

An example would be to log into the page and set the lights to turn on at 4pm and off at 9pm. But this also has to be secure so nobody outside the network can get at it without a username and password. I use DDNS to access the Pi from outside the home. I'm a novice when it comes to programming so I would like something already developed that I can implement.

1

"(...) need to know how the user can set specific times to run those scrips via the website."

There are probably many ways to do it but I can tell you how I'm doing it. I made a system using cron, python, php, js and html that does exactly this and more. The user logs in - via https/TLS, of course ;) - and is presented with some javascript time range pickers, sensor graphs, GPIO toggle buttons and a log viewer that fetches historical data from a sqlite db (it's nice to know how many minutes your lights have been on during the last month, for instance).

When the user has picked a schedule using the timepickers and clicks "save settings", these on/off times are sent to the server where php writes them to a json file. The json file is then read back by a python script that gets called by cron every minute and checks whether or not the current time and sensor values are within the given ranges (it also turns on an arduino that logs sensor data but that's irrelevant here). Python then makes decisions regarding GPIO toggling and other stuff. The crontab is never actually touched - only the json file is edited and used for communicating user settings to the system. In case of network loss, a ds3132 hardware clock takes over and ensures proper time keeping without ntp. Perhaps if I'd known about the links below, I wouldn't have gone to this much trouble hehe. Anyway, hope that answers your question.

Here's some more or less ready-made solutions and links to forum posts that might be useful:

  • 1
    Thank you! I've been digging around and havn't found quite as much as what you just posted. Your setup sounds awesome. I like how it routes back to the hardware clock in case of network failure and the fact that your not entering all your jobs into crontab. I have my work cut out for me now. Last night the wife said she wanted to start growing some seedlings and tomatoes and basic veggies in the basement (we live in wisconsin) too cold for outside yet. But i want to build another one for her to be able to fully monitor her greenhouse i am building now. This may come in handy again! Thanks!! – Nickuww Mar 10 '16 at 16:24
-1

You need to elaborate cron/atrun job scheduling for your authenticated users, quite a lot of web interfaces available, so suit yourself with any secure one

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.