-
Notifications
You must be signed in to change notification settings - Fork 69
My bridged device are not all showing up on Home Kit #1014
-
Hello, it's another time me... I have a serious problem. I am creating a bridge of n devices to display them on Home Kit, Google Home, etc. with one QR code. The problem I actually have is that on Google Home when I add the bridge on it all is good, but on Home Kit I only have one device instead of all the devices (I have made the test with 3 devices and I onlly get one). Here is the code I use: const {
server, uniqueId,
} = await initializeServer(
'Matter Bridge test',
AggregatorEndpoint.deviceType,
false,
0,
)
const {
XXXX, aggregatorArray, remoteInstance,
} = await getDevicesCreateAggregator(server)
const promise = XXXX.map(async (deviceConnect: Device, index: number) => {
const device = XXXXXXX
const deviceName = device.name
const basicEndpoint = new Endpoint(
ColorDimmenOnOffEndpoint.with(ColorControlServer.with(
ColorControl.Feature.HueSaturation,
), BridgedDeviceBasicInformationServer),
{
id: `BasicController-${deviceName}-${index}`,
bridgedDeviceBasicInformation: {
nodeLabel: deviceName,
productName: `${deviceName}-1`,
productLabel: deviceName,
serialNumber: `node-matter-${index}`,
reachable: true,
},
},
)
const speedEndpoint = new Endpoint(
DimmerEndpoint.with(BridgedDeviceBasicInformationServer),
{
id: 'SpeedControl',
bridgedDeviceBasicInformation: {
nodeLabel: deviceName, // Main end user name for the device
productName: `${deviceName}-2`,
productLabel: deviceName,
serialNumber: `node-matter-${index}`,
reachable: true,
},
onOff: {
globalSceneControl: true,
},
},
)
await aggregatorArray[index].add(basicEndpoint)
await aggregatorArray[index].add(speedEndpoint)
})
await Promise.all(promise)
await server.bringOnline()
logEndpoint(EndpointServer.forEndpoint(server)) export default async function initializeServer(
name: string,
deviceType: DeviceTypeId,
isMultiDevice: boolean,
index: number,
) {
const {
deviceName,
vendorName,
productName,
passcode,
discriminator,
vendorId,
productId,
port,
uniqueId,
} = await initializeConfig(name, isMultiDevice)
const finalPort = isMultiDevice ? port + index : port
const config = {
id: uniqueId,
network: {
port: finalPort,
},
commissioning: {
passcode,
discriminator,
},
productDescription: {
name: deviceName,
deviceType,
},
basicInformation: {
vendorName,
vendorId: VendorId(vendorId),
nodeLabel: productName,
productName,
productLabel: productName,
productId,
serialNumber: `matterjs-serial-number-1`,
uniqueId,
},
}
const server = await ServerNode.create(config)
return {
server,
uniqueId,
}
} export default async function initializeConfig(name: string, isMultiDevice: boolean) {
const NAMESPACE = XXXXX
const environement = MatterBridgeEnvironment()
const storageService = environement .get(StorageService)
const deviceStorage = (await storageService.open('device')).createContext('data')
const {
vendorName, deviceName, vendorId, productId, port,
} = DeviceConfig
const passcode = isMultiDevice ? await getRandomNumber(8, null) : environement .vars.number('passcode') ?? (await deviceStorage.get('passcode', await getRandomNumber(8, null)))
const discriminator = isMultiDevice ? await getRandomNumber(4, 4095) : environement .vars.number('discriminator') ?? (await deviceStorage.get('discriminator', await getRandomNumber(4, 4095)))
const productName = `${name}`
const uniqueId = `${uuidv5(name, NAMESPACE).replace(/-/g, '')}`
await deviceStorage.set({
passcode,
discriminator,
vendorid: vendorId,
productid: productId,
uniqueid: uniqueId,
})
return {
deviceName,
vendorName,
passcode,
discriminator,
vendorId,
productName,
productId,
port,
uniqueId,
}
} async function createAggregators(
XXXXXX,
server: ServerNode<ServerNode.RootEndpoint>,
) {
const aggregatorArray:Array<Endpoint<AggregatorEndpoint>> = []
const promise = XXXXXX.map(async (XXXXX) => {
const aggregator = new Endpoint(AggregatorEndpoint, { id: `aggregator-${XXXXX}` })
await server.add(aggregator)
aggregatorArray.push(aggregator)
})
await Promise.all(promise)
return aggregatorArray
}
export default async function getDevicesCreateAggregator(
server: ServerNode<ServerNode.RootEndpoint>,
) {
const aggregatorArray = await createAggregators(XXXXXXX, server)
return {
XXXXXX,
aggregatorArray,
XXXXXXX,
}
} I hope you can help me resolve this because I really don't know if it's due to my code are to home kit Thank you |
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment · 5 replies
-
Why you have multiple aggregators? You just need to have one and ll devices needs to be added there. Please adjust this and then post the log putput of this logEndpoint call ... this shows exactly which structure you have built |
Beta Was this translation helpful? Give feedback.
All reactions
-
So when I want multiple device wich contain multiple Endpoint only one aggregator is needed ? |
Beta Was this translation helpful? Give feedback.
All reactions
-
I have set only one aggregator and now I don't see device on Home Kit anymore... On Google Home, all works well here's the change I made:
|
Beta Was this translation helpful? Give feedback.
All reactions
-
If you do such structure changes you need to delete and repair it! Buit as said: before pairing check the logged structure por post here that I can have a look it this looks right |
Beta Was this translation helpful? Give feedback.
All reactions
-
Here is the log before connect to the device:
|
Beta Was this translation helpful? Give feedback.
All reactions
-
I have clean up some part of code, delete and restore the env and it works now thank you for your help here are the logs if you want:
|
Beta Was this translation helpful? Give feedback.
Why you have multiple aggregators? You just need to have one and ll devices needs to be added there.
Please adjust this and then post the log putput of this logEndpoint call ... this shows exactly which structure you have built