Add native Roku integration

This commit is contained in:
2026-05-05 12:32:02 +00:00
parent 5efb2f6760
commit 1f5ab6802d
12 changed files with 631 additions and 30 deletions
+20
View File
@@ -0,0 +1,20 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import { createRokuDiscoveryDescriptor } from '../../ts/integrations/roku/index.js';
tap.test('matches Roku ECP SSDP records', async () => {
const descriptor = createRokuDiscoveryDescriptor();
const matcher = descriptor.getMatchers()[0];
const result = await matcher.matches({
st: 'roku:ecp',
usn: 'uuid:roku-ecp-123456::roku:ecp',
location: 'http://192.168.1.60:8060/',
headers: {
manufacturer: 'Roku',
},
}, {});
expect(result.matched).toBeTrue();
expect(result.candidate?.host).toEqual('192.168.1.60');
expect(result.normalizedDeviceId).toEqual('roku-ecp-123456');
});
export default tap.start();
+28
View File
@@ -0,0 +1,28 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import { RokuMapper } from '../../ts/integrations/roku/index.js';
const snapshot = {
deviceInfo: {
deviceId: 'roku-ecp-123456',
vendorName: 'Roku',
modelName: 'Roku Streaming Stick',
friendlyDeviceName: 'Living Room Roku',
powerMode: 'PowerOn',
},
apps: [
{ id: '12', name: 'Netflix' },
{ id: '13', name: 'Prime Video' },
],
activeApp: { id: '12', name: 'Netflix' },
};
tap.test('maps Roku ECP snapshots to media devices and entities', async () => {
const devices = RokuMapper.toDevices(snapshot);
const entities = RokuMapper.toEntities(snapshot);
expect(devices[0].id).toEqual('roku.device.roku_ecp_123456');
expect(devices[0].state.some((stateArg) => stateArg.featureId === 'active_app' && stateArg.value === 'Netflix')).toBeTrue();
expect(entities[0].platform).toEqual('media_player');
expect(entities[0].state).toEqual('on');
});
export default tap.start();