GithubHelp home page GithubHelp logo

sebbo2002 / node-pyatv Goto Github PK

View Code? Open in Web Editor NEW
26.0 2.0 2.0 9.7 MB

A lightweight node.js wrapper around pyatv…

License: MIT License

Dockerfile 0.28% TypeScript 98.74% Shell 0.05% JavaScript 0.93%
nodejs node apple-tv appletv pyatv

node-pyatv's Introduction

node-pyatv

License Unit Tests

A lightweight wrapper around pyatv's which also supports realtime notifications.

📝 Content

☁ Installation

Before you use node-pyatv you need to install pyatv. This module woun't do this for you. Run atvremote --version to double check your installation. See FAQ section for installation tips.

To install the javascript module via npm just run:

npm install @sebbo2002/node-pyatv

⚒ Quick Start

import pyatv, {NodePyATVDeviceEvent} from '@sebbo2002/node-pyatv';

const devices = await pyatv.find(/*{debug: true}*/);
if (!devices.length) {
    throw new Error('Oh no.');
}

const device = devices[0];

// request current title
console.log(await device.getTitle());

// request full state
console.log(await device.getState());

// subscribe to events
device.on('update:deviceState', (event: NodePyATVDeviceEvent | Error) => {
    if(event instanceof Error) return;
    console.log(`Current device state is ${event.value}`);
});

📑 API Reference

The API documentation is automatically generated from the code comments and can be found here.

📑 Changelog

Please have a look at CHANGELOG.md to see the changelog.

🤨 FAQ

How to install pyatv

pip3 install pyatv

How to debug things

You can pass "debug": true for any command called. Some debug information is then printed via console.log. Additionaly you can pass a function to process debugs logs.

Why are some tests skipped?

Some unit tests require a responding apple tv to pass. These tests are disabled by default. You can set the environment variable ENABLE_INTEGRATION=1 to enable them.

Is this secure?

Defenitely not. For example, there's no escaping for parameters passed to pyatv. So be sure to double check the data you pass to this library, otherwise it may be possible to run code on your machine.

Copyright and license

Copyright (c) Sebastian Pekarek under the MIT license.

node-pyatv's People

Contributors

dependabot[bot] avatar depfu[bot] avatar github-actions[bot] avatar maxileith avatar sebbo2002 avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

btk999 maxileith

node-pyatv's Issues

Volume event triggered even though the volume did not change

Hello,

it's me again. I have found another bug. I am currently implementing volume control in my homebridge plugin and noticed that a volume event with the value null is triggered even though the volume doesn't change.

[7/11/2024, 6:31:44 PM] [Apple TV Enhanced] [V] CustomPyATVInstance: [node-pyatv][5N] stdout: {"result": "success", "datetime": "2024-07-11T18:31:44.296098+02:00", "hash": "OuDG6g5iU::yzccTFvsr", "media_type": "music", "device_state": "playing", "title": "The Way You Make Me Feel", "artist": "Michael Jackson", "album": "Bad (25th Anniversary Edition)", "genre": "Pop", "total_time": 298, "position": null, "shuffle": "off", "repeat": "off", "series_name": null, "season_number": null, "episode_number": null, "content_identifier": null, "app": "Musik", "app_id": "com.apple.TVMusic"}
[7/11/2024, 6:31:44 PM] [Apple TV Enhanced] [V] CustomPyATVInstance: [node-pyatv][5N] > {"result": "success", "datetime": "2024-07-11T18:31:44.296098+02:00", "hash": "OuDG6g5iU::yzccTFvsr", "media_type": "music", "device_state": "playing", "title": "The Way You Make Me Feel", "artist": "Michael Jackson", "album": "Bad (25th Anniversary Edition)", "genre": "Pop", "total_time": 298, "position": null, "shuffle": "off", "repeat": "off", "series_name": null, "season_number": null, "episode_number": null, "content_identifier": null, "app": "Musik", "app_id": "com.apple.TVMusic"}
[7/11/2024, 6:31:44 PM] [Apple TV Enhanced] [V] CustomPyATVInstance: [node-pyatv][5N] No position value found in input ({"result":"success","datetime":"2024-07-11T18:31:44.296098+02:00","hash":"OuDG6g5iU::yzccTFvsr","media_type":"music","device_state":"playing","title":"The Way You Make Me Feel","artist":"Michael Jackson","album":"Bad (25th Anniversary Edition)","genre":"Pop","total_time":298,"position":null,"shuffle":"off","repeat":"off","series_name":null,"season_number":null,"episode_number":null,"content_identifier":null,"app":"Musik","app_id":"com.apple.TVMusic"})
[7/11/2024, 6:31:44 PM] [Apple TV Enhanced] [V] CustomPyATVInstance: [node-pyatv][5N] No powerState value found in input ({"result":"success","datetime":"2024-07-11T18:31:44.296098+02:00","hash":"OuDG6g5iU::yzccTFvsr","media_type":"music","device_state":"playing","title":"The Way You Make Me Feel","artist":"Michael Jackson","album":"Bad (25th Anniversary Edition)","genre":"Pop","total_time":298,"position":null,"shuffle":"off","repeat":"off","series_name":null,"season_number":null,"episode_number":null,"content_identifier":null,"app":"Musik","app_id":"com.apple.TVMusic"})
[7/11/2024, 6:31:44 PM] [Apple TV Enhanced] [V] CustomPyATVInstance: [node-pyatv][5N] No focusState value found in input ({"result":"success","datetime":"2024-07-11T18:31:44.296098+02:00","hash":"OuDG6g5iU::yzccTFvsr","media_type":"music","device_state":"playing","title":"The Way You Make Me Feel","artist":"Michael Jackson","album":"Bad (25th Anniversary Edition)","genre":"Pop","total_time":298,"position":null,"shuffle":"off","repeat":"off","series_name":null,"season_number":null,"episode_number":null,"content_identifier":null,"app":"Musik","app_id":"com.apple.TVMusic"})
[7/11/2024, 6:31:44 PM] [Apple TV Enhanced] [D] Apple TV Wohnzimmer Apple TV (AA:BB:CC:DD:EE:FF): event volume: null
[7/11/2024, 6:31:44 PM] [Apple TV Enhanced] [I] Apple TV Wohnzimmer Apple TV (AA:BB:CC:DD:EE:FF): Volume has been set to 0

