49 lines
992 B
Go
49 lines
992 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"path"
|
|
"runtime"
|
|
|
|
"git.lehouerou.net/laurent/arlo-go"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func main() {
|
|
log.SetLevel(log.TraceLevel)
|
|
log.SetFormatter(&log.TextFormatter{
|
|
ForceColors: true,
|
|
FullTimestamp: true,
|
|
TimestampFormat: "02-01-2006 15:04:05",
|
|
CallerPrettyfier: func(f *runtime.Frame) (string, string) {
|
|
filename := path.Base(f.File)
|
|
return fmt.Sprintf("%s()", f.Function), fmt.Sprintf("%s:%d", filename, f.Line)
|
|
},
|
|
})
|
|
ctx := context.Background()
|
|
a := arlo.NewArlo()
|
|
err := a.Login(ctx, "hass@lehouerou.net", "TiPXMVLUeZfUg6RrmwzK")
|
|
if err != nil {
|
|
log.Errorf("login: %v", err)
|
|
return
|
|
}
|
|
for _, device := range a.Cameras {
|
|
err := device.RefreshState(ctx)
|
|
if err != nil {
|
|
log.Errorf("%v", err)
|
|
}
|
|
}
|
|
|
|
for _, device := range a.Cameras {
|
|
if device.DeviceName == "Salon" {
|
|
motionChan := device.SubscribeToMotion()
|
|
for b := range motionChan {
|
|
log.Infof("motion salon %t", b)
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|