After the call to deferLater() in maybe_change_power_state(), *before* adding the final errback to log.err, an errback that traps CancelledError ought to be added. That can log and call power_change_failure().
After the call to deferLater() in maybe_change_ power_state( ), *before* adding the final errback to log.err, an errback that traps CancelledError ought to be added. That can log and call power_change_ failure( ).