Power sleep temporary override

autopi-dongle
autopi-diy
#1

Hello all,

From what I learned here in the community, when the engine is off, the autoPI normally wakes only around 5 minutes every hour to prevent battery drain.

I’d like to have more time to work remotely on my autopi DYI, but I would like to keep settings the way they are (so that I don’t drain my car battery if I forget changing the configuration back to normal).

I already made some preparations to that the autopi is accessible from remote (via an openvpn connection - I can share details if anyone is interested), but I don’t know how to make the device wake up when I need to access it.

Do you have any suggestion on how I can implement a “Power sleep temporary block” ?

My use case is:

  • I log-in remotely
  • I send a “power-sleep-temporary-override command” somehow
  • normal sleep behavior is temporarily changed, so that the autopi stays alive e.g. for 2 hours
  • everything gets back to normal after 2 hours

Thanks in advance for any hints you could share.

R.

1 Like
#2

Hi @riccardo.to

I can see the use case for your suggestion. Good thing is that its already possible

Using the power.sleep_timer module you can alter the sleep timers on the device.

Basically there are two types of sleep timers:

  1. Hardware sleep timer. This is triggered at 12.2V and will force your device into sleep. This is an absolute last preventive sleep timer to ensure that your device wont drain the battery. We dont recommend tampering with this (but it is possible)
  2. Software/OS sleep timers. These can be altered through the power.sleep_timer function, and this is the ones I recommend you start working with.

You can disable all sleep timers with this command:

power.sleep_timer enable=False

You can add new sleep timer with this command:

power.sleep interval=3600 delay=7200 confirm=True

This will make the device sleep for 1 hour after 2 hours of uptime.

Remember that if you use the help commands, then you can explorer the full potential of all our commands. You can also check directly in the GitHub source code.

If you combine the sleep timers with the Jobs on the device, then you could even setup the device to do this automatically.

best
Peter

1 Like
#3

Cool - thanks! That definitely implements what I need!

Cheers,

Riccardo

#4

@Peter - could you point me to some doc or some location in the autopi code where I can understand more how timers are managed ?

I’d like to understand better how timers work e.g. is there a single sleep timer or there’s a list of them ? if so, where can I access the list of active timers and add/remove them ? how do these sleep timers interact with the “Inactivity Fallback” timer and other timers that I find in the settings ? how do you define “inactivity” in the “Inactivity Fallback” timer ?

R.

#5

Hi Riccardo

You can run the command

power.sleep_timer

to see the list of currently configured timers.

To clear all configured timers you can run the

power.sleep_timer enable=false

Basically how it works, is that the system reacts to different things, and then based on a range of data, it set the sleep timers. Like on startup, if it detect a running engine, it will set the sleep_timer to half an hour, and if it does not detect a running engine, it will set the sleep timer to 5 minutes. That’s basically how the Inactivity After_sleep timer works.

Then if the device see that an update is pending, and it decides to install it, it will clear the sleep timer so that it will not shut down right in the middle of the update, and then restore the sleep timer afterwards.

Best regards
/Malte