Add custom category_id for HomeKit server #985 by @Minims
This commit is contained in:
@@ -24,6 +24,7 @@ func Init() {
|
|||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
DeviceID string `yaml:"device_id"`
|
DeviceID string `yaml:"device_id"`
|
||||||
DevicePrivate string `yaml:"device_private"`
|
DevicePrivate string `yaml:"device_private"`
|
||||||
|
CategoryID string `yaml:"category_id"`
|
||||||
Pairings []string `yaml:"pairings"`
|
Pairings []string `yaml:"pairings"`
|
||||||
} `yaml:"homekit"`
|
} `yaml:"homekit"`
|
||||||
}
|
}
|
||||||
@@ -88,7 +89,7 @@ func Init() {
|
|||||||
hap.TXTProtoVersion: "1.1",
|
hap.TXTProtoVersion: "1.1",
|
||||||
hap.TXTStateNumber: "1",
|
hap.TXTStateNumber: "1",
|
||||||
hap.TXTStatusFlags: hap.StatusNotPaired,
|
hap.TXTStatusFlags: hap.StatusNotPaired,
|
||||||
hap.TXTCategory: hap.CategoryCamera,
|
hap.TXTCategory: calcCategoryID(conf.CategoryID),
|
||||||
hap.TXTSetupHash: srv.hap.SetupHash(),
|
hap.TXTSetupHash: srv.hap.SetupHash(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -376,3 +376,16 @@ func calcDevicePrivate(private, seed string) []byte {
|
|||||||
b := sha512.Sum512([]byte(seed))
|
b := sha512.Sum512([]byte(seed))
|
||||||
return ed25519.NewKeyFromSeed(b[:ed25519.SeedSize])
|
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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user