How to allow auto-update of apps in Play Store only when plugged in? I would like apps to be updated automatically when my phone is plugged in (charging) and on wifi. 
I can easily allow auto-update only when wifi is on with the appropriate option in the Play Store settings, but not prevent auto-updates from occuring if the phone is running on battery.

This is causing an unecessary battery drain when I am using my phone on wifi at home. Given that auto-updating apps is more a daemon job than a time critical task, I cannot believe it is not a standard power saving strategy.

Do you know any apps or system workaround (including if the device is rooted) to achieve this?
Note: 

Following solution: 


is tested on Android 4.2.1, COS12 (Android 5.0.2) and CM12.1 (Android 5.1.1) - all of them running Play Store v6.0.51
requires a rooted Android  
here is a short demo of the solution




While browsing the manifest of Play Store, I took an educated guess that only the following service is likely the initiator of auto-update of apps over Wi-Fi.

com.google.android.finsky.autoupdate.ReschedulerUsingAlarmManager$CheckWifiAndAutoUpdate


I played with that service under few conditions on different devices and found it useful for the goal in question. It goes without saying that the  auto-update setting of apps should be set to "Auto-update apps over Wi-Fi only" in Play Store.

Here is what you can do: Install an automation app which can execute series of actions when power source and Wi-Fi are connected and later on, disconnected. I used Tasker (trial version; userguide) as the automation app. 


Profile: Setup two contexts. See How to create a profile with multiple context in Tasker? for any related help


State &rarr; Power &rarr; Source: choose it
State &rarr; Net &rarr; Wifi Connected &rarr; fill details per your needs or leave all or any of them untouched



We would be needing two tasks: an entry task and an exit task. See my answer here for related help.


Enter task: (Actions):


Code &rarr; Run Shell


Command:


pm enable com.android.vending/com.google.android.finsky.autoupdate.ReschedulerUsingAlarmManager\$CheckWifiAndAutoUpdate;
am force-stop com.android.vending;
am startservice com.android.vending/com.google.android.finsky.autoupdate.ReschedulerUsingAlarmManager\$CheckWifiAndAutoUpdate

tick Use Root

You may optionally add one or more actions to notify yourself that the update procedure has begun. I used Alert &rarr; Flash to notify myself  via a toast.

Exit task: (Actions):

This task requires Busybox's applets installed. See How do I install missing command line tools onto an Android device? for related help.


Net &rarr; Test Net


Type: Mobile Data Enabled
Store Result In: %Mdata

Code &rarr; Run Shell


Command:


svc data disable;
svc wifi disable;
am force-stop com.android.vending;
am force-stop com.android.providers.downloads;
down_path=$(content query --uri content://downloads/my_downloads --projection _data --where "notificationpackage='com.android.vending'");
[[ "$down_path" != "No result found." ]] && echo $down_path | sed 's/.*=//g' | xargs rm -f || echo continue;
content delete --uri content://downloads/my_downloads --where "notificationpackage='com.android.vending'"
pm disable com.android.vending/com.google.android.finsky.autoupdate.ReschedulerUsingAlarmManager\$CheckWifiAndAutoUpdate;
svc wifi enable;
[[ "%Mdata" == "yes" ]] && svc data enable || echo doing nothing;

tick Use Root

Again, to notify yourself, use any action of your choice. 



What does those tasks do?

When the conditions for both the contexts are met, the enter task is run. The commands in that task does these things in sequential order:


enable the aforesaid Play Store's service
force-stop Play Store
start the said Play Store's service


And that's all for the auto-update to begin.

After remaining activated, whenever the profile deactivates (simply because a condition for a context doesn't meet anymore) the exit task would run. That exit task executes following steps in sequential order:


store the state (enabled/disabled) of mobile data in a variable Mdata
the job of those commands is to:


disable mobile data
disable Wi-Fi
force-stop Play Store
force-stop Download Manager


I noticed that if an update (download in progress) for an app is interrupted due to unavailability of Wi-Fi, the progress bar (notification) is dismissed, the status of the progress gets stored in a row in the table downloads of database downloads.db. (That database is located under the data directory of Download Manager.) That row also contains the location of the partially downloaded file.

In order to make sure that auto-update doesn't occur on the next successful connection to Wi-Fi and making sure that it never does so when the profile is not running the enter task, following is what rest of the commands do:


extract the location of the partially downloaded file from the value in the column _data corresponding to a row identified by com.android.vending as notificationpackage. We aim to delete that file. This is a small sacrifice to make.
if there is indeed a file path under _data, then use it to delete the file pointed by it.
delete that row, otherwise, it will be read by Download Manager when network connectivity changes (reconnected to a Wi-Fi) and auto-update would begin again.
disable the aforesaid Play Store service so that auto-update never begins on it own
enable Wi-Fi
enable mobile data, if it were enabled prior to running this task.





1At the time of creating the first revision of this answer the current Play Store version is definitely not 6.0.5 but above. However, none of my devices have received any further Play Store update so far.