diff --git a/app.go b/app.go index 372b3ad..b8a9905 100644 --- a/app.go +++ b/app.go @@ -86,6 +86,15 @@ func (a *App) RegisterSchedules(schedules ...Schedule) { } now := time.Now() + // TODO: on the day that daylight savings starts/ends, + // this results in schedules being an hour late or hour early because + // StartOfDay() occurs before the switch. This happens if you start + // gome assistant on this day, and VERIFY I think will persist until you + // start it again. Sunrise/sunset should be unaffected since those come + // from HA. + // + // IDEA: splitting schedule into Interval and DailySchedule could address this on schedule + // side, by using SetTime instead of Add(time.Duration). startTime := carbon.Now().StartOfDay().Carbon2Time() // apply offset if set if s.offset.Minutes() > 0 { diff --git a/entitylistener.go b/entitylistener.go index 132a8e8..59b1ef4 100644 --- a/entitylistener.go +++ b/entitylistener.go @@ -26,7 +26,8 @@ type EntityListener struct { exceptionRanges []timeRange } -// TODO: add state object as second arg +// TODO: add RunOnStartup() to etl, evl, schedule + type EntityListenerCallback func(*Service, *State, EntityData) type EntityData struct { diff --git a/eventListener.go b/eventListener.go index b0e6997..a85586d 100644 --- a/eventListener.go +++ b/eventListener.go @@ -22,7 +22,7 @@ type EventListener struct { } // TODO: add state object as second arg -type EventListenerCallback func(*Service, EventData) +type EventListenerCallback func(*Service, *State, EventData) type EventData struct { Type string @@ -130,7 +130,7 @@ func callEventListeners(app *App, msg ws.ChanMsg) { Type: baseEventMsg.Event.EventType, RawEventJSON: msg.Raw, } - go l.callback(app.service, eventData) + go l.callback(app.service, app.state, eventData) l.lastRan = carbon.Now() } } diff --git a/example/example.go b/example/example.go index af0dc74..69e6501 100644 --- a/example/example.go +++ b/example/example.go @@ -56,7 +56,7 @@ func pantryLights(service *ga.Service, state *ga.State, sensor ga.EntityData) { } } -func onEvent(service *ga.Service, data ga.EventData) { +func onEvent(service *ga.Service, state *ga.State, data ga.EventData) { // Since the structure of the event changes depending // on the event type, you can Unmarshal the raw json // into a Go type. If a type for your event doesn't