Add native camera and media service integrations
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||
import { BraviatvMapper } from '../../ts/integrations/braviatv/index.js';
|
||||
|
||||
const snapshot = {
|
||||
systemInfo: {
|
||||
cid: 'sony-cid-123',
|
||||
macAddr: 'AA:BB:CC:DD:EE:FF',
|
||||
name: 'Living Room Bravia',
|
||||
model: 'XR-55A80J',
|
||||
serial: '1000001',
|
||||
generation: '6.5.0',
|
||||
},
|
||||
state: {
|
||||
powerStatus: 'active' as const,
|
||||
power: 'on' as const,
|
||||
playback: 'playing' as const,
|
||||
source: 'HDMI 1',
|
||||
sourceUri: 'extInput:hdmi?port=1',
|
||||
volumeLevel: 0.35,
|
||||
muted: false,
|
||||
mediaTitle: 'Movie Night',
|
||||
},
|
||||
sources: [
|
||||
{ title: 'HDMI 1', uri: 'extInput:hdmi?port=1', type: 'input' as const },
|
||||
{ title: 'HDMI 2', uri: 'extInput:hdmi?port=2', type: 'input' as const },
|
||||
],
|
||||
apps: [
|
||||
{ title: 'Netflix', uri: 'com.sony.dtv.com.netflix.ninja', type: 'app' as const },
|
||||
{ title: 'YouTube', uri: 'com.sony.dtv.com.google.android.youtube.tv', type: 'app' as const },
|
||||
],
|
||||
channels: [],
|
||||
};
|
||||
|
||||
tap.test('maps Sony Bravia snapshots to media devices and entities', async () => {
|
||||
const devices = BraviatvMapper.toDevices(snapshot);
|
||||
const entities = BraviatvMapper.toEntities(snapshot);
|
||||
|
||||
expect(devices[0].id).toEqual('braviatv.device.sony_cid_123');
|
||||
expect(devices[0].state.some((stateArg) => stateArg.featureId === 'source' && stateArg.value === 'HDMI 1')).toBeTrue();
|
||||
expect(devices[0].state.some((stateArg) => stateArg.featureId === 'volume' && stateArg.value === 35)).toBeTrue();
|
||||
expect(entities[0].id).toEqual('media_player.living_room_bravia');
|
||||
expect(entities[0].platform).toEqual('media_player');
|
||||
expect(entities[0].state).toEqual('playing');
|
||||
expect((entities[0].attributes?.sourceList as string[]).includes('Netflix')).toBeTrue();
|
||||
expect(entities[0].attributes?.volumeLevel).toEqual(0.35);
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
Reference in New Issue
Block a user