mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-09 18:07:15 -06:00
change helper from TimeOfDay to Duration
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
"log"
|
||||
|
||||
ga "github.com/saml-dev/gome-assistant"
|
||||
)
|
||||
@@ -10,18 +9,19 @@ import (
|
||||
func main() {
|
||||
app := ga.App("192.168.86.67:8123")
|
||||
defer app.Cleanup()
|
||||
s := ga.ScheduleBuilder().Call(lightsOut).Daily().At(ga.Sunset()).Build()
|
||||
s2 := ga.ScheduleBuilder().Call(lightsOut).Every(time.Hour*4 + time.Minute*30).Offset(ga.TimeOfDay(1, 0)).Build()
|
||||
s := ga.ScheduleBuilder().Call(lightsOut).Daily().At(ga.Duration(23, 00)).Build()
|
||||
s2 := ga.ScheduleBuilder().Call(lightsOut).Every(ga.Duration(04, 30)).Offset(ga.Duration(1, 0)).Build()
|
||||
app.RegisterSchedule(s2)
|
||||
app.Start()
|
||||
|
||||
simpleListener := ga.EntityListenerBuilder().
|
||||
EntityId("light.lights").
|
||||
Call(cool).
|
||||
OnlyBetween(ga.TimeOfDay(22, 00), ga.TimeOfDay(07, 00))
|
||||
fmt.Println(simpleListener)
|
||||
OnlyBetween(ga.Duration(22, 00), ga.Duration(07, 00))
|
||||
log.Println(simpleListener)
|
||||
|
||||
fmt.Println(s, "\n", s2)
|
||||
log.Println(s)
|
||||
log.Println(s2)
|
||||
}
|
||||
|
||||
func lightsOut(service ga.Service, state ga.State) {
|
||||
|
||||
Reference in New Issue
Block a user