Add native local network integrations

This commit is contained in:
2026-05-05 18:45:46 +00:00
parent 282283d344
commit cfab8c593e
70 changed files with 9688 additions and 176 deletions
@@ -0,0 +1,34 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import { BluetoothLeTrackerIntegration } from '../../ts/integrations/bluetooth_le_tracker/index.js';
tap.test('returns a clear unsupported response for live scans without injected data', async () => {
const runtime = await new BluetoothLeTrackerIntegration().setup({}, {});
const result = await runtime.callService!({
domain: 'bluetooth_le_tracker',
service: 'scan',
target: {},
});
expect(result.success).toBeFalse();
expect(String(result.error).includes('Live scanning is not implemented') || String(result.error).includes('live scanning is not implemented')).toBeTrue();
});
tap.test('accepts injected scan data and refreshes runtime devices', async () => {
const runtime = await new BluetoothLeTrackerIntegration().setup({ minSeenNew: 1 }, {});
const result = await runtime.callService!({
domain: 'bluetooth_le_tracker',
service: 'scan',
target: {},
data: {
advertisements: [{ address: 'AA:BB:CC:DD:EE:FF', name: 'Backpack Tag', rssi: -59, time: Date.now() }],
},
});
const devices = await runtime.devices();
const entities = await runtime.entities();
expect(result.success).toBeTrue();
expect(devices.some((deviceArg) => deviceArg.id === 'bluetooth_le_tracker.device.aa_bb_cc_dd_ee_ff')).toBeTrue();
expect(entities.some((entityArg) => entityArg.uniqueId === 'bluetooth_le_tracker_presence_aa_bb_cc_dd_ee_ff' && entityArg.state === 'on')).toBeTrue();
});
export default tap.start();