Skip to content

Commit

Permalink
Add CLI for charge start/stop
Browse files Browse the repository at this point in the history
  • Loading branch information
rikroe committed Feb 19, 2023
1 parent 94765dd commit 3dd85f7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions bimmer_connected/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ def main_parser() -> argparse.ArgumentParser:
)
chargingprofile_parser.set_defaults(func=chargingprofile)

charge_parser = subparsers.add_parser("charge", description="Start/stop charging on enabled vehicles.")
_add_default_arguments(charge_parser)
charge_parser.add_argument("vin", help=TEXT_VIN)
charge_parser.add_argument("action", type=str, choices=["start", "stop"])
charge_parser.set_defaults(func=charge)

image_parser = subparsers.add_parser("image", description="Download a vehicle image.")
_add_default_arguments(image_parser)
image_parser.add_argument("vin", help=TEXT_VIN)
Expand Down Expand Up @@ -256,6 +262,17 @@ async def chargingprofile(args) -> None:
print(status.state)


async def charge(args) -> None:
"""Trigger a vehicle to start or stop charging."""
account = MyBMWAccount(
args.username, args.password, get_region_from_name(args.region), use_metric_units=(not args.imperial)
)
await account.get_vehicles()
vehicle = get_vehicle_or_return(account, args.vin)
status = await getattr(vehicle.remote_services, f"trigger_charge_{args.action.lower()}")()
print(status.state)


async def image(args) -> None:
"""Download a rendered image of the vehicle."""
account = MyBMWAccount(
Expand Down

0 comments on commit 3dd85f7

Please sign in to comment.