Quick fix for the lights turning on in the middle of the night
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Dreaded_X 2022-12-29 02:39:43 +01:00
parent d42afecd67
commit d6bbd78bec
Signed by: Dreaded_X
GPG Key ID: 76BDEC4E165D8AD9

View File

@ -39,6 +39,11 @@ func DevicesHandler(client paho.Client, prefix string, home *home.Home) {
// @TODO Instead of sending a sync request we should do something like home.sync <- interface{}
// This will then restart a timer, that way the sync will only trigger once everything has settled from multiple locations
home.Service.RequestSync(context.Background(), home.Username)
// Unsubscribe again, otherwise updates here will re-add all the devices which causes issues with the light sensor
if token := client.Unsubscribe(fmt.Sprintf("%s/bridge/devices", prefix)); token.Wait() && token.Error() != nil {
log.Println(token.Error())
}
}
if token := client.Subscribe(fmt.Sprintf("%s/bridge/devices", prefix), 1, handler); token.Wait() && token.Error() != nil {