Expose Chromecast/Chromecast Audio devices in Homebridge to enable automations
This command will work on Raspbian. Please Google the right comand for your platform.
sudo apt-get install libavahi-compat-libdnssd-dev
Example config.json:
{
"accessories": [
{
"accessory": "AutomationChromecast",
"name": "Test",
"chromecastDeviceName": "<The device Name of your Chromecast>",
"switchOffDelay": 10000
}
]
}
This accessory will create a switch linked with the status of a Chromecast or Chromecast Audio device.
It will also create a Motion Sensor, to trigger automation.
When you stream some audio/video to the Chromecast / Chromecast Audio, the switch turns on and the Sensor detects movement. Stop the streaming will turn the switch off and the sensor will stop detecting movements.
Turning On the switch will play the currently casted stream. Turning Off the switch will stop the stream.
The switch has the following properties:
Name | Description | Example |
---|---|---|
Type | The type of the device. | Chromecast Audio |
IP Address | The full IP address + port of the device | 192.168.1.100:8009 |
ID | The Chromecast UUID | a80722d5aa123456e408635c475988ca |
Volume | The volume slider, to adjust the volume of the device (it can be also used within automations) | n/a |
Note: some properties are not compatible with iOS Home app, use Elgato Eve app instead.
Attribute | Required | Usage | Example |
---|---|---|---|
name | Yes | A unique name for the accessory. It will be used as the accessory name in HomeKit. | Living Room TV |
chromecastDeviceName | Yes | The name of your Chromecast device as shown in your Google Home App (case insensitive). This plugin will use Bonjour/mdns to detect the IP address of the Chromecast based on this name. | Living Room |
switchOffDelay | No (default: 0 ) |
The number of milliseconds to wait before the motion sensor stops detecting movement after stop casting. By default it is set to zero: as soon as you stop playing, the motion sensor will switch off. If you want to add a delay, set it to a value greater than zero. This config is useful for automations (see later example on this readme). | 5000 (milliseconds, equal to 5 seconds) |
This project as been largely inspired by the work of @robertherber
Let's assume you have some powered speakers that need to be turned on before use (I have for example the Yamaha HS8).
You can connect the speakers to a Chromecast Audio device and connect the to an Elgato Eve Energy) switch.
You want to turn On the speakers automatically when streaming music and turning them Off once done.
Here's how:
switchOffDelay
to 30000 (30 seconds)Using a delay will prevent the speakers from switching on and off constantly when you momentarily stop/start a stream (to avoid damages to the speakers)
Do you want to play some audio/video on demand from your automation?
Check my homebridge-automation-chromecast-play plugin.