1.2.4 • Published 5 years ago

forked-daapd-homebridge-middleware v1.2.4

Weekly downloads
3
License
GPL-3.0
Repository
github
Last release
5 years ago

For use in conjunction with

to play your favourite radio stations with just a voice command and control multiple output devices.

Examples:

Hallway Kitchen Volume control

Overview

This package acts like a standalone proxy server which endpoints get to be called by the homebridge-better-http-rgb plugin. The plugin is responsible for then advertising the various accessories to homebridge (see config.json). The middleware is using the amazing forked-daapd JSON API to control the various accessories and redirect their actions to forked-daapd. Therefore it is possible to advertise almost any forked-daapd action to HomeKit.

Prerequisites

  • Node.js >= v10.15.1 with npm >= v6.4.1
  • forked-daapd >= v26.4 available in your local network
  • homebridge >= v0.4.46 with homebridge-better-http-rgb >= v2.0.0 plugin available in your local network
  • At least one output device (AirPlay, Chromecast, etc) in your local network which can be controlled by forked-daapd
  • At least one playlist with an internet radio stream url in it, available in your forked-daapd library

Installation and execution

Option 1: Installing as npm dependency

$ mkdir forked-daapd-homebridge-middleware
$ npm init
$ npm install --save forked-daapd-homebridge-middleware

For the npm init command answer all questions with ENTER key.

Configuration

See configuration.

Run as npm dependency

$ cd forked-daapd-homebridge-middleware
$ npx forked-daapd-homebridge-middleware

Option 2: Installing as separate project

$ git clone https://github.com/moecre/forked-daapd-homebridge-middleware.git
$ cd forked-daapd-homebridge-middleware
$ npm install

Configuration

See configuration.

Run as separate project

$ cd forked-daapd-homebridge-middleware
$ npm start

Running with PM2

In production I strongly advise you to use a process manager like PM2 to run forked-daapd-homebridge-middleware. In case anything unexpected happens the middleware is going to be restarted automatically by PM2.

PM2 status

By the way, that's a good solution for your Homebridge process, too.

Configuration

Create forked-daapd-homebridge-middleware configuration file

Copy the distributed index.dist.json to index.json in the same directory and change the file according to your setup and needs.

ParamDescription
baseUrlURL to your forked-daapd JSON API

Adding your accessories to Homebridge

Please take a look at the provided config.json for examples. In general your Homebridge configuration file is located in ~/.homebridge/config.json.

Radio station

Please replace placeholders, eg. {NAME YOUR RADIO STATION} for ROCK ANTENNE. Keep in mind that the name must be unique over all your accessories (UUID in Homebridge).

{
  "accessory": "HTTP-RGB",
  "name": "{NAME YOUR RADIO STATION}",
  "service": "Light",
  "switch": {
    "status": "http://{HOSTNAME ON WHICH FORKED-DAAPD-HOMEBRIDGE-MIDDLEWARE IS RUNNING}:3000/playlists/{URL ENCODED NAME OF THE PLAYLIST IN FORKED-DAAPD}",
    "powerOn": "http://{HOSTNAME ON WHICH FORKED-DAAPD-HOMEBRIDGE-MIDDLEWARE IS RUNNING}:3000/playlists/{URL ENCODED NAME OF THE PLAYLIST IN FORKED-DAAPD}/play[?shuffle=true]",
    "powerOff": "http://{HOSTNAME ON WHICH FORKED-DAAPD-HOMEBRIDGE-MIDDLEWARE IS RUNNING}:3000/player/stop"
  }
}

The /playlists/:playlist/play endpoint has an optional parameter shuffle. If applied all the playlist items get added to the queue shuffled.

Speaker (output device)

Please replace placeholders, eg. {NAME YOUR SPEAKER} for Hallway speaker. Keep in mind that the name must be unique over all your accessories (UUID in Homebridge).

{
  "accessory": "HTTP-RGB",
  "name": "{NAME YOUR SPEAKER}",
  "service": "Light",
  "switch": {
    "status": "http://{HOSTNAME ON WHICH FORKED-DAAPD-HOMEBRIDGE-MIDDLEWARE IS RUNNING}:3000/outputs/{URL ENCODED NAME OF OUTPUT DEVICE IN FORKED-DAAPD}",
    "powerOn": "http://{HOSTNAME ON WHICH FORKED-DAAPD-HOMEBRIDGE-MIDDLEWARE IS RUNNING}:3000/outputs/{URL ENCODED NAME OF OUTPUT DEVICE IN FORKED-DAAPD}/state/on",
    "powerOff": "http://{HOSTNAME ON WHICH FORKED-DAAPD-HOMEBRIDGE-MIDDLEWARE IS RUNNING}:3000/outputs/{URL ENCODED NAME OF OUTPUT DEVICE IN FORKED-DAAPD}/state/off"
  },
  "brightness": {
     "status": "http://{HOSTNAME ON WHICH FORKED-DAAPD-HOMEBRIDGE-MIDDLEWARE IS RUNNING}:3000/outputs/{URL ENCODED NAME OF OUTPUT DEVICE IN FORKED-DAAPD}/volume",
     "url": "http://{HOSTNAME ON WHICH FORKED-DAAPD-HOMEBRIDGE-MIDDLEWARE IS RUNNING}:3000/outputs/{URL ENCODED NAME OF OUTPUT DEVICE IN FORKED-DAAPD}/volume/%s"
  }
}

How to create playlists in your forked-daapd server

Please have a look here.