Before using wittyPy, make sure your Witty-Pi and the according software works propperly on your Raspberry Pi.


To use the wittyPy functionality, you first have to instatiate wittyPy and connect it to your wittyPi. As the only argument it takes the path to your wittyPi software directory:

import wittyPy
witty = wittyPy.WittyPi('/home/user/wittyPi')

Current State

After instatiating, WittyPi searches for the required files and reads the current state of your Witty-Pi. You can access them using:

  • witty.next_startup and witty.next_shutdown are WittyTime objects and store the next scheduled boot/shutdown.
  • witty.available_schedules```is a list of the schedules in your ``../wittyPi/schedules folder.
  • witty.timedelta is the difference in seconds between your system time and your RTC time.

Set Startup or Shutdown

To set a startup or shutdown, run wittyPy.set_startup() or wittyPy.set_shutdown(). The startup methods takes up to four arguments (day, hour, minute, second) and the shutdown method three (day, hour, minute). Running these functions will create a WittyTime. This includes a validation of the argzuments. Use integers (day: 1-31; hour: 0-23; minute & second: 0-59). For day and hour you can also use "??" as a wildcard. If you set a wildcard for the hour, the Witty Pi expects that you also set a wildcard for the day:

witty.set_startup('??', 10, 30)
witty.set_shutdown(11, 12, 13)

Set Schedule

To activate a schedule use wittyPy.activate_schedule(). This method expects the index of the desired schedule in the witty.available_schedules list:


To reset startup, shutdown or schedule, simply overwrite it with a new one, or use the wittyPy.reset() method. This method takes "startup",``”shutdown”,“schedule”`` or "all" as an option:


Check time left

To check the time left until next startup or shutdown, use the wittyTime.t_left() method: