Skip to content

Commit

Permalink
feat(core): add allIDs attribute to device
Browse files Browse the repository at this point in the history
adding the new all_identifiers attribute introduced in postlund/pyatv#2282 to the device as allIDs.
  • Loading branch information
maxileith authored and sebbo2002 committed Dec 26, 2023
1 parent 3422796 commit 02a9c05
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ export default class NodePyATVDevice implements EventEmitter{
return this.options.id;
}

/**
* Get all IDs of the Apple TV.
*/
get allIDs(): string[] | undefined {
return this.options.allIDs;
}

/**
* Get the used protocol to connect to the Apple TV.
*/
Expand Down
1 change: 1 addition & 0 deletions src/lib/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export default class NodePyATVInstance {
this.device(Object.assign({}, options, {
host: device.address,
id: device.identifier,
allIDs: device.all_identifiers,
name: device.name,
model: device.device_info?.model,
modelName: device.device_info?.model_str,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export interface NodePyATVDeviceOptions extends NodePyATVFindAndInstanceOptions
os?: string;
version?: string;
services?: NodePyATVService[];
allIDs?: string[];
}

export interface NodePyATVGetStateOptions {
Expand All @@ -175,6 +176,7 @@ export interface NodePyATVInternalScanDevice {
name: string;
address: string;
identifier: string;
all_identifiers: string[];
device_info?: {
model: string;
model_str: string;
Expand Down
21 changes: 21 additions & 0 deletions test/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,27 @@ describe('NodePyATVDevice', function () {
});
});

describe('get allIDs()', function () {
it('should return all the IDs', function () {
const device = new NodePyATVDevice({
name: 'My Testdevice',
host: '192.168.178.2',
id: '*****',
allIDs: [
'some_id_1',
'some_id_2',
'some_id_3',
]
});

assert.deepStrictEqual(device.allIDs, [
'some_id_1',
'some_id_2',
'some_id_3',
]);
});
});

describe('get protocol()', function () {
it('should return the protocol', function () {
const device = new NodePyATVDevice({
Expand Down

0 comments on commit 02a9c05

Please sign in to comment.