def timer(ctx, vac: mirobo.Vacuum): """List and modify existing timers.""" if ctx.invoked_subcommand is not None: return timers = vac.timer() click.echo("Timezone: %s\n" % vac.timezone()) for idx, timer in enumerate(timers): color = "green" if timer.enabled else "yellow" click.echo( click.style("Timer #%s, id %s (ts: %s)" % (idx, timer.id, timer.ts), bold=True, fg=color)) click.echo(" %s" % timer.cron) min, hr, x, y, days = timer.cron.split(' ') cron = "%s %s %s %s %s" % (min, hr, x, y, days) click.echo(" %s" % pretty_cron.prettify_cron(cron))
def timer(vac: mirobo.Vacuum, timer): """Schedule vacuuming, times in GMT.""" if timer: raise NotImplementedError() # vac.set_timer(x) pass else: timers = vac.timer() for idx, timer in enumerate(timers): color = "green" if timer.enabled else "yellow" # Note ts == ID for changes click.echo(click.style("Timer #%s, id %s (ts: %s)" % ( idx, timer.id, timer.ts), bold=True, fg=color)) print(" %s" % timer.cron) min, hr, x, y, days = timer.cron.split(' ') # hr is in gmt+8 (chinese time), TODO convert to local hr = (int(hr) - 8) % 24 cron = "%s %s %s %s %s" % (min, hr, x, y, days) click.echo(" %s" % pretty_cron.prettify_cron(cron))