mirror of
https://github.com/nikdoof/hapz2m.git
synced 2026-01-30 15:08:19 +00:00
Mark old last_seen devices as "not responding"
Devices that have not received an update since a fixed timeout (24 hrs for now), based on its last_seen time, will be marked as "not responding" in the Home app. With this I can identify which devices are unreachable or dead. Also needed to upgrade hap with the fix for brutella/hap#30, or the entire bridge will stop working.
This commit is contained in:
11
bridge.go
11
bridge.go
@@ -410,6 +410,17 @@ func (br *Bridge) AddDevice(dev *Device, acc *accessory.A, mappings []*ExposeMap
|
||||
return nil, 0
|
||||
}
|
||||
}
|
||||
|
||||
m.Characteristic.ValueRequestFunc = func(req *http.Request) (any, int) {
|
||||
lastSeenSince := time.Since(brdev.LastSeen)
|
||||
|
||||
errCode := 0
|
||||
if lastSeenSince >= Z2M_LAST_SEEN_TIMEOUT {
|
||||
//log.Printf("dev %s last seen too long ago", name)
|
||||
errCode = hap.JsonStatusServiceCommunicationFailure
|
||||
}
|
||||
return m.Characteristic.Val, errCode
|
||||
}
|
||||
}
|
||||
|
||||
br.devices[name] = brdev
|
||||
|
||||
Reference in New Issue
Block a user