All Projects → ebaauw → homebridge-music

ebaauw / homebridge-music

Licence: Apache-2.0 license
Homebridge plugin for iTunes with AirPlay speakers

Programming Languages

javascript
184084 projects - #8 most used programming language
applescript
352 projects
Makefile
30231 projects

Projects that are alternatives of or similar to homebridge-music

Homebridge Dacp
Remotely control Apple TV and iTunes via HomeKit.
Stars: ✭ 128 (+39.13%)
Mutual labels:  homebridge-plugin, itunes, homekit
Homebridge Plex Sensors
Homebridge Sensors for Plex - a plugin for Homebridge to adds sensors triggered by Plex playbacks.
Stars: ✭ 95 (+3.26%)
Mutual labels:  homebridge-plugin, homekit
homebridge-nb
Homebridge plugin for Nuki Bridge
Stars: ✭ 38 (-58.7%)
Mutual labels:  homebridge-plugin, homekit
homebridge-keylights
Yet another Homebridge plugin for Elgato Key Light and Key Light Air. https://homebridge.io
Stars: ✭ 40 (-56.52%)
Mutual labels:  homebridge-plugin, homekit
Homebridge Ewelink
Homebridge plugin to control eWeLink devices with original firmware.
Stars: ✭ 208 (+126.09%)
Mutual labels:  homebridge-plugin, homekit
homebridge-unifi-occupancy-sensor
An occupancy sensor for Homebridge and UniFi
Stars: ✭ 71 (-22.83%)
Mutual labels:  homebridge-plugin, homekit
Homebridge Mi Hygrothermograph
Homebridge plugin for the Xiaomi Mi Bluetooth Temperature and Humidity Sensor
Stars: ✭ 179 (+94.57%)
Mutual labels:  homebridge-plugin, homekit
Homebridge Homeassistant
DEPRECATED in favor of native HomeKit support. -  Homebridge plugin for Home Assistant
Stars: ✭ 666 (+623.91%)
Mutual labels:  homebridge-plugin, homekit
Homebridge Zp
Homebridge plugin for Sonos ZonePlayer
Stars: ✭ 148 (+60.87%)
Mutual labels:  homebridge-plugin, homekit
Homebridge Http Switch
Powerful http switch for Homebridge: https://github.com/homebridge/homebridge
Stars: ✭ 111 (+20.65%)
Mutual labels:  homebridge-plugin, homekit
homebridge-panasonic
A Homebridge plugin for Panasonic Viera TV's. Written to support the new Homekit TV accessory.
Stars: ✭ 18 (-80.43%)
Mutual labels:  homebridge-plugin, homekit
Homebridge Dafang
Homebridge Plugin for Xiaomi Dafang / Wyze Cam IP Camera => Hey Siri, Start Video Recording
Stars: ✭ 176 (+91.3%)
Mutual labels:  homebridge-plugin, homekit
Homebridge Hubitat Tonesto7
Hubitat Homebridge Plugin
Stars: ✭ 45 (-51.09%)
Mutual labels:  homebridge-plugin, homekit
Homebridge Gsh
Allow Google Assistant to control your Homebridge accessories.
Stars: ✭ 190 (+106.52%)
Mutual labels:  homebridge-plugin, homekit
Homebridge Govee
Homebridge plugin to control Govee devices supported by the official Govee API.
Stars: ✭ 33 (-64.13%)
Mutual labels:  homebridge-plugin, homekit
Homebridge Edomoticz
Domoticz Homebridge-Plugin
Stars: ✭ 104 (+13.04%)
Mutual labels:  homebridge-plugin, homekit
Homebridge Unifi Protect
📹 Complete HomeKit integration for UniFi Protect with full support for most features including autoconfiguration, motion detection, and multiple controllers: https://homebridge.io
Stars: ✭ 335 (+264.13%)
Mutual labels:  homebridge-plugin, homekit
Homebridge Hue
Homebridge plugin for Philips Hue and/or deCONZ
Stars: ✭ 637 (+592.39%)
Mutual labels:  homebridge-plugin, homekit
Homebridge Nest Cam
View your Nest cams in HomeKit using Homebridge.
Stars: ✭ 103 (+11.96%)
Mutual labels:  homebridge-plugin, homekit
Homebridge Platform Wemo
Homebridge plugin to control Wemo devices.
Stars: ✭ 173 (+88.04%)
Mutual labels:  homebridge-plugin, homekit

Homebridge Music

Downloads Version Homebridge Discord verified-by-homebridge

GitHub issues GitHub pull requests JavaScript Style Guide

Homebridge plugin for iTunes with Airplay speakers

Copyright © 2016-2023 Erik Baauw. All rights reserved.

This homebridge plugin exposes controls to Apple's HomeKit for a music player, like iTunes/Music or EyeTV, running on macOS. It provides the following features:

  • HomeKit support for controlling iTunes (Music as of macOS 10.15 Catalina) or EyeTV:
    • On/Off control;
    • Volume control;
    • Previous/Next track/channel;
    • View current track/channel;
  • HomeKit support for controlling AirPlay speakers connected to iTunes/Music on macOS:
    • On/Off control;
    • Volume control;
  • HomeKit control for Airfoil-connected speakers:
    • On/Off control;
    • Volume control;
  • Provides an AppleScript framework to support other players.

