Set safe shutdown battery level UPS HAT v2

Hi,
i working with a UPS HAT v2 and i wanna know if when the DC power input is disconneted and the the power is just of the battery i can keep the system running and when the battery is low he just turn off safely.
I searching for the use of set_safe_shutdown_battery_level but i can’t use this i don’t know why, can be because of the firmware version? what is the newest?

the set_safe_shutdown_battery_level was removed? @ensar

Hi @falconeee ,

Yes, it was removed. All available functions are here: sixfab-power-python-api.power_api.power_api API documentation

1 Like

Thanks for the answer! For the safe shutdown now i can use the power outage? When run_time come to the end the system shut down safely?

Yes, you can use it. Note that you need to enable the power outage event state.

1 Like

Thanks!!! This function will help me a lot!

Do you have an example for how to guarantee that the rPi is shut down when the battery reaches 3.1V or level==5% (I don’t care which of these two)? @ensar

from power_api import SixfabPower
import time

api = SixfabPower()

api.set_power_outage_event_status(2) #set power outage event

while True:
if api.get_battery_level() < 10: #if battery level below 10% shutdown
api.set_power_outage_event_status(1)
print(‘shutdown’)
else:
print(‘keep working’+ ’ ’ + str(api.get_battery_level()))

time.sleep(5)
1 Like

Thanks! But if the rPi hangs for whatever reason then this ceases to work and the HAT won’t shut down at all.