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 🙏

© 2026 – Pkg Stats / Ryan Hefner

chromecast2mqtt

v0.1.0

Published

Interface between Google Cast devices (Chromecast, Google Home, Nest speakers, Android TV) and MQTT

Readme

chromecast2mqtt

Interface between Google Cast devices (Chromecast, Google Home and Nest speakers, Android TV, cast-enabled speakers) and MQTT, following the mqtt-smarthome convention, built on mqtt-interfaces-core.

Devices are found with mdns (or pinned by address), every device keeps a Cast v2 connection open, and its volume, the running app and what plays are retained status topics the moment they change. Commands set the volume, mute, control playback, play a url and close the running app. Home Assistant finds every device through MQTT discovery.

Install

npm install -g chromecast2mqtt
chromecast2mqtt -u mqtt://broker                       # mdns finds the devices
chromecast2mqtt -u mqtt://broker --no-discovery -d living_room=192.168.1.20
sudo chromecast2mqtt --install -n chromecast -u mqtt://broker   # systemd service chromecast2mqtt@chromecast

Docker

Multi-arch image (amd64, arm64, armv7). mdns needs the host network:

docker run -d --name chromecast2mqtt --restart unless-stopped --network host \
  -e CHROMECAST2MQTT_MQTT_URL=mqtt://broker ghcr.io/handijk/chromecast2mqtt

Without the host network pin the devices: -e CHROMECAST2MQTT_DISCOVERY=false -e CHROMECAST2MQTT_DEVICES=living_room=192.168.1.20,kitchen=192.168.1.21.

Topics

Instance name chromecast (--name); status payloads are {"val": ..., "ts": ..., "lc": ...} unless --no-json-payloads.

| topic | retained | value | | ---------------------------------------------------------------------- | -------- | ----------------------------------------------------------------- | | chromecast/connected | yes | 0 gone, 1 broker only, 2 at least one device connected | | chromecast/status/<device>/online | yes | true while the connection to the device is up | | chromecast/status/<device>/name, model, address, id | yes | the device | | chromecast/status/<device>/volume | yes | 0–1 | | chromecast/status/<device>/muted | yes | true or false | | chromecast/status/<device>/app | yes | the running app ("Spotify", "YouTube"), null on the idle screen | | chromecast/status/<device>/app_id | yes | its id, null on the idle screen | | chromecast/status/<device>/idle | yes | true when nothing runs (the backdrop) | | chromecast/status/<device>/status_text | yes | what the app says it does, or null | | chromecast/status/<device>/player_state | yes | IDLE, PLAYING, PAUSED, BUFFERING | | chromecast/status/<device>/title, artist, album | yes | what plays, or null | | chromecast/status/<device>/content_type, content_id, stream_type | yes | the media | | chromecast/status/<device>/duration, position | yes | seconds, or null | | chromecast/status/<device>/image | yes | artwork url, or null | | chromecast/status/<device>/idle_reason | yes | FINISHED, CANCELLED, ERROR, ... when the player went idle |

<device> is the friendly name as a slug (Living Room → living_room), or the cast id with --device-topics id. Two devices with the same name get the start of their id appended.

Some apps (YouTube, Netflix, ...) do not let a second sender join their media session: for those you get the app and the volume, not what plays. The idle screen and apps without media report player_state IDLE.

Commands

| topic | payload | | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | | chromecast/set/<device>/volume | 0.35 (or 35) | | chromecast/set/<device>/muted | true or false | | chromecast/set/<device>/player_state | play, pause or stop (the current media session) | | chromecast/set/<device>/seek | seconds | | chromecast/set/<device>/play | "https://host/stream.mp3" or {"url": ..., "content_type": "audio/mpeg", "title": ..., "image": ..., "stream_type": "LIVE"} | | chromecast/set/<device>/quit | anything: closes the running app |

play launches the default media receiver with the url; the content type is guessed from the url's extension when not given.

Home Assistant

Discovery is on by default (--no-ha-discovery turns it off and clears it). Home Assistant has no MQTT media player, so every cast device is a device with a volume slider, a mute switch, the app, player state, title, artist and album as sensors and play, pause and stop buttons. A device shows unavailable while its connection is down.

Options

Run chromecast2mqtt --help for the full list; every option is also an environment variable (CHROMECAST2MQTT_DEVICES, …), see --config-schema.

| option | default | | | ---------------------- | ------- | ------------------------------------------------------------------ | | --devices, -d | | <name>=<host>[:<port>],... pinned devices (no mdns needed) | | --discovery | on | find devices with mdns (--no-discovery to turn it off) | | --device-topics | name | name or id | | --reconnect-interval | 10 | seconds between connection attempts to a device that is gone | | --position-interval | 10 | seconds between position updates while playing (0 = events only) |

Shared options: --mqtt-url/-u, --mqtt-username, --mqtt-password, --mqtt-tls-ca, --name/-n, --json-payloads, --ha-discovery, --ha-prefix, --maintenance, --stats-interval, --verbosity/-v, --install, --uninstall, --config-schema.

License

MIT