Skip to content

Commit

Permalink
Fixed Subcommand Calls
Browse files Browse the repository at this point in the history
  • Loading branch information
stegm committed Dec 11, 2024
1 parent b93f089 commit 0508412
Showing 1 changed file with 40 additions and 10 deletions.
50 changes: 40 additions & 10 deletions pykoplenti/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,20 @@ async def fn(client: ApiClient):
@click.option("--begin", type=click.DateTime(["%Y-%m-%d"]), help="first day to export")
@click.option("--end", type=click.DateTime(["%Y-%m-%d"]), help="last day to export")
@pass_global_args
def download_log(global_args, out, begin, end):
def download_log(global_args: GlobalArgs, out, begin, end):
"""Download the log data from the inverter to a file."""

async def fn(client: ApiClient):
await client.download_logdata(writer=out, begin=begin, end=end)

asyncio.run(
command_main(global_args.host, global_args.port, global_args.passwd, fn)
command_main(
global_args.host,
global_args.port,
global_args.key,
global_args.service_code,
fn,
)
)


Expand Down Expand Up @@ -394,7 +400,7 @@ async def fn(client: ApiClient):
@cli.command()
@click.argument("ids", required=True, nargs=-1)
@pass_global_args
def read_processdata(global_args, ids):
def read_processdata(global_args: GlobalArgs, ids):
"""Returns the values of the given process data.
IDS is the identifier (<module_id>/<processdata_id>) of one or more processdata
Expand Down Expand Up @@ -428,7 +434,13 @@ async def fn(client: ApiClient):
print(f"{k}/{x.id}={x.value}")

asyncio.run(
command_main(global_args.host, global_args.port, global_args.passwd, fn)
command_main(
global_args.host,
global_args.port,
global_args.key,
global_args.service_code,
fn,
)
)


Expand All @@ -437,7 +449,7 @@ async def fn(client: ApiClient):
"--rw", is_flag=True, default=False, help="display only writable settings"
)
@pass_global_args
def all_settings(global_args, rw):
def all_settings(global_args: GlobalArgs, rw: bool):
"""Returns the ids of all settings."""

async def fn(client: ApiClient):
Expand All @@ -448,14 +460,20 @@ async def fn(client: ApiClient):
print(f"{k}/{x.id}")

asyncio.run(
command_main(global_args.host, global_args.port, global_args.passwd, fn)
command_main(
global_args.host,
global_args.port,
global_args.key,
global_args.service_code,
fn,
)
)


@cli.command()
@click.argument("ids", required=True, nargs=-1)
@pass_global_args
def read_settings(global_args, ids):
def read_settings(global_args: GlobalArgs, ids):
"""Read the value of the given settings.
IDS is the identifier (<module_id>/<setting_id>) of one or more settings to read
Expand Down Expand Up @@ -486,14 +504,20 @@ async def fn(client: ApiClient):
print(f"{k}/{i}={v}")

asyncio.run(
command_main(global_args.host, global_args.port, global_args.passwd, fn)
command_main(
global_args.host,
global_args.port,
global_args.key,
global_args.service_code,
fn,
)
)


@cli.command()
@click.argument("id_values", required=True, nargs=-1)
@pass_global_args
def write_settings(global_args, id_values):
def write_settings(global_args: GlobalArgs, id_values):
"""Write the values of the given settings.
ID_VALUES is the identifier plus the the value to write
Expand Down Expand Up @@ -522,7 +546,13 @@ async def fn(client: ApiClient):
await client.set_setting_values(module_id, setting_values)

asyncio.run(
command_main(global_args.host, global_args.port, global_args.passwd, fn)
command_main(
global_args.host,
global_args.port,
global_args.key,
global_args.service_code,
fn,
)
)


Expand Down

0 comments on commit 0508412

Please sign in to comment.