homebridge-pc-volume is a Homebridge plugin that adds a support for changing a computer's volume using HomeKit and Siri.
homebridge-pc-volume utilises node-loudness, which currently supports macOS, Linux (using ALSA), and Windows. Windows may need OpenSSL to be installed; it is required when being run on CI, which installs the latest 64-bit not-light 1.0.2 build avialable from https://slproweb.com/products/Win32OpenSSL.html. I have not personally tested this project on Linux or Windows.
First, install Homebridge.
Then install homebridge-pc-volume via npm
:
npm install -g homebridge-pc-volume
homebridge-pc-volume will also need to be specified as an accessory in your ~/.homebridge/config.json
:
{
// Other keys here...
"accessories": [
{
"accessory": "ComputerSpeakers",
"name": "MacBook"
}
]
}
Note that accessory
must be "ComputerSpeakers", while the name
can be any value of your choosing.
When the property logarithmic
is set to true
the volume will be scaled logarithmically.
The services
property can be used to decide how your computer's speaker will be exposed: as a lightbulb, fan, speaker, or a combination of all 3.
Please note that while iOS 11 supports "HomeKit speakers" this appears to actually be via AirPlay 2, so the "speaker" option is unlikely to work!
If no services key is provided a lightbulb will be exposed.
"accessories": [
{
"accessory": "ComputerSpeakers",
"name": "MacBook"
}
]
"accessories": [
{
"accessory": "ComputerSpeakers",
"name": "MacBook",
"services": ["lightbulb"]
}
]
"accessories": [
{
"accessory": "ComputerSpeakers",
"name": "MacBook",
"services": ["fan"]
}
]
"accessories": [
{
"accessory": "ComputerSpeakers",
"name": "MacBook",
"services": ["speaker", "fan"]
}
]
Buttons can be exposed that will increase or decrease the system volume by a set percentage. These services are called increase-button
and decrease-button
. switchVolumeDelta
can be provided to change the default percentage change of 5%. switchDelay
controls the delay in ms between the switch being turned on and turned back off. Without a delay the Home app will not display the change. Defaults to 10
.
"accessories": [
{
"accessory": "ComputerSpeakers",
"name": "MacBook",
"services": ["fan", "increase-button", "decrease-button"],
"switchVolumeDelta": 10,
"switchDelay": 100
}
]
If you wish to set some initial values when the plugin starts you can set the initialVolume
and initiallyMuted
properties:
"accessories": [
{
"accessory": "ComputerSpeakers",
"name": "MacBook",
"initialVolume": 70,
"initiallyMuted": true
}
]
To develop homebridge-pc-volume locally:
- Clone the project
- Run
yarn install
- Run
yarn build
- Run
npm install --global $(pwd)
This will allow homebridge to find your local version of homebridge-pc-volume. After making changes you will need to restart homebridge.
You may also stop any homebridge instance you already have running and run yarn build:watch:debug
, which will start homebridge, and automatically restart it when a source file is updated. This instance of homebridge uses the .homebridge-debug/config.json
config file.