Add native hub protocol integrations

This commit is contained in:
2026-05-05 14:57:06 +00:00
parent 2823a1c718
commit 1eebd71e7d
102 changed files with 16316 additions and 330 deletions
+19
View File
@@ -0,0 +1,19 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import { createZhaDiscoveryDescriptor } from '../../ts/integrations/zha/index.js';
tap.test('matches known ZHA USB coordinator records', async () => {
const descriptor = createZhaDiscoveryDescriptor();
const matcher = descriptor.getMatchers().find((matcherArg) => matcherArg.id === 'zha-usb-match');
const result = await matcher!.matches({
vid: '10C4',
pid: 'EA60',
manufacturer: 'SONOFF',
description: 'SONOFF Zigbee 3.0 USB Dongle Plus',
path: '/dev/ttyUSB0',
}, {});
expect(result.matched).toBeTrue();
expect(result.candidate?.integrationDomain).toEqual('zha');
expect(result.candidate?.metadata?.radioPath).toEqual('/dev/ttyUSB0');
});
export default tap.start();
+32
View File
@@ -0,0 +1,32 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import { ZhaMapper } from '../../ts/integrations/zha/index.js';
const snapshot = ZhaMapper.toSnapshot({
radio: { path: '/dev/ttyUSB0', radioType: 'znp' },
coordinator: { ieee: '00:11:22:33:44:55:66:77', model: 'CC2652' },
devices: [{
ieee: 'aa:bb:cc:dd:ee:ff:00:11',
name: 'Kitchen light',
manufacturer: 'IKEA',
model: 'TRADFRI bulb',
available: true,
entities: [{
platform: 'light',
entityId: 'light.kitchen_light',
uniqueId: 'zha_kitchen_light',
name: 'Kitchen light',
isOn: true,
endpointId: 1,
clusterId: 6,
}],
}],
});
tap.test('maps ZHA devices and entities', async () => {
const devices = ZhaMapper.toDevices(snapshot);
const entities = ZhaMapper.toEntities(snapshot);
expect(devices.some((deviceArg) => deviceArg.id === 'zha.device.aa_bb_cc_dd_ee_ff_00_11')).toBeTrue();
expect(entities.some((entityArg) => entityArg.id === 'light.kitchen_light' && entityArg.state === 'on')).toBeTrue();
});
export default tap.start();