mirror of
https://github.com/Xevion/go-ha.git
synced 2025-12-06 23:15:09 -06:00
cleanup todos that are done
This commit is contained in:
5
app.go
5
app.go
@@ -67,9 +67,8 @@ func (a *app) RegisterSchedule(s schedule) {
|
|||||||
log.Fatalln("A schedule must call either Daily() or Every() when built.")
|
log.Fatalln("A schedule must call either Daily() or Every() when built.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: consider moving all time stuff to carbon?
|
|
||||||
now := time.Now()
|
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
|
// apply offset if set
|
||||||
if s.offset.Minutes() > 0 {
|
if s.offset.Minutes() > 0 {
|
||||||
startTime = startTime.Add(s.offset)
|
startTime = startTime.Add(s.offset)
|
||||||
@@ -81,7 +80,7 @@ func (a *app) RegisterSchedule(s schedule) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s.realStartTime = startTime
|
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) {
|
func (a *app) RegisterEntityListener(el entityListener) {
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ func main() {
|
|||||||
Call(pantryLights).
|
Call(pantryLights).
|
||||||
Build()
|
Build()
|
||||||
app.RegisterEntityListener(pantryDoor)
|
app.RegisterEntityListener(pantryDoor)
|
||||||
|
app.RegisterSchedule(ga.ScheduleBuilder().Call(cool).Every("5s").Build())
|
||||||
|
|
||||||
app.Start()
|
app.Start()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func pantryLights(service *ga.Service, data ga.EntityData) {
|
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.HomeAssistant.Toggle("group.living_room_lamps", map[string]any{"brightness_pct": 100})
|
||||||
// service.Light.Toggle("light.entryway_lamp", map[string]any{"brightness_pct": 100})
|
// service.Light.Toggle("light.entryway_lamp", map[string]any{"brightness_pct": 100})
|
||||||
if data.ToState == "on" {
|
if data.ToState == "on" {
|
||||||
@@ -32,6 +32,7 @@ func pantryLights(service *ga.Service, data ga.EntityData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func cool(service *ga.Service, state *ga.State) {
|
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")
|
// service.Light.TurnOn("light.entryway_lamp")
|
||||||
// log.Default().Println("B")
|
// log.Default().Println("B")
|
||||||
}
|
}
|
||||||
@@ -43,5 +44,3 @@ func c(service *ga.Service, state *ga.State) {
|
|||||||
func listenerCB(service *ga.Service, data ga.EntityData) {
|
func listenerCB(service *ga.Service, data ga.EntityData) {
|
||||||
log.Default().Println("hi katie")
|
log.Default().Println("hi katie")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: randomly placed, add .Throttle to Listener
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func (ib InputDatetime) Set(entityId string, value time.Time) {
|
|||||||
"timestamp": fmt.Sprint(value.Unix()),
|
"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() {
|
func (ib InputDatetime) Reload() {
|
||||||
|
|||||||
Reference in New Issue
Block a user