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
+49
View File
@@ -0,0 +1,49 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import { createDeconzDiscoveryDescriptor } from '../../ts/integrations/deconz/index.js';
tap.test('matches deCONZ mDNS, SSDP, and manual discovery records', async () => {
const descriptor = createDeconzDiscoveryDescriptor();
const mdnsMatcher = descriptor.getMatchers().find((matcherArg) => matcherArg.id === 'deconz-mdns-match')!;
const ssdpMatcher = descriptor.getMatchers().find((matcherArg) => matcherArg.id === 'deconz-ssdp-match')!;
const manualMatcher = descriptor.getMatchers().find((matcherArg) => matcherArg.id === 'deconz-manual-match')!;
const validator = descriptor.getValidators()[0];
const mdnsResult = await mdnsMatcher.matches({
name: 'deCONZ-GW',
type: '_http._tcp.local.',
host: 'deconz.local',
port: 80,
txt: {
bridgeid: '00212EFFFF00C5FB',
modelid: 'deCONZ',
},
}, {});
expect(mdnsResult.matched).toBeTrue();
expect(mdnsResult.normalizedDeviceId).toEqual('00212EFFFF00C5FB');
const ssdpResult = await ssdpMatcher.matches({
ssdpLocation: 'http://192.168.1.55:80/description.xml',
upnp: {
manufacturer: 'Royal Philips Electronics',
manufacturerURL: 'http://www.dresden-elektronik.de',
modelName: 'deCONZ',
serialNumber: '00:21:2e:ff:ff:00:c5:fb',
},
}, {});
expect(ssdpResult.matched).toBeTrue();
expect(ssdpResult.candidate?.host).toEqual('192.168.1.55');
expect(ssdpResult.normalizedDeviceId).toEqual('00212EFFFF00C5FB');
const manualResult = await manualMatcher.matches({
host: '192.168.1.56',
name: 'Phoscon Gateway',
model: 'ConBee II',
}, {});
expect(manualResult.matched).toBeTrue();
expect(manualResult.candidate?.port).toEqual(80);
const validationResult = await validator.validate(manualResult.candidate!, {});
expect(validationResult.matched).toBeTrue();
});
export default tap.start();
+136
View File
@@ -0,0 +1,136 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import { DeconzMapper, type IDeconzSnapshot } from '../../ts/integrations/deconz/index.js';
const snapshot: IDeconzSnapshot = {
config: {
bridgeid: '00212EFFFF00C5FB',
name: 'RaspBee GW',
devicename: 'ConBee II',
modelid: 'deCONZ',
swversion: '2.26.3',
rfconnected: true,
websocketport: 8088,
},
lights: {
'1': {
name: 'Kitchen Ceiling',
manufacturername: 'IKEA',
modelid: 'TRADFRI bulb E27',
type: 'Extended color light',
uniqueid: '00:0b:57:ff:fe:9a:46:ab-01',
state: {
on: true,
bri: 204,
ct: 370,
reachable: true,
},
},
'2': {
name: 'Counter Plug',
manufacturername: 'dresden elektronik',
modelid: 'Smart plug',
type: 'Smart plug',
uniqueid: '00:0b:57:ff:fe:9a:46:ac-01',
state: {
on: false,
reachable: true,
},
},
'3': {
name: 'Living Blind',
manufacturername: 'ubisys',
modelid: 'J1',
type: 'Window covering device',
uniqueid: '00:0b:57:ff:fe:9a:46:ad-01',
state: {
open: true,
lift: 25,
reachable: true,
},
},
},
groups: {
'4': {
name: 'Living Room',
lights: ['1', '3'],
state: {
all_on: false,
any_on: true,
},
action: {
on: true,
bri: 128,
},
},
},
sensors: {
'5': {
name: 'Hall Temperature',
manufacturername: 'Xiaomi',
modelid: 'lumi.weather',
type: 'ZHATemperature',
uniqueid: '00:15:8d:00:01:aa:bb:cc-01-0402',
config: {
battery: 88,
on: true,
reachable: true,
},
state: {
temperature: 2150,
lastupdated: '2026-05-05T08:00:00',
},
},
'6': {
name: 'Hall Motion',
manufacturername: 'Philips',
modelid: 'SML001',
type: 'ZHAPresence',
uniqueid: '00:17:88:01:02:03:04:05-02-0406',
config: {
lowbattery: false,
on: true,
reachable: true,
},
state: {
presence: true,
lastupdated: '2026-05-05T08:01:00',
},
},
'7': {
name: 'Radiator',
manufacturername: 'Eurotronic',
modelid: 'SPZB0001',
type: 'ZHAThermostat',
uniqueid: '00:15:8d:00:01:aa:bb:dd-01-0201',
config: {
heatsetpoint: 2200,
locked: false,
mode: 'heat',
on: true,
reachable: true,
},
state: {
temperature: 2010,
lastupdated: '2026-05-05T08:02:00',
},
},
},
};
tap.test('maps deCONZ lights, groups, sensors, covers, and climate entities', async () => {
const devices = DeconzMapper.toDevices(snapshot);
const entities = DeconzMapper.toEntities(snapshot);
expect(devices.some((deviceArg) => deviceArg.id === 'deconz.gateway.00212effff00c5fb')).toBeTrue();
expect(devices.some((deviceArg) => deviceArg.features.some((featureArg) => featureArg.capability === 'cover'))).toBeTrue();
expect(entities.find((entityArg) => entityArg.id === 'light.kitchen_ceiling')?.state).toEqual('on');
expect(entities.find((entityArg) => entityArg.id === 'switch.counter_plug')?.state).toEqual('off');
expect(entities.find((entityArg) => entityArg.id === 'cover.living_blind')?.attributes?.position).toEqual(75);
expect(entities.find((entityArg) => entityArg.id === 'light.living_room')?.attributes?.isDeconzGroup).toEqual(true);
expect(entities.find((entityArg) => entityArg.id === 'sensor.hall_temperature')?.state).toEqual(21.5);
expect(entities.find((entityArg) => entityArg.id === 'binary_sensor.hall_motion')?.state).toEqual('on');
expect(entities.find((entityArg) => entityArg.id === 'climate.radiator')?.attributes?.targetTemperature).toEqual(22);
});
export default tap.start();