Add custom category_id for HomeKit server #985 by @Minims

This commit is contained in:
Alex X
2025-11-18 20:52:32 +03:00
parent 6c78b5cb53
commit 290e8fcfda
2 changed files with 15 additions and 1 deletions
+2 -1
View File
@@ -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(),
},
}
+13
View File
@@ -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
}