Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

cli.py usage year and month options do not output data as expected #373

Copy link
Copy link
@jules43

Description

@jules43
Issue body actions

The kasa.exe (cli.py) usage option is intended to output a comma separated list of day,minutes or month,minutes instead it outputs the raw list/dict data.

A way to fix this is with the following code in the usage function (note I added a sort that may be redundant):

    if year:
        click.echo(f"== For year {year.year} ==")
        click.echo("Month, usage (minutes)")
        usage_data = await usage.get_monthstat(year=year.year)
        
        period="month"
        
    elif month:
        click.echo(f"== For month {month.month} of {month.year} ==")
        click.echo("Day, usage (minutes)")
        usage_data = await usage.get_daystat(year=month.year, month=month.month)

       period="day"

    else:
        # Call with no argument outputs summary data and returns
        click.echo("Today: %s minutes" % usage.usage_today)
        click.echo("This month: %s minutes" % usage.usage_this_month)

        return
        
    # output any detailed usage data
    usage_data = usage_data.get(period + "_list")
    usage_data.sort(key = lambda item: item.get(period))
    for usage in usage_data:
        click.echo(f'{usage.get(period)}, {usage.get("time")}')

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.