Skip to content

Commit

Permalink
Merge pull request #288 from sebbo2002/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbo2002 committed Dec 26, 2023
2 parents 794192f + 0053301 commit a8e3648
Show file tree
Hide file tree
Showing 10 changed files with 770 additions and 397 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/stale-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
pull-requests: write
steps:
- name: 🧹 Cleanup issues & pull requests
uses: actions/stale@v8
uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: ☁️ Checkout Project
uses: actions/checkout@v4
- name: 🔧 Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
# https://github.com/aio-libs/aiohttp/issues/7739#issuecomment-1773868351
python-version: 3.11
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
- name: ☁️ Checkout Project
uses: actions/checkout@v4
- name: 🔧 Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: 🔧 Setup pip cache
Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
- name: ☁️ Checkout Project
uses: actions/checkout@v4
- name: 🔧 Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: 🔧 Setup pip cache
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:latest

ARG PYATV_VERSION=0.10.3
ARG NODE_VERSION=16
ARG PYATV_VERSION=0.14.5
ARG NODE_VERSION=20

# ensure local python is preferred over distribution python
ENV PATH /usr/local/bin:$PATH
Expand Down
1,065 changes: 689 additions & 376 deletions package-lock.json

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/npm": "^11.0.1",
"@types/mocha": "^10.0.4",
"@types/node": "^20.8.9",
"@types/semver": "^7.5.5",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"@semantic-release/npm": "^11.0.2",
"@types/mocha": "^10.0.6",
"@types/node": "^20.10.2",
"@types/semver": "^7.5.6",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"c8": "^8.0.1",
"eslint": "^8.53.0",
"eslint-plugin-jsonc": "^2.10.0",
"eslint": "^8.55.0",
"eslint-plugin-jsonc": "^2.11.2",
"esm": "^3.2.25",
"license-checker": "^25.0.1",
"mocha": "^10.2.0",
"mochawesome": "^7.1.3",
"semantic-release": "^22.0.7",
"semantic-release": "^22.0.12",
"semantic-release-license": "^1.0.3",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.1",
"tsup": "^7.2.0",
"typedoc": "^0.25.3",
"typescript": "^5.2.2"
"ts-node": "^10.9.2",
"tsup": "^8.0.1",
"typedoc": "^0.25.4",
"typescript": "^5.3.3"
},
"engines": {
"node": ">=18.0.0"
Expand Down Expand Up @@ -60,7 +60,7 @@
"build-all": "./.github/workflows/build.sh",
"check": "./check.sh",
"coverage": "c8 mocha",
"develop": "ts-node ./src/bin/start.ts",
"develop": "TS_NODE_TRANSPILE_ONLY=true node --no-warnings --enable-source-maps --loader ts-node/esm src/bin/start.ts",
"example": "node ./dist/examples/push.js",
"license-check": "license-checker --production --summary",
"lint": "eslint . --ext .ts",
Expand Down
16 changes: 16 additions & 0 deletions src/lib/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,29 @@ export default class NodePyATVDevice implements EventEmitter{
return this.options.id;
}

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

/**
* Get the used protocol to connect to the Apple TV.
*/
get protocol(): NodePyATVProtocol | undefined {
return this.options.protocol;
}

/**
* Get the MAC address of the Apple TV.
* Requires pyatv >= 0.14.5.
*/
get mac(): string | undefined {
return this.options.mac;
}

/**
* Get the model identifier of the device. Only set, if the
* device was found using [[find()]]. Requires pyatv ≧ 0.10.3.
Expand Down
2 changes: 2 additions & 0 deletions src/lib/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ export default class NodePyATVInstance {
this.device(Object.assign({}, options, {
host: device.address,
id: device.identifier,
allIDs: device.all_identifiers,
name: device.name,
mac: device.device_info?.mac,
model: device.device_info?.model,
modelName: device.device_info?.model_str,
os: device.device_info?.operating_system,
Expand Down
4 changes: 4 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,13 @@ export interface NodePyATVFindAndInstanceOptions extends NodePyATVInstanceOption
export interface NodePyATVDeviceOptions extends NodePyATVFindAndInstanceOptions {
host: string;
name: string;
mac?: string;
model?: string;
modelName?: string;
os?: string;
version?: string;
services?: NodePyATVService[];
allIDs?: string[];
}

export interface NodePyATVGetStateOptions {
Expand All @@ -175,7 +177,9 @@ export interface NodePyATVInternalScanDevice {
name: string;
address: string;
identifier: string;
all_identifiers: string[];
device_info?: {
mac: string | null;
model: string;
model_str: string;
operating_system: string;
Expand Down
33 changes: 33 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 All @@ -60,6 +81,18 @@ describe('NodePyATVDevice', function () {
});
});

describe('get mac()', function () {
it('should return the mac', function () {
const device = new NodePyATVDevice({
name: 'My Testdevice',
host: '192.168.178.2',
mac: 'AA:BB:CC:DD:EE:FF'
});

assert.strictEqual(device.mac, 'AA:BB:CC:DD:EE:FF');
});
});

describe('get model()', function () {
it('should return the model if set by scan', function () {
const device = new NodePyATVDevice({
Expand Down
7 changes: 6 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@
],
"include": [
"src/**/*"
]
],
"ts-node": {
"esm": true,
"experimentalResolver": true,
"files": true
}
}

0 comments on commit a8e3648

Please sign in to comment.