-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add configurable show/hide of TV audio input, as well as other audio inputs from favourites list. Updated ReadMe and config.schema #219
Open
rfiorentino1
wants to merge
4
commits into
ebaauw:main
Choose a base branch
from
rfiorentino1:Development
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8abec5a
Added config option to hide all audio inputs from Favourites List; fi…
rfiorentino1 9b334fd
Remove .DS_Store file
rfiorentino1 59f198a
Added pesky .DS_Store to .gitignore
rfiorentino1 4771ef1
Closes issue #206, and adds/updates the following:
rfiorentino1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
out | ||
npm-debug.log | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
<p align="center"> | ||
<img src="homebridge-zp.png" height="200px"> | ||
<img src="homebridge-zp.png" height="200px" alt="Homebridge ZP Logo"> | ||
</p> | ||
<span align="center"> | ||
|
||
<a id="homebridge-zp"></a> | ||
# Homebridge ZP | ||
[![Downloads](https://img.shields.io/npm/dt/homebridge-zp.svg)](https://www.npmjs.com/package/homebridge-zp) | ||
[![Version](https://img.shields.io/npm/v/homebridge-zp.svg)](https://www.npmjs.com/package/homebridge-zp) | ||
|
@@ -20,11 +21,12 @@ Copyright © 2016-2024 Erik Baauw. All rights reserved. | |
|
||
This [Homebridge](https://github.com/homebridge/homebridge) plugin exposes [Sonos](http://www.sonos.com) zone players to Apple's [HomeKit](http://www.apple.com/ios/home/). | ||
It provides the following features: | ||
|
||
- Automatic discovery of Sonos zones, taking into account stereo pairs and home theatre setup; | ||
- Support for Sonos groups, created through the Sonos app; | ||
- Control from HomeKit of play/pause, sleep timer, next/previous track, volume, and mute per Sonos group; | ||
- Control from HomeKit of input selection per group, from Sonos favourites and local sources, like LineIn, Airplay; | ||
- Optional control from HomeKit of volume, mute, balance, bass, treble, loudness, night sound, and speech enhancement per Sonos zone; | ||
- Optional control from HomeKit of volume, mute, balance, bass, treble, loudness, night sound, and speech enhancement per Sonos zone, as well as surround/height level etc for home theater configurations; | ||
- Optional control from HomeKit for Sonos zones leaving Sonos groups, and for Sonos zones creating/joining one Sonos group; | ||
- Optional control from HomeKit to enable/disable Sonos alarms; | ||
- Real-time monitoring from HomeKit of state per Sonos group and, optionally, per Sonos zone. | ||
|
@@ -33,21 +35,40 @@ Like the Sonos app, Homebridge ZP subscribes to zone player events to receive no | |
Note that Sonos doesn't support events for these, so Homebridge ZP cannot provide real-time monitoring for this; | ||
- Includes command-line tools, for controlling Sonos zone players and for troubleshooting. | ||
|
||
## Contents | ||
|
||
* [Prerequisites](#prerequisites) | ||
* [zones](#zones) | ||
* [TV](#tv) | ||
* [TV-Enabled Zones](#tv-enabled-zones) | ||
* [Groups](#groups) | ||
* [Speakers](#speakers) | ||
* [Command-line Tool](#command-line-tool) | ||
* [Installation](#installation) | ||
* [Configuration](#configuration) | ||
* [Troubleshooting](#troubleshooting) | ||
* [Caveats](#caveats) | ||
|
||
|
||
<a id="prerequisites"></a> | ||
### Prerequisites | ||
You need a server to run Homebridge. | ||
|
||
This can be anything running [Node.js](https://nodejs.org): from a Raspberry Pi, a NAS system, or an always-on PC running Linux, macOS, or Windows. | ||
See the [Homebridge Wiki](https://github.com/homebridge/homebridge/wiki) for details. | ||
I run Homebridge ZP on a Raspberry Pi 3B+. | ||
|
||
To interact with HomeKit, you need Siri or a HomeKit app on an iPhone, Apple Watch, iPad, iPod Touch, or Apple TV (4th generation or later). | ||
I recommend to use the latest released versions of iOS, watchOS, and tvOS. | ||
|
||
Please note that Siri and even Apple's [Home](https://support.apple.com/en-us/HT204893) app still provide only limited HomeKit support. | ||
To use the full features of Homebridge Zp, you might want to check out some other HomeKit apps, like the [Eve](https://www.evehome.com/en/eve-app) app (free) or Matthias Hochgatterer's [Home+](https://hochgatterer.me/home/) app (paid). | ||
|
||
As Sonos uses UPnP to discover the zone players, the server running Homebridge must be on the same subnet as your Sonos zone players. | ||
As HomeKit uses Bonjour to discover Homebridge, the server running Homebridge must be on the same subnet as your iDevices running HomeKit. | ||
For remote access and for HomeKit automations, you need to setup an Apple TV (4th generation or later), HomePod, or iPad as [home hub](https://support.apple.com/en-us/HT207057). | ||
|
||
<a id="zones"></a> | ||
### Zones | ||
Homebridge ZP creates an accessory per Sonos zone, named after the zone, e.g. *Living Room Sonos* for the *Living Room* zone. | ||
By default, this accessory contains a single `Switch` service, with the same name as the accessory. The standard `On` characteristic is used for play/pause control. | ||
|
@@ -60,28 +81,46 @@ Despite the "HomeKit" branding, technically, this has nothing to do with HomeKit | |
No Homebridge plugin can expose speakers that look like AirPlay2 speakers in the Home app. | ||
Also note that these Airplay2 speakers cannot be accessed by other HomeKit apps. | ||
|
||
<a id="tv"></a> | ||
### TV | ||
|
||
When `"tv": true` is set in `config.json`, Homebridge ZP creates an additional *Television* accessory per zone, allowing input selection from Apple's Home app and control from the *Remote* widget. | ||
Note that Apple has imposed some technical restrictions on *Television* accessories: | ||
- They cannot be bridged; they need to be paired to HomeKit individually; | ||
|
||
- They cannot be bridged; they need to be paired to HomeKit individually. | ||
- They cannot be accessed by HomeKit apps; only from Apple's Home app. | ||
|
||
<a id="tv-enabled-zones"></a> | ||
### Tv-Enabled Zones | ||
Many Sonos products, such as Amp, Beam, Arc, etc have HDMI inputs on them, which causes Homebridge ZP to think that there is a TV connected to any product which supports TV input. Because there is no reliable way to know if this is the case, the plugin allows you to customize what zones actually have a TV connected. All zones are enabled by default, and disabling a zone will cause it's TV audio input to be hidden within Homekit. The zone names will auto-populate anytime HomeBridge is restarted, and will create a boolian for each zone in your config. The easiest way to define this is by using [Homebridge Config UI X](https://github.com/homebridge/homebridge-config-ui-x) or manually by adding "tvEnabledZones": { | ||
} | ||
to your config.json, like this: | ||
|
||
```json | ||
"tvEnabledZones": { | ||
"Patio": false, | ||
"Kitchen": false, | ||
"Living Room": true, | ||
"Master Bathroom": false, | ||
"Master Bedroom": true | ||
}, | ||
"platform": "ZP" | ||
``` | ||
|
||
|
||
<a id="groups"></a> | ||
### Groups | ||
When multiple Sonos zones, e.g. *Living Room* and *Kitchen*, are grouped into one Sonos group, the Sonos app shows them as a single room, e.g. *Living Room + 1*, with shared control for play/pause, music source, and (group) volume and mute. | ||
When this group is broken, each zone forms a separate standalone group, containing only that zone. | ||
The Sonos app shows each standalone group as a separate room, with separate control per room for play/pause, music source, and (zone) volume and mute. | ||
When you combine Sonos zones, such as *Living Room* and *Kitchen*, into one group, the Sonos app shows them as a single room, e.g. *Living Room + 1*. This allows you to control both rooms together for play/pause, music source, and volume/mute. When you ungroup them, each room goes back to being separate, with its own controls. | ||
|
||
If Homebridge ZP would mimic this behaviour, dynamically creating and deleting accessories for groups, HomeKit would lose the assignment to HomeKit rooms, groups, scenes, and automations, every time an accessory is deleted. Consequently, you would have to reconfigure HomeKit each time you group or ungroup Sonos zones. | ||
|
||
If Homebridge ZP would mimic this behaviour, dynamically creating and deleting accessories for groups, HomeKit would lose the assignment to HomeKit rooms, groups, scenes, and automations, every time an accessory is deleted. | ||
Consequently, you would have to reconfigure HomeKit each time you group or ungroup Sonos zones. | ||
To overcome this, Homebridge ZP creates an accessory for each Sonos zone, which manages the group the zone belongs to. When zones are separate, the controls for *Living Room* only effect the *Living Room* zone, and the controls for *Kitchen* only effect the *Kitchen* zone. When the zones are grouped, controls in any zone in that group will effect all speakers in the group e.g. *Living Room + 1*. | ||
|
||
To overcome this, Homebridge ZP creates an accessory and corresponding service for each Sonos zone. This service actually controls the Sonos *group* the zone is in rather than the zone. | ||
When separated, the *Living Room Sonos* service controls the standalone *Living Room* group, consisting of only the *Living Room* zone; and the *Kitchen Sonos* service controls the standalone *Kitchen* group, consisting of only the *Kitchen* zone. | ||
When grouped, both the *Living Room Sonos* service and the *Kitchen Sonos* service control the multi-zone *Living Room + 1* group, containing both the *Living Room* and *Kitchen* zones. | ||
The `Sonos Group` characteristic shows which group the zone belongs to, or rather: the name of the group coordinator zone, in this example: *Living Room*. | ||
The `Sonos Group` characteristic shows which group a speaker belongs to by displaying the name of the main speaker in the group, like *Living Room*. | ||
|
||
So when grouped, changing the *Living Room Sonos* `Volume` changes the volume of both the *Living Room* zone and the *Kitchen* zone. | ||
So does changing the *Kitchen Sonos* `Volume`. | ||
When ungrouped, changing the *Living Room Sonos* `Volume` only changes the volume of the *Living Room* zone; and changing the *Kitchen Sonos* `Volume` only changes the volume of the *Kitchen* zone. | ||
So, when grouped, adjusting the *Living Room* volume changes the volume for both *Living Room* and *Kitchen*. The same happens if you adjust the volume for *Kitchen*. When ungrouped, changing the *Living Room* volume only affects *Living Room*, and changing the *Kitchen* volume only affects *Kitchen*. | ||
|
||
<a id="speakers"></a> | ||
### Speakers | ||
To change the volume of an individual zone in a multi-zone group, an additional `Volume` characteristic is needed for the zone, next to the `Volume` characteristic for the group. | ||
As HomeKit doesn't support multiple characteristics of the same type per service, it actually requires an additional service. | ||
|
@@ -99,19 +138,23 @@ Note that `Bass`, `Treble`, and `Loudness` are custom characteristics. They mig | |
|
||
Like the *Sonos* service, the type of the *Speakers* service can be changed in `config.json` from the default `Switch`. | ||
|
||
<a id="command-line-tool"></a> | ||
### Command-Line Tool | ||
Homebridge ZP includes a command-line tool, `zp`, to interact with your Sonos Zone Players from the command line. | ||
It takes a `-h` or `--help` argument to provide a brief overview of its functionality and command-line arguments. | ||
|
||
<a id="installation"></a> | ||
### Installation | ||
To install Homebridge ZP: | ||
- Follow the instructions on the [Homebridge Wiki](https://github.com/homebridge/homebridge/wiki) to install Node.js and Homebridge; | ||
- Install the Homebridge ZP plugin through Homebridge Config UI X or manually by: | ||
|
||
- Follow the instructions on the [Homebridge Wiki](https://github.com/homebridge/homebridge/wiki) to install Node.js and Homebridge | ||
- Install the Homebridge ZP plugin through [Homebridge Config UI X](https://github.com/homebridge/homebridge-config-ui-x) or manually by: | ||
``` | ||
$ sudo npm -g i homebridge-zp | ||
``` | ||
- Edit `config.json` and add the `ZP` platform provided by Homebridge ZP, see [**Configuration**](#configuration). | ||
|
||
<a id="configuration"></a> | ||
### Configuration | ||
In Homebridge's `config.json` you need to specify Homebridge ZP as a platform plugin: | ||
```json | ||
|
@@ -127,9 +170,11 @@ Key | Default | Description | |
--- | ------- | ----------- | ||
`address` | _(discovered)_ | The IP address for the web server Homebridge ZP creates to receive notifications from Sonos zone players. This must be an IP address of the server running Homebridge ZP, reachable by the zone players. You might need to set this on a multi-homed server, if Homebridge ZP binds to the wrong network interface. | ||
`alarms` | `false` | Flag whether to expose an additional service per Sonos alarm. | ||
`brightness` | `false` | Flag whether to expose volume as `Brightness` when `service` is `"switch"` or `"speaker"`. Setting this flag enables volume control from Siri, but not from Apple's Home app. | ||
`excludeAirPlay` | `false` | Flag whether not to expose zone players that support Airplay, since they natively show up in Apple's Home app. | ||
`brightness` | `false` | Flag whether to expose volume as Brightness when "service" is "switch" or "speaker". Setting this flag enables volume control from Siri, but not from Apple's Home app. | ||
`excludeAirPlay` | `false` | Flag whether not to expose zone players that support Airplay, since they natively show up in Apple's Home app. Note that if you only have an S2 system, enabling this option will essentially render the plugin unusable, as all zones will be hidden from Homekit. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is technically not correct; there are still plenty of older zoneplayers supported by S2 that don't support Airplay (like the Play:1 and Play:3). |
||
`forceS2` | `false` | Flag whether to expose only S2 zone players. See [**Split Sonos System**](#split-sonos-system) below. | ||
`filterFavourites` | `false` | Flag whether or not to exclude audio inputs from the favourites list in Homekit. see [**TV**](#tv) for details. | ||
`tvEnabledZones` | `dynamically updated` | Object key to specify whether a zone will show a TV audio input in Homekit. see [**TV-Enabled Zones**](#tv-enabled-zones) for details. | ||
`heartrate` | (disabled) | Interval (in seconds) to poll zone players when `leds` is set. | ||
`leds` | `false` | Flag whether to expose an additional *Lightbulb* service per zone for the status LED. This also supports locking the physical controls. | ||
`nameScheme` | `"% Sonos"` | The name scheme for the HomeKit accessories. `%` is replaced with the zone name. E.g. with the default name scheme, the accessory for the `Kitchen` zone is set to `Kitchen Sonos`. Note that this does _not_ change the names of the HomeKit services, used by Siri. | ||
|
@@ -139,7 +184,7 @@ Key | Default | Description | |
`speakers` | `false` | Flag whether to expose a second *Speakers* service per zone, in addition to the standard *Sonos* service, see [**Speakers**](#speakers). You might want to set this if you're using Sonos groups in a configuration of multiple Sonos zones. | ||
`subscriptionTimeout` | `30` | The duration (in minutes) of the subscriptions Homebridge ZP creates with each zone player. | ||
`timeout` | `15` | The timeout (in seconds) to wait for a response from a Sonos zone player. | ||
`tv` | `false` | Create an additional, non-bridged TV accessory for each zone.<br>Note that each TV accessory needs to be paired with HomeKit separately, using the same pin as for Homebridge, as specified in `config.json`. | ||
`tv` | `false` | Create an additional, non-bridged TV accessory for each zone.<br>Note that each TV accessory needs to be paired with HomeKit separately, using the same pin as for Homebridge, as specified in `config.json`. see [**TV**](#tv) for more details. | ||
`tvIdPrefix` | `TV` | Prefix for serial number of TV accessories, to enable multiple instances of Homebridge ZP on the same network. | ||
|
||
Below is an example `config.json` that exposes the *Sonos* and *Speakers* service as a HomeKit `Speaker` and volume as `Brightness`, so it can be controlled from Siri: | ||
|
@@ -154,24 +199,29 @@ Below is an example `config.json` that exposes the *Sonos* and *Speakers* servic | |
] | ||
``` | ||
|
||
<a id="split-sonos-system"></a> | ||
#### Split Sonos System | ||
If you have a split Sonos system, Homebridge ZP will expose both the S2 and the S1 zone players. | ||
Of course you can only group S2 zone players with other S2 zone players; and S1 zone players with other S1 zone players. | ||
The same restriction applies when you have multiple Sonos households on your network: you can only group zone players with other zone players in the same household. | ||
|
||
<a id="troubleshooting"></a> | ||
### Troubleshooting | ||
|
||
<a id="check-dependencies"></a> | ||
#### Check Dependencies | ||
If you run into Homebridge startup issues, please double-check what versions of Node.js and of Homebridge have been installed. | ||
Homebridge ZP has been developed and tested using the [latest LTS](https://nodejs.org/en/about/releases/) version of Node.js and the [latest](https://www.npmjs.com/package/homebridge) version of Homebridge. | ||
Other versions might or might not work - I simply don't have the bandwidth to test these. | ||
|
||
<a id="run-homebridge-zp-solo"></a> | ||
#### Run Homebridge ZP Solo | ||
If you run into Homebridge startup issues, please run a separate instance of Homebridge with only Homebridge ZP (and Homebridge Config UI X) enabled in `config.json`. | ||
This way, you can determine whether the issue is related to Homebridge ZP itself, or to the interaction of multiple Homebridge plugins in your setup. | ||
You can start this separate instance of Homebridge on a different system, as a different user, or from a different user directory (specified by the `-U` flag). | ||
Make sure to use a different Homebridge `name`, `username`, and (if running on the same system) `port` in the `config.json` for each instance. | ||
|
||
<a id="debug-log-file"></a> | ||
#### Debug Log File | ||
Homebridge ZP outputs an info message for each HomeKit characteristic value it sets and for each HomeKit characteristic value change notification it receives. | ||
When Homebridge is started with `-D`, Homebridge ZP outputs a debug message for each request it makes to a Sonos zone player and for each zone player notification event it receives. | ||
|
@@ -190,20 +240,23 @@ To capture these messages into a log file do the following: | |
$ gzip homebridge.log | ||
``` | ||
|
||
<a id="web-server"></a> | ||
#### Web Server | ||
Like the Sonos app, Homebridge ZP subscribes to the zone player events to be notified in real-time of changes. It creates a web server to receive these notifications. The IP address and port number for this listener are logged in a debug message, e.g. | ||
``` | ||
[1/1/2020, 11:58:35 AM] [Sonos] listening on http://192.168.x.x:58004/notify | ||
``` | ||
To check whether the listener is reachable from the network, open this URL in your web browser. You should see an overview of the active subscriptions per zone player. | ||
|
||
<a id="getting-help"></a> | ||
#### Getting Help | ||
If you have a question, please post a message to the **#zp** channel of the Homebridge community on [Discord](https://discord.gg/3qFgFMk). | ||
|
||
If you encounter a problem, please open an issue on [GitHub](https://github.com/ebaauw/homebridge-zp/issues). | ||
Please **attach** a copy of `homebridge.log.gz` to the issue, see [**Debug Log File**](#debug-log-file). | ||
Please do **not** copy/paste large amounts of log output. | ||
|
||
<a id="caveats"></a> | ||
### Caveats | ||
Homebridge ZP is a hobby project of mine, provided as-is, with no warranty whatsoever. I've been running it successfully at my home for years, but your mileage might vary. | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think markdown automatically creates link targets for chapter headings (###). At least that works in the Wiki sections of GitHub. Not sure why the links don't work when viewing on GitHub - I need to investigate.