npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

castv2-device-monitor

v1.3.2

Published

Monitor a castv2 (a.k.a Chromecast) device

Downloads

19

Readme

castv2-device-monitor

Monitor the state of a castv2 (a.k.a. Chromecast) device.

Usage

const DeviceMonitor = require('castv2-device-monitor).DeviceMonitor

// Monitor the chromecast with the friendly name Livingroom
let dm = new DeviceMonitor('Livingroom')
dm.on('powerState', powerState => console.log('powerState', powerState))
dm.on('playState', playState => console.log('playState', playState))
dm.on('application', application => console.log('application', application))
dm.on('media', media => console.log('media', media))

A DeviceMonitor monitors a single Chromecast device and emits events whenever something changes with it. It can emit the following events:

event 'powerState'

The powerState event has a single parameter with the possible values 'on' and 'off'. A DeviceMonitor will always emit a powerState event soon after it is created.

As far as I know, a Chromecast device does not expose any real power indicator. The powerState is an attempt to emulate a power indicator. powerState will always be on when the Chromecast is playing something, and it will be set to off after the Chromecast has been idle for 60 seconds. To use another idle timeout, supply the timeout in milliseconds as the third parameter to the DeviceMonitor contructor.

The powerState can be used to control power to an amplifier or TV that the Chromecast is connected to.

event 'playState'

The playState event has a single parameter with the possible values 'play' and 'pause'.

event 'application'

The application event has a single parameter that is the friendly name of the application that is currently controlling the Chromecast.

event 'media'

The media event has a single parameter that contains an object with properties 'artist' and 'title'. These describe the currently playing song on the Chromecast.

event 'volume'

The volume event has a single parameter that contains the current volume as a number between 0-1, where 0 is muted and 1 is the maximum volume.

Controlling device

The DeviceMonitor also offers a limited ability to control playback on the device:

dm.pauseDevice()
dm.playDevice()
dm.volumeUp()
dm.volumeDown()

Additionally, dm.stopDevice() can be used to stop the session from the application to the device. It usually means that you have to select the cast-device again from the application.

Debugging

This module includes a binary castv2-device-monitor for testing purposes.

Usage:

./node_modules/.bin/castv2-device-monitor Livingroom

DEBUG=* ./node_modules/.bin/castv2-device-monitor Livingroom eth0 5000