Skip to content

Commit b52ed31

Browse files
support fade timers
1 parent 52369be commit b52ed31

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

cmd/kasa/main.go

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,86 @@ func main() {
536536
return nil
537537
},
538538
},
539+
{
540+
Name: "setfadeontime",
541+
Usage: "set fade on time",
542+
ArgsUsage: "time in ms",
543+
Arguments: []cli.Argument{
544+
&cli.StringArg{Name: "host", Min: 1, Max: 1, Destination: &host},
545+
&cli.StringArg{Name: "time", Min: 1, Max: 1, Destination: &value},
546+
},
547+
Action: func(ctx context.Context, cmd *cli.Command) error {
548+
k, err := getKasaDevice(cmd)
549+
if err != nil {
550+
return err
551+
}
552+
fade, err := strconv.Atoi(value)
553+
if err != nil {
554+
return err
555+
}
556+
return k.SetFadeOnTime(fade)
557+
},
558+
},
559+
{
560+
Name: "setfadeoofftime",
561+
Usage: "set fade off time",
562+
ArgsUsage: "time in ms",
563+
Arguments: []cli.Argument{
564+
&cli.StringArg{Name: "host", Min: 1, Max: 1, Destination: &host},
565+
&cli.StringArg{Name: "time", Min: 1, Max: 1, Destination: &value},
566+
},
567+
Action: func(ctx context.Context, cmd *cli.Command) error {
568+
k, err := getKasaDevice(cmd)
569+
if err != nil {
570+
return err
571+
}
572+
fade, err := strconv.Atoi(value)
573+
if err != nil {
574+
return err
575+
}
576+
return k.SetFadeOffTime(fade)
577+
},
578+
},
579+
{
580+
Name: "setgentleontime",
581+
Usage: "set gentle on time",
582+
ArgsUsage: "time in ms",
583+
Arguments: []cli.Argument{
584+
&cli.StringArg{Name: "host", Min: 1, Max: 1, Destination: &host},
585+
&cli.StringArg{Name: "time", Min: 1, Max: 1, Destination: &value},
586+
},
587+
Action: func(ctx context.Context, cmd *cli.Command) error {
588+
k, err := getKasaDevice(cmd)
589+
if err != nil {
590+
return err
591+
}
592+
fade, err := strconv.Atoi(value)
593+
if err != nil {
594+
return err
595+
}
596+
return k.SetGentleOnTime(fade)
597+
},
598+
},
599+
{
600+
Name: "setgentleoofftime",
601+
Usage: "set gentle off time",
602+
ArgsUsage: "time in ms",
603+
Arguments: []cli.Argument{
604+
&cli.StringArg{Name: "host", Min: 1, Max: 1, Destination: &host},
605+
&cli.StringArg{Name: "time", Min: 1, Max: 1, Destination: &value},
606+
},
607+
Action: func(ctx context.Context, cmd *cli.Command) error {
608+
k, err := getKasaDevice(cmd)
609+
if err != nil {
610+
return err
611+
}
612+
fade, err := strconv.Atoi(value)
613+
if err != nil {
614+
return err
615+
}
616+
return k.SetGentleOffTime(fade)
617+
},
618+
},
539619
{
540620
Name: "emeter",
541621
Usage: "check energy usage",

0 commit comments

Comments
 (0)