Add native camera and media service integrations

This commit is contained in:
2026-05-05 17:13:54 +00:00
parent 489d9d5243
commit e7441844c9
112 changed files with 18608 additions and 327 deletions
@@ -0,0 +1,47 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import { createJellyfinDiscoveryDescriptor } from '../../ts/integrations/jellyfin/index.js';
tap.test('matches manual Jellyfin server URLs', async () => {
const descriptor = createJellyfinDiscoveryDescriptor();
const matcher = descriptor.getMatchers().find((matcherArg) => matcherArg.id === 'jellyfin-manual-match');
const result = await matcher?.matches({
url: 'http://jellyfin.local:8096',
name: 'Home Jellyfin',
}, {});
expect(result?.matched).toBeTrue();
expect(result?.candidate?.host).toEqual('jellyfin.local');
expect(result?.candidate?.port).toEqual(8096);
});
tap.test('matches Jellyfin SSDP records', async () => {
const descriptor = createJellyfinDiscoveryDescriptor();
const matcher = descriptor.getMatchers().find((matcherArg) => matcherArg.id === 'jellyfin-ssdp-match');
const result = await matcher?.matches({
st: 'urn:schemas-upnp-org:device:MediaServer:1',
usn: 'uuid:jellyfin-server-1::urn:schemas-upnp-org:device:MediaServer:1',
location: 'http://192.168.1.20:8096/dlna/server/description.xml',
server: 'Jellyfin/10.10.7 UPnP/1.0',
headers: {
manufacturer: 'Jellyfin',
modelName: 'Jellyfin Server',
},
}, {});
expect(result?.matched).toBeTrue();
expect(result?.normalizedDeviceId).toEqual('jellyfin-server-1');
expect(result?.candidate?.host).toEqual('192.168.1.20');
});
tap.test('validates Jellyfin candidates', async () => {
const descriptor = createJellyfinDiscoveryDescriptor();
const validator = descriptor.getValidators()[0];
const result = await validator.validate({
source: 'manual',
integrationDomain: 'jellyfin',
host: '192.168.1.20',
port: 8096,
}, {});
expect(result.matched).toBeTrue();
expect(result.confidence).toEqual('high');
});
export default tap.start();
@@ -0,0 +1,64 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import { JellyfinMapper, type IJellyfinSnapshot } from '../../ts/integrations/jellyfin/index.js';
const snapshot: IJellyfinSnapshot = {
server: {
Id: 'server-1',
Name: 'Home Jellyfin',
Version: '10.10.7',
},
online: true,
updatedAt: '2026-05-05T12:00:00.000Z',
sessions: [
{
Id: 'session-1',
UserName: 'phil',
Client: 'Jellyfin Web',
DeviceName: 'Living Room Browser',
DeviceId: 'device-1',
ApplicationVersion: '10.10.7',
IsActive: true,
SupportsRemoteControl: true,
Capabilities: {
SupportsMediaControl: true,
SupportsPersistentIdentifier: true,
SupportedCommands: ['Pause', 'Unpause', 'Stop', 'SetVolume'],
},
LastPlaybackCheckIn: '2026-05-05T12:01:00.000Z',
PlayState: {
IsPaused: false,
IsMuted: false,
PositionTicks: 1800000000,
VolumeLevel: 55,
},
NowPlayingItem: {
Id: 'movie-1',
Name: 'Example Movie',
Type: 'Movie',
RunTimeTicks: 72000000000,
},
},
],
};
tap.test('maps active Jellyfin sessions to media devices', async () => {
const devices = JellyfinMapper.toDevices(snapshot);
expect(devices.some((deviceArg) => deviceArg.id === 'jellyfin.server.server_1')).toBeTrue();
const sessionDevice = devices.find((deviceArg) => deviceArg.id === 'jellyfin.session.device_1');
expect(sessionDevice?.name).toEqual('Living Room Browser');
expect(sessionDevice?.features.some((featureArg) => featureArg.id === 'remote_command')).toBeTrue();
expect(sessionDevice?.state.some((stateArg) => stateArg.featureId === 'current_title' && stateArg.value === 'Example Movie')).toBeTrue();
});
tap.test('maps active Jellyfin sessions to media player entities', async () => {
const entities = JellyfinMapper.toEntities(snapshot);
const player = entities.find((entityArg) => entityArg.platform === 'media_player');
expect(player?.id).toEqual('media_player.living_room_browser');
expect(player?.state).toEqual('playing');
expect(player?.attributes?.volumeLevel).toEqual(0.55);
expect(player?.attributes?.mediaContentType).toEqual('movie');
expect(player?.attributes?.mediaDuration).toEqual(7200);
expect(player?.attributes?.mediaPosition).toEqual(180);
});
export default tap.start();