Make events typesafe

The events are currently pretty stupid to use, because either an error or a NodePyATVDeviceEvent object falls out. I would have to inform myself how to improve the typing.

`output_devices` in response of `atvscript push_updates` resulting in faulty state

Hi @sebbo2002 ,

this Issue is related to #291. An user of my plugin @rvetere has reported the issue maxileith/homebridge-appletv-enhanced#155. After some investigation the root cause is similar to the on reported in #291. Below is the response of atvscript push_updates

{"result": "success", "datetime": "2024-01-11T19:45:57.122827+01:00", "power_state": "on"}
{"result": "success", "datetime": "2024-01-11T19:45:57.123138+01:00", "output_devices": [{"name": "Apple TV", "identifier": "D4ED48E4-4C88-47C0-B05C-077747F85C5D"}]}
{"result": "success", "datetime": "2024-01-11T19:45:57.125393+01:00", "hash": "ca496c14642c78af6dd4250191fe175f6dafd72b4c33bcbab43c454aae051da1", "media_type": "unknown", "device_state": "idle", "title": null, "artist": null, "album": null, "genre": null, "total_time": null, "position": null, "shuffle": "off", "repeat": "off", "series_name": null, "season_number": null, "episode_number": null, "content_identifier": null, "app": null, "app_id": null}
{"result": "success", "datetime": "2024-01-11T19:45:57.126692+01:00", "volume": 50.0}

… which does include a line with the unexpected attribute output_devices which I do not think is correctly handled here:

