Add native Roku integration
This commit is contained in:
@@ -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();
|
||||
@@ -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();
|
||||
Reference in New Issue
Block a user