Hi,
I have a WittyPi5 which I intend to use for turning on a device each hour and capture some data before shutting down after completion.
To do this, I found the following example: https://github.com/uugear/Witty-Pi-4/blob/main/Software/wittypi/schedules/turn_on_every_hour.wpi
However, after debugging this for some time, I found the following in the logfile for the WittyPi5:
[12-30 17:25:04.252] Admin CMD: List Files [12-30 17:25:04.253] Listing files in directory: /schedule [12-30 17:25:06.659] Admin CMD: Choose Script [12-30 17:25:06.660] Applying script turn_on_every_hour.wpi... [12-30 17:25:07.489] Error: Invalid time component 'WAIT' [12-30 17:25:07.489] Failed to generate .act file from .wpi file [12-30 17:25:07.490] Load and run script failed
Is this not supported for the WittyPi5? If not, what's a similar way to accomplish this?
Is this not supported for the WittyPi5? If not, what's a similar way to accomplish this?
It is indeed no longer supported in Witty Pi 5.
There is no need to skip any shutdown in the schedule script - the shutdown will always be scheduled, and you can just shutdown your Raspberry Pi before the scheduled shutdown is due.
It is indeed no longer supported in Witty Pi 5.
There is no need to skip any shutdown in the schedule script - the shutdown will always be scheduled, and you can just shutdown your Raspberry Pi before the scheduled shutdown is due.
I was about to mention the discrepancy with the WittyPi5_UserManual, but I see now that it has been updated. For me this was unfortunate, as I found no real way to work this out without this flag, and the scheduling was one of the reasons for why I got the device.
However! Since the firmware of WittyPi5 is open, and now so easy to customize, I had no issues modifying the firmware myself. Kudos for this, it really makes this device extremely versatile and useful!
For reference, in case anyone has some of the same usecases, I will use this as part of a multifunction system with the following characteristics:
- The button will be connected to a interrupt on a motion sensor, meaning it should turn the device on, but never power it off
- The device should periodically turn on to check sensor statuses, but as it's connected to cellular it might take some time to transfer. Therefore the WittyPi should never turn it off, but the running script should do so itself when finished. (I was planning to use the WAIT flag for this)
- If a human turns the main power on at the location it's placed, the device should turn itself on immediately and stay on until the main power is turned off again. This so it's online and available to the person at the location. When the main power is off, then the device should go back to its regular schedule+interrupt controls. (Done by connecting VIN to switch, and VUSB to permanent power).
I've done the following modifications for the firmware to support this (so far):
$ git diff src
diff --git a/src/main.c b/src/main.c
index ddede38..b18fa21 100755
--- a/src/main.c
+++ b/src/main.c
@@ -137,7 +137,9 @@ void button_released_callback() {
} else { // Raspberry Pi is powered, request shutdown
- request_shutdown(false, ACTION_REASON_BUTTON_CLICK);
+ request_startup(ACTION_REASON_BUTTON_CLICK);
+ // A2MOD: Never shutdown with switch
+ // request_shutdown(false, ACTION_REASON_BUTTON_CLICK);
}
}
@@ -151,8 +153,10 @@ void button_long_pressed_callback() {
// Callback for scheduled shutdown
int64_t shutdown_alarm_callback(alarm_id_t id, void *user_data) {
- debug_log("Scheduled shutdown is due.\n");
- request_shutdown(false, ACTION_REASON_ALARM2);
+ debug_log("Scheduled shutdown is due. (A2BLOCKED) \n");
+ // A2MOD: Disabling scheduled shutdowns due to missing WAIT
+ // https://www.uugear.com/forums/technial-support-discussion/wittypi5-error-invalid-time-component-wait/
+ // request_shutdown(false, ACTION_REASON_ALARM2);
return 0;
}
diff --git a/src/power.c b/src/power.c
index 36eba21..cc5b3b9 100755
--- a/src/power.c
+++ b/src/power.c
@@ -465,7 +465,9 @@ int power_source_polling(void) {
} else { // Raspberry Pi is not powered
power_mode = POWER_MODE_NONE;
- if (can_vin_turn_on_rpi() && !can_cur_time_turn_off_rpi() && !can_temperature_turn_off_rpi()) {
+ // A2MOD: IGNORE CUR TIME OFF FOR VIN-Recovery
+ // if (can_vin_turn_on_rpi() && !can_cur_time_turn_off_rpi() && !can_temperature_turn_off_rpi()) {
+ if (can_vin_turn_on_rpi() && !can_temperature_turn_off_rpi()) {
debug_log("Startup occurs due to high Vin.\n");
request_startup(ACTION_REASON_VIN_RECOVER);
return POWER_RECOVER_STARTUP;
@@ -482,7 +484,8 @@ int power_source_polling(void) {
* @return true or false
*/
bool can_vin_turn_on_rpi(void) {
- if (vin_recoverable) {
+ // A2MOD: VIN is always recoverable
+ // if (vin_recoverable) {
uint16_t vrec = conf_get(CONF_RECOVERY_VOLTAGE) * 100;
if (vrec != 0) {
uint16_t vin = get_vin_mv();
@@ -492,7 +495,7 @@ bool can_vin_turn_on_rpi(void) {
return true;
}
}
- }
+ //}
return false;
}
