A lightweight wrapper around pyatv's which also supports realtime notifications.
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
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}`);
});
The API documentation is automatically generated from the code comments and can be found here.
Please have a look at CHANGELOG.md to see the changelog.
pip3 install pyatv
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.
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.
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 (c) Sebastian Pekarek under the MIT license.