How would I schedule events eg turn on/off a relay at specific times

Firstly, not sure if this is the correct category, sorry in advance if it is not right.

I have a Photon connected to a relay that can control my boiler in my home. I control it via a small web app I wrote which uses javascript to call the API to run the exposed functions and return the status.

Works like a charm.

My next task is to implement a timer, for example for it to turn on at a specific time and off at another time.

I was originally thinking of controlling cron jobs on the website but it sounds like a hack n slash!

How would I achieve this in a sensible manor? I can’t seem to think of a solution

Thank you

you could use a library like this:

3 Likes

Excellent, I will have a look once I get home, just leaving work now

Morning,

would it be possible to do an array of DailyTimer objects? I would like some flexibility in the number of timed events

Thanks

I suppose, but you are limited (right now) by by your choice of constructor. So you have to initialize the array of DailyTimer objects… something like this:

DailyTimer myTimer[] = {{8, 15, 13, 15, WEEKENDS},{9, 15, 22, 0, WEEKDAYS}};

We could certainly add a constructor that takes no arguments and uses come default values, but you eventually have to set the times anyways, I suppose.

I was thinking something like this process

[web]
Create list of events (stored in a database, sqlite3 probably)
save and push number of events to photon

[photon]
on push from web: initialise array of X number timers and pull details of each timer from web server and process

Yeah easily done. I am using these timers to do something like that… updating on or off times from time to time with web-hooks. For instance, I use Solar noon to determine when to open/close blinds on the east and west side of my house and sunset/sunrise for lawn watering and exterior lighting.