I am successfully using a wittypi with Pi4 in a remote off grid location and I would like to know if it's possible to write a schedule to turn the pi on only during the night.
Since the sunset/sunrise time changes during the year and the on/off times don't need to very accurate, I was wondering if it's possible to make a schedule that does something similar with this:
- In January, run for 14 hrs and stay off 10 hrs. Run from from 5pm to 7 am
- in Feb run for 13 hrs, from 5:30pm to 6:30am
- .......
- in July, run from 10pm to 5 am
...
I tried something like this, but it complains that it cannot find the END time, so probably it doesn't know how to handle multiple START/END in one scheule
BEGIN 2025-12-01 17:00:00
END 2025-12-02 00:00:00
ON H14 # stay ON for 14 hrs
OFF H10 # keep OFF for 12hrs
BEGIN 2024-12-02 17:30:00
END 2024-12-03 00:00:00
ON H13 # stay at ON for 13hrs
OFF H11 # keep OFF for 11hrs
Times are not exact, just to get an idea.
Any help would be appreciated.
Thanks,
speo
Oh, I see a bunch of mistakes in my file.
I tried this:
BEGIN 2024-12-26 02:10:00
END 2024-12-26 02:30:00
ON M4 # stay ON for 14 hrs
OFF M4 # keep OFF for 12hrs
BEGIN 2024-12-26 02:40:00
END 2024-12-27 02:55:00
ON M10 # stay ON for 14 hrs
OFF M10 # keep OFF for 12hrs
And I got this:
Running the script...
--------------- 2024-12-26 02:03:34 ---------------
Schedule next shutdown at: 2024-12-26 02:44:00
Schedule next startup at: 2024-12-26 02:48:00
---------------------------------------------------
Done 🙂
================================================================================
>>> Current temperature: 32.75°C / 90.95°F
>>> Your system time is: 2024-12-26 02:03:32 EST
>>> Your RTC time is: 2024-12-26 02:03:35 EST
>>> Vin=8.89V, Vout=5.13V, Iout=0.49A
Now you can:
1. Write system time to RTC
2. Write RTC time to system
3. Synchronize with network time
4. Schedule next shutdown [26 02:44:00]
5. Schedule next startup [26 02:48:00]
So, it skipped the first BEGIN/END
Schedule script doesn't support multple BEGIN/END in one file.
What you need can be achieved by switching different schedule script files on the fly. It is possible to check the current time (ideally from the RTC) and decide which schedule script file will be used.
The logic to switch different schedule script files can be placed in the "beforeScript.sh" file, which will be executed by daemon.sh automatically on boot.
Thanks for the reply, I will give it a try.