applyStateAndEmitEvents(newState: NodePyATVState): void {
let keys = Object.keys(this.state);
if('power_state' in newState && newState.power_state) {
keys = ['power_state'];
}
if('focus_state' in newState && newState.focus_state) {
keys = ['focus_state'];
}
// Volume events don't hold the complete state…
// see https://github.com/sebbo2002/node-pyatv/pull/291
if('volume' in newState && newState.volume) {
keys = ['volume'];
}
I think it should be handled like power_state or volume

airplay pairing fail

Pairing with companion is working, however pairing with airplay gives below error.
atvremote version 0.10.3
without airplay credentials I cannot subscribe to live events.
Is this a known issue?

=================================

   Name: AppleTV

Model/SW: Apple TV 4K, tvOS 16.3
Address: x.x.x.x
MAC: xx:xx:xx:xx:xx:xx
Deep Sleep: False
Identifiers:

  • xx:xx:xx:xx:xx:xx
  • xxxxxxxxxxxx
    Services:
  • Protocol: Companion, Port: 49153, Credentials: None, Requires Password: False, Password: None, Pairing: Disabled
  • Protocol: AirPlay, Port: 7000, Credentials: None, Requires Password: False, Password: None, Pairing: Disabled
  • Protocol: RAOP, Port: 7000, Credentials: None, Requires Password: False, Password: None, Pairing: Disabled

=============================

pi@raspberrypi:~ $ atvremote --id xx:xx:xx:xx:xx:xx --protocol airplay pair
2023-02-01 21:21:50 ERROR [pyatv.scripts.atvremote]: Pairing failed
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.7/site-packages/pyatv/support/init.py", line 33, in error_handler
return await func(*args, **kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/pyatv/protocols/airplay/auth/hap.py", line 43, in start_pairing
await self.http.post("/pair-pin-start", headers=_AIRPLAY_HEADERS)
File "/home/pi/.local/lib/python3.7/site-packages/pyatv/support/http.py", line 361, in post
"POST", path, headers=headers, body=body, allow_error=allow_error
File "/home/pi/.local/lib/python3.7/site-packages/pyatv/support/http.py", line 417, in send_and_receive
response.code,
pyatv.exceptions.HttpError: HTTP/1.1 method POST failed with code 400: Bad Request

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/pi/.local/lib/python3.7/site-packages/pyatv/scripts/atvremote.py", line 179, in pair
await self._perform_pairing(pairing)
File "/home/pi/.local/lib/python3.7/site-packages/pyatv/scripts/atvremote.py", line 189, in _perform_pairing
await pairing.begin()
File "/home/pi/.local/lib/python3.7/site-packages/pyatv/protocols/airplay/pairing.py", line 63, in begin
self.pairing_procedure.start_pairing, exceptions.PairingError
File "/home/pi/.local/lib/python3.7/site-packages/pyatv/support/init.py", line 41, in error_handler
raise fallback(str(ex)) from ex
pyatv.exceptions.PairingError: HTTP/1.1 method POST failed with code 400: Bad Request

Is it possible to support double tap key press?

My goal is to be able to force quit an app using double tap home key and swipe up:

It can only be achieved using workaround

  • atvremote -s home home // calling this can show a list of background apps
  • atvremote -s up up // calling this can exit the current app

Is it possible to allow keyPress to take an array instead of just a single key?

async pressKey(key: NodePyATVKeys): Promise<void> {

or if we could support double tap on keyPress with InputAction https://github.com/postlund/pyatv/blob/master/pyatv/interface.py#L372

Error Installing node-pyatv

When I attempt to install node-pyatv on my Windows 10 machine I get the error below. Do you have any suggestions on a workaround?

84 verbose stack Error: command failed
84 verbose stack at ChildProcess.
C:\Users\Woodstock\AppData\Roaming\npm\node_modules\npm\node_modules@npmcli\promise-spawn\lib\index.js:53:27)
84 verbose stack at ChildProcess.emit (node:events:513:28)
84 verbose stack at maybeClose (node:internal/child_process:1091:16)
84 verbose stack at ChildProcess._handle.onexit (node:internal/child_process:302:5)
85 verbose pkgid @sebbo2002/[email protected]
86 verbose cwd C:\Windows\System32
87 verbose Windows_NT 10.0.19045
88 verbose node v18.16.0
89 verbose npm v9.6.7
90 error code 1
91 error path C:\Windows\System32\node_modules@sebbo2002\node-pyatv
92 error command failed
93 error command C:\Windows\system32\cmd.exe /d /s /c ./check.sh
94 error '.' is not recognized as an internal or external command,
94 error operable program or batch file.
95 verbose exit 1

The automated release is failing 🚨

🚨 The automated release from the develop branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the develop branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Cannot push to the Git repository.

semantic-release cannot push the version tag to the branch develop on the remote Git repository with URL http://[secure]@github.com/sebbo2002/node-pyatv.git.

This can be caused by:


Good luck with your project ✨

Your semantic-release bot 📦🚀

The automated release is failing 🚨

🚨 The automated release from the develop branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the develop branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot 📦🚀

Python 3.11 and 3.12 incompatability

Hello there,

I am currently developing a homebridge plugin and utilizing you awesome wrapper.

The only problem is, that once I use a python version higher than 3.10, the following error occurs:

Error: Got pyatv Error: Passing coroutines is forbidden, use tasks explicitly.

pyatv Stacktrace:
Traceback (most recent call last):
  File "/home/maxileith/Downloads/homebridge-appletv/dist/.venv/lib/python3.11/site-packages/pyatv/scripts/atvscript.py", line 389, in appstart
    args.output(await _handle_command(args, abort_sem, storage, loop)),
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/maxileith/Downloads/homebridge-appletv/dist/.venv/lib/python3.11/site-packages/pyatv/scripts/atvscript.py", line 271, in _handle_command
    return await _run_command(atv, args, abort_sem, loop)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/maxileith/Downloads/homebridge-appletv/dist/.venv/lib/python3.11/site-packages/pyatv/scripts/atvscript.py", line 305, in _run_command
    await wait_for_input(loop, abort_sem)
  File "/home/maxileith/Downloads/homebridge-appletv/dist/.venv/lib/python3.11/site-packages/pyatv/scripts/atvscript.py", line 167, in wait_for_input
    await asyncio.wait(
  File "/home/maxileith/.pyenv/versions/3.11.6/lib/python3.11/asyncio/tasks.py", line 425, in wait
    raise TypeError("Passing coroutines is forbidden, use tasks explicitly.")
TypeError: Passing coroutines is forbidden, use tasks explicitly.

    at parseState (/home/maxileith/Downloads/homebridge-appletv/node_modules/@sebbo2002/node-pyatv/src/lib/tools.ts:267:15)
    at A.applyPushUpdate (/home/maxileith/Downloads/homebridge-appletv/node_modules/@sebbo2002/node-pyatv/src/lib/device-events.ts:94:30)
    at A.parsePushUpdate (/home/maxileith/Downloads/homebridge-appletv/node_modules/@sebbo2002/node-pyatv/src/lib/device-events.ts:84:14)
    at /home/maxileith/Downloads/homebridge-appletv/node_modules/@sebbo2002/node-pyatv/src/lib/device-events.ts:159:36
    at Array.forEach (<anonymous>)
    at Socket.p (/home/maxileith/Downloads/homebridge-appletv/node_modules/@sebbo2002/node-pyatv/src/lib/device-events.ts:159:18)
    at Socket.emit (node:events:529:35)
    at addChunk (node:internal/streams/readable:335:12)
    at readableAddChunk (node:internal/streams/readable:308:9)
    at Socket.Readable.push (node:internal/streams/readable:245:10)

empty getState (events) and not show error

all error in stdout and not show in events error

[node-pyatv][2O] stdout: {"result": "failure", "datetime": "2021-11-24T21:13:36.424576+03:00", "exception": "invalid credentials: 321", "stacktrace": "Traceback (most recent call last):\n  File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/scripts/atvscript.py\", line 302, in appstart\n    print(args.output(await _handle_command(args, abort_sem, loop)), flush=True)\n  File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/scripts/atvscript.py\", line 196, in _handle_command\n    atv = await connect(config, loop, protocol=Protocol.MRP)\n  File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/__init__.py\", line 96, in connect\n    for setup_data in proto_methods.setup(\n  File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/protocols/airplay/__init__.py\", line 192, in setup\n    stream = AirPlayStream(config, service)\n  File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/protocols/airplay/__init__.py\", line 79, in __init__\n    self._credentials: HapCredentials = parse_credentials(self.service.credentials)\n  File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/auth/hap_pairing.py\", line 139, in parse_credentials\n    raise exceptions.InvalidCredentialsError(\"invalid credentials: \" + detail_string)\npyatv.exceptions.InvalidCredentialsError: invalid credentials: 321\n"}
[node-pyatv][2O] No hash value found in input ({"result":"failure","datetime":"2021-11-24T21:13:36.424576+03:00","exception":"invalid credentials: 321","stacktrace":"Traceback (most recent call last):\n  File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/scripts/atvscript.py\", line 302, in appstart\n    print(args.output(await _handle_command(args, abort_sem, loop)), flush=True)\n  File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/scripts/atvscript.py\", line 196, in _handle_command\n    atv = await connect(config, loop, protocol=Protocol.MRP)\n  File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/__init__.py\", line 96, in connect\n    for setup_data in proto_methods.setup(\n  File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/protocols/airplay/__init__.py\", line 192, in setup\n    stream = AirPlayStream(config, service)\n  File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/protocols/airplay/__init__.py\", line 79, in __init__\n    self._credentials: HapCredentials = parse_credentials(self.service.credentials)\n  File \"/Users/free/Library/Python/3.8/lib/python/site-packages/pyatv/auth/hap_pairing.py\", line 139, in parse_credentials\n    raise exceptions.InvalidCredentialsError(\"invalid credentials: \" + detail_string)\npyatv.exceptions.InvalidCredentialsError: invalid credentials: 321\n"})

when such a situation arrives empty events filled only with the date, but there must be errors in events

bug when scanning using unicast

Hi, it's me again.

So on my homebridge-appletv-enhanced plugin I always had coming in a few issues regarding a specific error:

[5/18/2024, 4:20:20 PM] [Apple TV Enhanced] [E] Platform: Error: Unable to parse result U json: SyntaxError: Unexpected non-whitespace character after JSON at position 1504

Now, I got my hand on verbose logs from a user who has these problems: maxileith/homebridge-appletv-enhanced#407 (you can read the original logs in the attatchment of this issue). In verbose log, my plugin prints debug messages from your library and therefore it is easy to dig into it.

So the user has configured the plugin in a way that it does unicast discovery: Your library then executes the following atvscript command:

[5/18/2024, 4:20:12 PM] [Apple TV Enhanced] [V] CustomPyATVInstance: [node-pyatv][U] /var/lib/homebridge/appletv-enhanced/.venv/bin/atvscript -s 10.0.0.30,10.0.0.229,10.0.0.79,10.0.0.20,10.0.0.156,10.0.0.232 scan

So far so good. However, the atvscript then returns instead of a single JSON line three lines with the individual JSONs which your library simply does not expext:

{"result": "failure", "datetime": "2024-05-18T16:20:18.103087-06:00", "error": "Task exception was never retrieved", "exception": "[Errno 113] Connect call failed ('10.0.0.232', 32498)", "stacktrace": "Traceback (most recent call last):\n  File \"/var/lib/homebridge/appletv-enhanced/.venv/lib/python3.11/site-packages/pyatv/support/knock.py\", line 28, in _async_knock\n    _, writer = await asyncio.wait_for(\n                ^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/lib/python3.11/asyncio/tasks.py\", line 479, in wait_for\n    return fut.result()\n           ^^^^^^^^^^^^\n  File \"/usr/lib/python3.11/asyncio/streams.py\", line 48, in open_connection\n    transport, _ = await loop.create_connection(\n                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/lib/python3.11/asyncio/base_events.py\", line 1085, in create_connection\n    raise exceptions[0]\n  File \"/usr/lib/python3.11/asyncio/base_events.py\", line 1069, in create_connection\n    sock = await self._connect_sock(\n           ^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/lib/python3.11/asyncio/base_events.py\", line 973, in _connect_sock\n    await self.sock_connect(sock, address)\n  File \"/usr/lib/python3.11/asyncio/selector_events.py\", line 634, in sock_connect\n    return await fut\n           ^^^^^^^^^\n  File \"/usr/lib/python3.11/asyncio/selector_events.py\", line 674, in _sock_connect_cb\n    raise OSError(err, f'Connect call failed {address}')\nOSError: [Errno 113] Connect call failed ('10.0.0.232', 32498)\n"}
{"result": "failure", "datetime": "2024-05-18T16:20:18.114744-06:00", "error": "Task exception was never retrieved", "exception": "[Errno 113] Connect call failed ('10.0.0.229', 32498)", "stacktrace": "Traceback (most recent call last):\n  File \"/var/lib/homebridge/appletv-enhanced/.venv/lib/python3.11/site-packages/pyatv/support/knock.py\", line 28, in _async_knock\n    _, writer = await asyncio.wait_for(\n                ^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/lib/python3.11/asyncio/tasks.py\", line 479, in wait_for\n    return fut.result()\n           ^^^^^^^^^^^^\n  File \"/usr/lib/python3.11/asyncio/streams.py\", line 48, in open_connection\n    transport, _ = await loop.create_connection(\n                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/lib/python3.11/asyncio/base_events.py\", line 1085, in create_connection\n    raise exceptions[0]\n  File \"/usr/lib/python3.11/asyncio/base_events.py\", line 1069, in create_connection\n    sock = await self._connect_sock(\n           ^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/lib/python3.11/asyncio/base_events.py\", line 973, in _connect_sock\n    await self.sock_connect(sock, address)\n  File \"/usr/lib/python3.11/asyncio/selector_events.py\", line 634, in sock_connect\n    return await fut\n           ^^^^^^^^^\n  File \"/usr/lib/python3.11/asyncio/selector_events.py\", line 674, in _sock_connect_cb\n    raise OSError(err, f'Connect call failed {address}')\nOSError: [Errno 113] Connect call failed ('10.0.0.229', 32498)\n"}
{"result": "success", "datetime": "2024-05-18T16:20:20.042648-06:00", "devices": [{"name": "Living Room", "address": "10.0.0.30", "identifier": "37323C0E-99E6-4CC3-A006-1ED5368FFF8C", "all_identifiers": ["86B730B2-5189-4B6A-BCAA-CDDB18F05FA8", "C8:D0:83:E9:D0:49", "37323C0E-99E6-4CC3-A006-1ED5368FFF8C", "C8D083E9D049"], "device_info": {"mac": "C8:D0:83:E9:D0:49", "model": "Gen4K", "model_str": "Apple TV 4K", "operating_system": "TvOS", "version": "17.5"}, "services": [{"protocol": "companion", "port": 49153}, {"protocol": "airplay", "port": 7000}, {"protocol": "mrp", "port": 49154}, {"protocol": "raop", "port": 7000}]}, {"name": "Kitchen", "address": "10.0.0.79", "identifier": "45B6A67A-9FAD-497D-95EF-7FC5ECB3371C", "all_identifiers": ["B163C908-000F-4983-BDC7-BEFD76887EF5", "C8:69:CD:63:2A:11", "45B6A67A-9FAD-497D-95EF-7FC5ECB3371C", "C869CD632A11"], "device_info": {"mac": "C8:69:CD:63:2A:11", "model": "Gen4", "model_str": "Apple TV 4", "operating_system": "TvOS", "version": "17.4"}, "services": [{"protocol": "companion", "port": 49153}, {"protocol": "airplay", "port": 7000}, {"protocol": "mrp", "port": 49157}, {"protocol": "raop", "port": 7000}]}, {"name": "Bedroom", "address": "10.0.0.20", "identifier": "CA55DA36-ADEF-4DBC-A0B3-BA68B0C53E40", "all_identifiers": ["08:66:98:BC:37:1F", "108F35A0-FF21-4884-96C2-145AAAB1B4C4", "CA55DA36-ADEF-4DBC-A0B3-BA68B0C53E40", "086698BC371F"], "device_info": {"mac": "08:66:98:BC:37:1F", "model": "Gen4", "model_str": "Apple TV 4", "operating_system": "TvOS", "version": "17.4"}, "services": [{"protocol": "airplay", "port": 7000}, {"protocol": "companion", "port": 49153}, {"protocol": "mrp", "port": 49154}, {"protocol": "raop", "port": 7000}]}, {"name": "Basement", "address": "10.0.0.156", "identifier": "C02B27DB-2AF3-43E7-8EF7-885E1E9AB3B4", "all_identifiers": ["8BDB6773-479F-4C01-A185-29FF5516F2C2", "D0:03:4B:4C:2A:2E", "C02B27DB-2AF3-43E7-8EF7-885E1E9AB3B4", "D0034B4C2A2E"], "device_info": {"mac": "D0:03:4B:4C:2A:2E", "model": "Gen4", "model_str": "Apple TV 4", "operating_system": "TvOS", "version": "17.4"}, "services": [{"protocol": "companion", "port": 49153}, {"protocol": "airplay", "port": 7000}, {"protocol": "mrp", "port": 49154}, {"protocol": "raop", "port": 7000}]}]}

So 2 of the 6 unicast scans were unsuccesful. The atvscript return a seperate json for each error and one single json for all successful scans. As the lib does not expect that it throws the following error:

[5/18/2024, 4:20:20 PM] [Apple TV Enhanced] [V] CustomPyATVInstance: [node-pyatv][U] /var/lib/homebridge/appletv-enhanced/.venv/bin/atvscript exited with code: 0
[5/18/2024, 4:20:20 PM] [Apple TV Enhanced] [V] CustomPyATVInstance: [node-pyatv][U] Unable to parse result U json: SyntaxError: Unexpected non-whitespace character after JSON at position 1504

Position 1504 is the line break after the first JSON in line 1 of 3.

So what I basically need, is that the library does not throw an error and parses the successful scans correctly. On top I need a list of errors so that I can output that in my plugin. Would that be feasible?

A workaround I could imagine would be to do call the find method for each Host individually ...

Thanks in advance and thank you for the lib :)

package.json homepage link incorrect

I just wanted to mentioned that the homepage link in the package.json are pointing to a template repository and not this one. This results in wrong links on npmjs.com

Airplay2 (Stereo) Speaker support ?

Guten Tag,

While searching for a way to integrate AppleTV and Airplay 2 for the Homey Smart Home, I came across your node implementation via the pyatv python library.

My basic question is, do you support normal Airplay2 (stereo) speaker devices like HomePod mini besides AppleTV ?

Gruss Chris

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.