add variable system + fix bugs here and there.

This commit is contained in:
2023-01-13 01:19:34 +01:00
parent 88036cfcae
commit 842f96d8e3
22 changed files with 368 additions and 43 deletions
+10 -3
View File
@@ -243,7 +243,7 @@ func (b *Bridge) ApplyPatches(date time.Time, resources []ResourceData) (eventLi
SecondsSince: 0,
})
lastMotionCopy[resource.ID] = time.Now()
lastMotionCopy[b.fullId(resource)] = time.Now()
}
}
if resource.Button != nil {
@@ -331,6 +331,13 @@ func (b *Bridge) Run(ctx context.Context, bus *lucifer3.EventBus) interface{} {
return errors.New("failed to connect to bridge")
}
bus.RunEvent(events.Log{
ID: "hue:" + b.host,
Level: "info",
Code: "hue_bridge_starting",
Message: "Bridge is connecting...",
})
go b.makeCongruentLoop(ctx)
bus.RunEvents(hwEvents)
@@ -380,8 +387,8 @@ func (b *Bridge) Run(ctx context.Context, bus *lucifer3.EventBus) interface{} {
for id, value := range lastMotion {
since := time.Since(value)
sinceMod := since % time.Minute
if since > time.Second*30 && (sinceMod <= time.Second*5) {
sinceMod := since % (time.Second * 30)
if sinceMod >= time.Second*27 || sinceMod <= time.Second*3 {
bus.RunEvent(events.MotionSensed{ID: id, SecondsSince: since.Seconds()})
}
}