feat(homekit): add HKSV support with motion detection and doorbell functionality
- Introduced HKSV configuration options in homekit.go, allowing for motion detection and doorbell features. - Implemented API endpoints for triggering motion detection and doorbell events. - Enhanced server.go to handle HKSV sessions and manage motion detection states. - Created new accessory types for HKSV and doorbell in accessory.go. - Added support for audio recording configurations in ch207.go. - Defined new services for motion detection and doorbell in services_hksv.go. - Implemented opack encoding/decoding for HDS protocol in opack.go and protocol.go. - Updated OpenAPI documentation to reflect new endpoints and features. - Extended schema.json to include HKSV configuration options.
This commit is contained in:
+19
-2
@@ -68,14 +68,31 @@ func ServerHandler(server Server) HandlerFunc {
|
||||
AID uint8 `json:"aid"`
|
||||
IID uint64 `json:"iid"`
|
||||
Value any `json:"value"`
|
||||
Event any `json:"ev"`
|
||||
} `json:"characteristics"`
|
||||
}
|
||||
if err := json.NewDecoder(req.Body).Decode(&v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, char := range v.Value {
|
||||
server.SetCharacteristic(conn, char.AID, char.IID, char.Value)
|
||||
for _, c := range v.Value {
|
||||
if c.Value != nil {
|
||||
server.SetCharacteristic(conn, c.AID, c.IID, c.Value)
|
||||
}
|
||||
if c.Event != nil {
|
||||
// subscribe/unsubscribe to events
|
||||
accs := server.GetAccessories(conn)
|
||||
for _, acc := range accs {
|
||||
if char := acc.GetCharacterByID(c.IID); char != nil {
|
||||
if ev, ok := c.Event.(bool); ok && ev {
|
||||
char.AddListener(conn)
|
||||
} else {
|
||||
char.RemoveListener(conn)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res := &http.Response{
|
||||
|
||||
Reference in New Issue
Block a user