cleanup todos that are done

This commit is contained in:
Sam Lewis
2022-10-17 12:37:36 -04:00
parent b92147a6a6
commit ccd6805d40
3 changed files with 5 additions and 7 deletions

5
app.go
View File

@@ -67,9 +67,8 @@ func (a *app) RegisterSchedule(s schedule) {
log.Fatalln("A schedule must call either Daily() or Every() when built.")
}
// TODO: consider moving all time stuff to carbon?
now := time.Now()
startTime := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location()) // start at midnight today
startTime := carbon.Now().StartOfDay().Carbon2Time()
// apply offset if set
if s.offset.Minutes() > 0 {
startTime = startTime.Add(s.offset)
@@ -81,7 +80,7 @@ func (a *app) RegisterSchedule(s schedule) {
}
s.realStartTime = startTime
a.schedules.Insert(s, float64(startTime.Unix())) // TODO: this blows up because schedule can't be used as key for map in prio queue lib. Just copy/paste and tweak as needed
a.schedules.Insert(s, float64(startTime.Unix()))
}
func (a *app) RegisterEntityListener(el entityListener) {

View File

@@ -15,13 +15,13 @@ func main() {
Call(pantryLights).
Build()
app.RegisterEntityListener(pantryDoor)
app.RegisterSchedule(ga.ScheduleBuilder().Call(cool).Every("5s").Build())
app.Start()
}
func pantryLights(service *ga.Service, data ga.EntityData) {
// service.InputDatetime.Set("input_datetime.garage_last_triggered_ts", time.Now())
// service.HomeAssistant.Toggle("group.living_room_lamps", map[string]any{"brightness_pct": 100})
// service.Light.Toggle("light.entryway_lamp", map[string]any{"brightness_pct": 100})
if data.ToState == "on" {
@@ -32,6 +32,7 @@ func pantryLights(service *ga.Service, data ga.EntityData) {
}
func cool(service *ga.Service, state *ga.State) {
// service.InputDatetime.Set("input_datetime.garage_last_triggered_ts", time.Now())
// service.Light.TurnOn("light.entryway_lamp")
// log.Default().Println("B")
}
@@ -43,5 +44,3 @@ func c(service *ga.Service, state *ga.State) {
func listenerCB(service *ga.Service, data ga.EntityData) {
log.Default().Println("hi katie")
}
// TODO: randomly placed, add .Throttle to Listener

View File

@@ -26,7 +26,7 @@ func (ib InputDatetime) Set(entityId string, value time.Time) {
"timestamp": fmt.Sprint(value.Unix()),
}
ws.WriteMessage(req, ib.conn, ib.ctx) // TODO: this ain't working for some reason
ws.WriteMessage(req, ib.conn, ib.ctx)
}
func (ib InputDatetime) Reload() {