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 🙏

© 2025 – Pkg Stats / Ryan Hefner

homebridge-sonos-control

v1.2.0

Published

Allows to play tracks and notifications on your Sonos system via homebridge / HomeKit.

Readme

Homebridge Sonos Control Plugin

verified-by-homebridge

✨ Introduction

The Homebridge Sonos Control Plugin allows you to configure HomeKit switches to play (native) notifications or tracks on your Sonos devices. If multiple tracks are configured for a switch, a track is selected at random.

🔧 Installation

Typically, you install the plugin via Homebridge's web UI. For manual installation, use:

npm install -g homebridge-sonos-control

📄 Configuration

Configuration is done in config.json or via web UI.

📢 Example Configuration

{
  "switches": [
    {
      "name": "Vecna Clock Bedroom",
      "sonosDeviceNames": [
        "Bedroom"
      ],
      "onlyWhenPlaying": false,
      "tracks": [
        {
          "trackUri": "http://192.168.0.3/stranger-things-clock2.mp3",
          "nativeNotification": true
        }
      ],
      "cronExpression": "0 * * * *"
    },
    {
      "name": "Radio Stream Livingroom",
      "sonosDeviceNames": [
        "Livingroom"
      ],
      "onlyWhenPlaying": false,
      "tracks": [
        {
          "trackUri": "x-rincon-mp3radio://http://stream.srg-ssr.ch/drs3/mp3_128.m3u",
          "nativeNotification": false,
          "volume": 30
        }
      ]
    },
    {
      "name": "Random Track Kitchen & Children",
      "sonosDeviceNames": [
        "Kitchen", "Children"
      ],
      "onlyWhenPlaying": false,
      "tracks": [
        {
          "trackUri": "spotify:track:1NVi9hztbG04tDrxvdv7Om",
          "nativeNotification": false,
          "stopAfter": 2000
        },
        {
          "trackUri": "spotify:track:3dPQuX8Gs42Y7b454ybpMR",
          "nativeNotification": false,
          "seekPosition": "00:03:27",
          "stopAfter": 3000
        }
      ]
    }
  ],
  "platform": "GlurzSonosControl"
}

📊 Configuration Options

Switch

| Field | Type | Description | |--------------------|-----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------| | name | string | Name of the switch in HomeKit. (required) | | sonosDeviceNames | string[] | Names of the Sonos devices that will play the notification. (required) | | onlyWhenPlaying | boolean | Only play this notification if the device is already playing. (default: false) | | tracks | array of tracks | The definition of one or more tracks / notifications to be played by this switch. If more than one track is configured, one is selected at random. (required) | | cronExpression | string | A cron expression to trigger this switch. See https://www.npmjs.com/package/cron?activeTab=readme (optional) |

Track

| Field | Type | Description | |----------------------|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------| | trackUri | string (URL) | The URI of the track / notification to be played. Can be any URI Sonos understands. For native notifications, a MP3 or WAF file must be specified. (required) | | volume | number (1-100) | Volume of the notification. Uses the devices volume if not specified. (optional) | | nativeNotification | boolean | Whether the native Sonos notification should be used. See description below. (default: true) | | seekPosition | string (hh:mm:ss) | Start time in the track. Not available for native notifications. (optional) | | stopAfter | number (milliseconds) | Stops playback after given amount of milliseconds. Not available for native notifications. (optional) | | repeatContinuously | boolean | Plays the track continuously using Sonos' 'repeat one' functionality. Not available for native notifications. (optional) |

General Options

| Field | Type | Description | | --------------- | ------------- |-------------------------------------------------------------------------------------------------------------------------| | sonosDeviceIp | string (IPv4) | If automatic discovery fails, a fixed IP of any Sonos device can be specified as a starting point for device discovery. |

Native vs. non-native notifications

Native notifications use a functionality of the Sonos speakers, in which a (short) notification is played, whereby the music currently playing is paused or, depending on the device model, continues to play quietly in the background. After the notification, the previous state is restored. Native notifications are limited in that only MP3 or WAV URIs can be used.

Non-native notification emulate this behavior and also restore the state of the device before the notification. Non-native notifications support any kind of URI Sonos understands.

Track URIs

Sonos understands a variety of Track URIs. Some examples:

  • https://myserver.com/some_file.mp3
  • spotify:track:3dPQuX8Gs42Y7b454ybpMR
  • x-rincon-mp3radio://http://stream.srg-ssr.ch/drs3/mp3_128.m3u

ℹ️ To easily figure out the track URIs of played tracks, this plugin logs the metadata (incl. track URI) of any song played on your Sonos system to the debug log.

🔗 Links

👋 Feedback & Support

If you have questions or issues, create an issue on GitHub. Enjoy your Sonos plugin! 🎶

🙏🏻 Credits

This plugin uses:

  • svroij's library to access Sonos from TypeScript.
  • The cron library to trigger switches by cron expressions.

This plugin is not affiliated with Sonos.