Code Details:

After provisioning the EP10, configure this code for the plug name and the hours to charge before turning off. In this example a 4-hour charge time worked fine.

Upon code startup if the plug is not detected (typically the EP10 is unpowered) the code waits in a loop until the EP10 is available. This is in case the network has been reset due to power fail or you forgot to plug in the EP10.

Then the code sleeps and periodically wakes every 5 seconds to check if the EP10 is powering the charger. If so the code then sleeps the configured number of hours, awakes and turns off the charger.

Error conditions:
As typical for this simple home automation the most common error condition here is that the EP10 is not powered, usually because the user unplugged it during testing or is moving it. 

When using the kasa library the "try-await-except SmartDeviceException" technique provides recoverable error handling.

OS tested:
    Windows 10 (py 3.8), Ubuntu 22.04 (py 3.10), Raspberry Pi OS 11 bullseye on Pi 3B+ (py 3.9).

------------------------ EP10 provisioning notes ---------------------------------------------

For kasa CLI commands, refer to

First find the plug's wifi and connect to its network (use a laptop), its wifi SSID ends with its 4-digit MAC.

    Example: TP-LINK_Smart Plug_8714

Provision to your main router on

    kasa --host wifi join 'your network SSID' --password routerspasswordorhexdigits

Shorten alias name:

    kasa --alias "TP-LINK_Smart Plug_8714" alias "Plug_8714"

Test, turn on:

    kasa --alias "Plug_8714" on