@@ -302,16 +302,13 @@ def timer(ctx, vac: mirobo.Vacuum):
302302 if ctx .invoked_subcommand is not None :
303303 return
304304 timers = vac .timer ()
305+ click .echo ("Timezone: %s\n " % vac .timezone ())
305306 for idx , timer in enumerate (timers ):
306307 color = "green" if timer .enabled else "yellow"
307- # Note ts == ID for changes
308308 click .echo (click .style ("Timer #%s, id %s (ts: %s)" % (
309309 idx , timer .id , timer .ts ), bold = True , fg = color ))
310- print (" %s" % timer .cron )
310+ click . echo (" %s" % timer .cron )
311311 min , hr , x , y , days = timer .cron .split (' ' )
312- # hr is in gmt+8 (chinese time), TODO convert to local
313- if hr != '*' :
314- hr = (int (hr ) - 8 ) % 24
315312 cron = "%s %s %s %s %s" % (min , hr , x , y , days )
316313 click .echo (" %s" % pretty_cron .prettify_cron (cron ))
317314
@@ -322,29 +319,30 @@ def timer(ctx, vac: mirobo.Vacuum):
322319@click .option ('--params' , default = '' , required = False )
323320@pass_dev
324321def add (vac : mirobo .Vacuum , cron , command , params ):
325- """Schedule vacuuming. ."""
322+ """Add a timer ."""
326323 click .echo (vac .add_timer (cron , command , params ))
327324
328325
329326@timer .command ()
330327@click .argument ('timer_id' , type = int , required = True )
331328@pass_dev
332329def delete (vac : mirobo .Vacuum , timer_id ):
333- """Delete existing schedule ."""
330+ """Delete a timer ."""
334331 click .echo (vac .delete_timer (timer_id ))
335332
336333
337334@timer .command ()
338335@click .argument ('timer_id' , type = int , required = True )
339- @click .option ('--on ' , is_flag = True )
340- @click .option ('--off ' , is_flag = True )
336+ @click .option ('--enable ' , is_flag = True )
337+ @click .option ('--disable ' , is_flag = True )
341338@pass_dev
342- def update (vac : mirobo .Vacuum , timer_id , on , off ):
343- """Update (on or off) an existing scheduled."""
344- if on and not off :
345- vac .update_timer (timer_id , "on" )
346- elif off and not on :
347- vac .update_timer (timer_id , "off" )
339+ def update (vac : mirobo .Vacuum , timer_id , enable , disable ):
340+ """Enable/disable a timer."""
341+ from mirobo .vacuum import TimerState
342+ if enable and not disable :
343+ vac .update_timer (timer_id , TimerState .On )
344+ elif disable and not enable :
345+ vac .update_timer (timer_id , TimerState .Off )
348346 else :
349347 click .echo ("Only 'on' and 'off' are valid for timer" )
350348
0 commit comments