Files

33 lines
1.0 KiB
TypeScript
Raw Permalink Normal View History

2026-05-05 14:57:06 +00:00
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();