feat(homekit): add ONVIF motion detection support

- implement ONVIF motion watcher to handle motion events
- add configuration options for motion hold time and ONVIF URL
- remap motion mode from "onvif" to "api" for compatibility
- log ONVIF motion watcher activity for better debugging

feat(onvif): implement event subscription for motion detection
- create PullPoint subscription to receive motion events
- implement methods for pulling messages and renewing subscriptions
- handle event requests and responses specific to motion detection

test(onvif): add unit tests for motion event parsing and subscription
- create tests for parsing various motion event XML responses
- verify correct handling of multiple notifications and edge cases
- test resolving event addresses for ONVIF clients

fix(hksv): improve motion detection logging
- log warnings when accessory or character not found during motion detection
- log number of listeners notified during motion state changes

feat(hap): add listener count method
- introduce method to retrieve the number of listeners for a character

feat(onvif): enhance ONVIF client with event URL handling
- extract event URL from ONVIF device response for subscription management
This commit is contained in:
Sergey Krashevich
2026-03-09 13:06:57 +03:00
parent e3d1085a6d
commit 8a21809f18
10 changed files with 1004 additions and 3 deletions
+6 -2
View File
@@ -600,15 +600,19 @@ func (s *Server) GetImage(conn net.Conn, width, height int) []byte {
// SetMotionDetected triggers or clears the motion detected characteristic.
func (s *Server) SetMotionDetected(detected bool) {
if s.accessory == nil {
s.log.Warn().Str("stream", s.stream).Msg("[hksv] SetMotionDetected: accessory is nil")
return
}
char := s.accessory.GetCharacter("22") // MotionDetected
if char == nil {
s.log.Warn().Str("stream", s.stream).Msg("[hksv] SetMotionDetected: char 22 (MotionDetected) not found")
return
}
char.Value = detected
_ = char.NotifyListeners(nil)
s.log.Debug().Str("stream", s.stream).Bool("motion", detected).Msg("[hksv] motion")
listeners := char.ListenerCount()
err := char.NotifyListeners(nil)
s.log.Debug().Str("stream", s.stream).Bool("motion", detected).
Int("listeners", listeners).Err(err).Msg("[hksv] motion")
}
// MotionDetected returns the current motion detected state.