Note: this is my old plugin from 2016 that I used to control my music, before moving to Sonos and Homebridge ZP.

Prerequisites

You need a macOS system to run Homebridge Music. AppleScript is used to communicate with iTunes/Music, EyeTV, or another music player, and that only runs on macOS.

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 app still provide only limited HomeKit support. To use the full features of Homebridge Music, you might want to check out some other HomeKit apps, like the Eve app (free) or Matthias Hochgatterer's Home+ app (paid).

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.

Player and Speakers

Homebridge Music creates an accessory Music for the player. By default, this accessory contains a single ÂSwitch service, with the same name as the accessory. In addition to the standard On characteristic for play/pause control, additional characteristics are provided for Volume, Change Track, and Current Track (read-only).

For each AirPlay or Airfoil speaker, Homebridge Music creates an additional accessory, named after the speaker. By default, these accessory contain a single Switch service, with the same name as the accessory. In addition to the standard One characteristic for play/pause control, an additional characteristic is provided for Volume.

Note that neither Siri nor the Apple's Home app support Volume, even thought this is a standard HomeKit characteristic. Because of this, the type of the service, as well as the type of characteristic used for volume can be changed from config.json, see Configuration and Homebridge ZP issue #10.

Installation

To install Homebridge Music:

  • Follow the instructions on the Homebridge Wiki to install Node.js and Homebridge on a macOS system;
  • Install the Homebridge Music plugin through Homebridge Config UI X or manually by:
    $ sudo npm -g i homebridge-music
    
  • Edit config.json and add the Music platform provided by Homebridge Music, see Configuration.

Configuration

In Homebridge's config.json you need to specify a platform for Homebridge Music:

  "platforms": [
    {
      "platform": "Music"
    }
  ]

The following optional parameters can be added to modify Homebridge Music's behaviour:

Key Default Description
service "switch" Defines what type of service and volume characteristic Homebridge Music uses.
Possible values are: "switch" for Switch and Volume; "speaker" for Speaker and Volume; "light" for LightBulb and Brightness; and "fan" for Fan and Rotation Speed.
Selecting "light" or "fan" enables changing the volume from Siri and from Apple's Home app.
Selecting "speaker" is not supported by the Apple's Home app.
brightness false Flag whether to expose volume as Brightness in combination with Switch or Speaker.
Setting this flag enables volume control from Siri.
script "iTunes"
"Music"
Name of the AppleScript library to interact with the player and speakers.
The default depends on the macOS version, see AppleScript.
speakername ".*" (any) Regular expression to be used as filter for speaker names.
track "" (none) Name of the track for the player to start.
Note that iTunes and Music will report an error when trying to Play when no current track has been set. You might want to change the default when starting iTunes or Music from Homebridge Music.
resetTrack false Reset current track to default track on stop.
heartrate 5 Heartbeat interval in seconds.
Player and speaker states are refreshed every heartrate seconds.
timeout 5 Timeout in seconds for AppleScript commands.
Increase this when seeing timeout error in the log. Note that HomeKit apps are blocked while the command to apply changed characteristics runs.

AppleScript

Homebridge Music interacts with the music player and speakers is through AppleScript. Each player/speaker combination has an associated AppleScript file in /usr/local/lib/node_modules/homebridge-music/scripts.

Homebridge Music ships with the following scripts:

Script Player Speakers macOS
iTunes iTunes iTunes AirPlay speakers < 10.15 Catalina
Music Music Music AirPlay speakers >= 10.15 Catalina
iTunes-Airfoil iTunes Airfoil < 10.15 Catalina
Music-Airfoil Music Airfoil >= 10.15 Catalina
EyeTV-Airfoil EyeTV v3* Airfoil < 10.15 Catalina
n/a EyeTV v4* Airfoil n/a

*) EyeTV v3 is a 32-bit application, which are no longer supported on macOS 10.15 Catalina.
*) EyeTV v4 is a 64-bit application and runs on Catalina, but it (currently?) lacks proper AppleScript support, see issue #14.

Each script provides the following functions to Homebridge Music:

Function Schema Description
getState(initial) GetState Gets player and speaker states.
setPlayerOn(on, track) SetOn Switches Player On/Off.
changeTrack(next) SetOn Sets next/previous track.
setPlayerVolume(vol) SetVolume Sets Player Volume.
setSpeakerOn(id, on) SetOn Switches Speaker On/Off.
setSpeakerVolume(id, vol) SetVolume Sets Speaker Volume.

These functions return a JSON string that conforms to the corresponding schema in /usr/local/lib/node_modules/homebridge-music/lib.

You can add your own script to support your favourite music player. To verify whether your script returns valid responses, you might want to use JSON Schema Lint.

Caveats

Homebridge Music 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.

The HomeKit terminology needs some getting used to. An accessory more or less corresponds to a physical device, accessible from your iOS device over WiFi or Bluetooth. A bridge (like Homebridge) is an accessory that provides access to other, bridged, accessories. An accessory might provide multiple services. Each service corresponds to a virtual device (like a lightbulb, switch, motion sensor, ..., but also: a programmable switch button, accessory information, battery status). Siri interacts with services, not with accessories. A service contains one or more characteristics. A characteristic is like a service attribute, which might be read or written by HomeKit apps. You might want to checkout Apple's HomeKit Accessory Simulator, which is distributed as an additional tool for Xcode.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].