Feature Suggestion for Software Shutdown Followed by Hardware Shutdown?

Forgive me if this has already been mentioned but I could not find the same scenario in other threads. In my experience so far, the PI board is not powered off following a software shutdown and therefore cannot be restarted by a “Start” event. A hardware shutdown by itself is undesirable. Would it be possible to have an event type that performs the equivalent of a software shutdown followed by a hardware poweroff?

Thanks,
-Zach.

Hi Zach,
I’m a user like yourself, here’s what I came up with for this exact scenario.
Full disclosure, I’m using the “sixfab-power-python-api” v0.0.2 , not the pms-agent/power.sixfab.com.
about this code -

  1. I’m importing ALL modules. I’ve found some missing dependencies for the command module so I’m being “safe”.

  2. I’ve created two events; first is the soft-power-off (Safe Shutdown for the RPi OS), then the hard-power-off.

  3. The default for the ‘RESPONSE_DELAY’ is 10ms, often times too short to set & get via i2c so I’ve added a liberal amount of time, 500ms to each.

  4. While I staggered the timers 15 & 30 sec respectively the reaction is not quite as accurate. There is a 5 sec built-in timer for ‘soft-shutdown’ but I haven’t found the code reference to it yet.
    Note - you are probably aware but, charge led (L2) will continue to provide correct status. If L1 is programmed it too will continue to operate as programmed.
    IMPORTANT - with power removed BUT battery in place the voltage pins on the 40 pin header leak. Pins 1 & 17 report ~ .98 VDC (operationally provide 3.3 VDC) and Pins 2 & 4 report ~ .48 VDC (operationally provide 5 VDC). This is not a capacitance drain, it IS constant BUT the amperage is SO insignificant any connected devices or sensors will NOT power.

#!/usr/bin/env python3

from power_api import *
import time

print("Soft Pwr-Off set: " + str(api.create_scheduled_event(1, Definition.EVENT_INTERVAL, Definition.EVENT_ONE_SHOT, 15, Definition.INTERVAL_TYPE_SEC, 0, 3, 500)))

print("Hard Pwr-Off set: " + str(api.create_scheduled_event(2, Definition.EVENT_INTERVAL, Definition.EVENT_ONE_SHOT, 30, Definition.INTERVAL_TYPE_SEC, 0, 2, 500)))

Thanks Mark that helps and that’s good to know about the leak. I’m trying to gather sensor data, send it over the network, and then shut down cleanly to save power. I’d been trying to put the OS in a consistent state and then make direct API calls to trigger a hardware power off, but you are right there’s no reason I can’t just schedule a one-shot hardware power off event for a few minutes in the future and then just shutdown the OS if my script’s work is done. I already have an hourly task to start back up.

-Zach.