Skip to content

Commit

Permalink
add EnableCloud as requested in #7
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudkucooland committed Apr 16, 2024
1 parent 11daa4d commit 034aad4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/kasa/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ func main() {
if err != nil {
panic(err)
}
case "cloud":
if host == "" || value == "" || v2 == ""{
fmt.Println("usage: kasa cloud [host] [username] [password]")
return
}
err := k.EnableCloud(value, v2)
if err != nil {
panic(err)
}
case "switch":
if host == "" || value == "" {
fmt.Println("usage: kasa switch [host] [true|false]")
Expand Down
12 changes: 12 additions & 0 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,18 @@ func (d *Device) DisableCloud() error {
return nil
}

// Enable/Configure Cloud
func (d *Device) EnableCloud(username, password string) error {
cmd := fmt.Sprintf(CmdSetServerCreds, username, password)

err := d.sendUDP(cmd)
if err != nil {
klogger.Println(err.Error())
return err
}
return nil
}

// Reboot instructs the device to reboot
func (d *Device) Reboot() error {
err := d.sendUDP(CmdReboot)
Expand Down

0 comments on commit 034aad4

Please sign in to comment.