From 290e8fcfda3c28207f30cf736a722fd725efaf60 Mon Sep 17 00:00:00 2001 From: Alex X Date: Tue, 18 Nov 2025 20:52:32 +0300 Subject: [PATCH] Add custom category_id for HomeKit server #985 by @Minims --- internal/homekit/homekit.go | 3 ++- internal/homekit/server.go | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/internal/homekit/homekit.go b/internal/homekit/homekit.go index 4de49624..98988806 100644 --- a/internal/homekit/homekit.go +++ b/internal/homekit/homekit.go @@ -24,6 +24,7 @@ func Init() { Name string `yaml:"name"` DeviceID string `yaml:"device_id"` DevicePrivate string `yaml:"device_private"` + CategoryID string `yaml:"category_id"` Pairings []string `yaml:"pairings"` } `yaml:"homekit"` } @@ -88,7 +89,7 @@ func Init() { hap.TXTProtoVersion: "1.1", hap.TXTStateNumber: "1", hap.TXTStatusFlags: hap.StatusNotPaired, - hap.TXTCategory: hap.CategoryCamera, + hap.TXTCategory: calcCategoryID(conf.CategoryID), hap.TXTSetupHash: srv.hap.SetupHash(), }, } diff --git a/internal/homekit/server.go b/internal/homekit/server.go index 57e97287..25082e4e 100644 --- a/internal/homekit/server.go +++ b/internal/homekit/server.go @@ -376,3 +376,16 @@ func calcDevicePrivate(private, seed string) []byte { b := sha512.Sum512([]byte(seed)) return ed25519.NewKeyFromSeed(b[:ed25519.SeedSize]) } + +func calcCategoryID(categoryID string) string { + switch categoryID { + case "bridge": + return hap.CategoryBridge + case "doorbell": + return hap.CategoryDoorbell + } + if core.Atoi(categoryID) > 0 { + return categoryID + } + return hap.CategoryCamera +}