arlo-go/cmd/main.go

49 lines
992 B
Go
Raw Normal View History

2020-05-27 19:03:26 +00:00
package main
import (
"context"
2020-07-02 10:48:07 +00:00
"fmt"
"path"
"runtime"
2020-05-27 19:03:26 +00:00
"git.lehouerou.net/laurent/arlo-go"
log "github.com/sirupsen/logrus"
)
func main() {
2020-07-02 10:48:07 +00:00
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)
},
})
2020-05-27 19:03:26 +00:00
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)
}
}
2020-05-27 19:03:26 +00:00
for _, device := range a.Cameras {
2020-06-08 16:19:08 +00:00
if device.DeviceName == "Salon" {
motionChan := device.SubscribeToMotion()
2020-06-08 16:19:08 +00:00
for b := range motionChan {
log.Infof("motion salon %t", b)
}
2020-05-27 19:03:26 +00:00
}
}
}