-
-
Save kevink/fb7678d9b7745972de86c975c741a81a to your computer and use it in GitHub Desktop.
ArloQ Camers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"github.com/jeffreydwalter/arlo-go" | |
"github.com/spf13/viper" | |
) | |
// Currently failing with "Failed to turn on: failed to reconnect to event stream: failed to turn camera on: basestation not connected to event stream" | |
func main() { | |
viper.AutomaticEnv() | |
// Look in environment variables for User and Password | |
userName := viper.GetString("ARLO_USER") | |
pass := viper.GetString("ARLO_PASS") | |
// Instantiating the Arlo object automatically calls Login(), which returns an oAuth token that gets cached. | |
// Subsequent successful calls to login will update the oAuth token. | |
arlo, err := arlo.Login(userName, pass) | |
if err != nil { | |
log.Printf("Failed to login: %s\n", err) | |
return | |
} | |
// At this point you're logged into Arlo. | |
devices, err := arlo.GetDevices() | |
if err != nil { | |
log.Printf("Failed to Get Devices: %s\n", err) | |
return | |
} | |
//fmt.Printf("devices %#v\n", devices) | |
cameras := devices.GetCameras() | |
for _, camera := range *cameras { | |
//camera.ParentId = camera.DeviceId | |
fmt.Println(camera.DeviceId) | |
fmt.Println(camera.DeviceName) | |
resp, err := camera.On() | |
if err != nil { | |
fmt.Printf("Failed to turn on: %s\n", err) | |
return | |
} | |
fmt.Println(resp) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment