Files
go-ha/cmd/main/testing.go
Sam Lewis 7bcca889f9 good progress yay:
- impl http client
- create http client in App()
- generic builder for Service.*
- set Service on app to pass to callbacks later
- impl State
- set State on app to pass to callbacks later
- change panic to log.Fatalln
2022-10-11 01:22:23 -04:00

35 lines
813 B
Go

package main
import (
"fmt"
"time"
ga "github.com/saml-dev/gome-assistant"
)
func main() {
app := ga.App("192.168.86.67:8123")
defer app.Cleanup()
s := ga.ScheduleBuilder().Call(lightsOut).Daily().At(ga.Sunset.Subtract(ga.TimeOfDay(0, 30))).Build()
s2 := ga.ScheduleBuilder().Call(lightsOut).Every(time.Hour*4 + time.Minute*30).Offset(ga.TimeOfDay(1, 0)).Build()
app.RegisterSchedule(s2)
// err = app.Start()
simpleListener := ga.EntityListenerBuilder().
EntityId("light.lights").
Call(cool).
OnlyBetween(ga.TimeOfDay(22, 00), ga.TimeOfDay(07, 00))
fmt.Println(simpleListener)
fmt.Println(s, "\n", s2)
}
func lightsOut(service ga.Service, state ga.State) {
// ga.TurnOff("light.all_lights")
}
func cool(service ga.Service, data ga.Data) {
service.Light.TurnOn("light.entryway_lamp")
}