HowTo integrate your daapd-server with Home-Assistant

09.09.2020

Last modified: 12.02.2021
estimated reading time 3 min
the forked-daapd Server is an awesome replacement for the older iTunes-Server (e.g. Firefly). Here is the link to the github repository : https://github.com/ejurgensen/forked-daapd/

It is assumed that you have a running and properly configured instance of Home-Assistant. And it is also assumed that you have your daapd-server already running.

Step 1: Splitting up the configuration of Home-Assistant

edit the configuration.yaml of your home-assistant instance as shown below. There are several ways to edit configuration files depending on your setup. The result should always look like this:

############    Splitting up the configuration for forked-daapd-server    ############
automation: !include automations.yaml
input_number: !include input_number.yaml

media_player: !include media.yaml
rest_command: !include rest_command.yaml
sensor: !include sensors.yaml
switch: !include switches.yaml

############   configuring a YAML based Lovelace Dashboard for greater flexibility   ############
############   but ensuring that the default dashboard will be configurable via UI   ############
lovelace:
  mode: storage
  # Add yaml dashboards
  dashboards:
    lovelace-yaml:
      mode: yaml
      title: My Awesome Home
      icon: mdi:home-assistant
      show_in_sidebar: true
      filename: lovelace.yaml

Save the configuration

Step 2: creating the new configuration files for the daapd-server

Create a file code iconswitches.yaml file in the configuration directory of your home-assistant instance as shown below.

- platform: rest
  name: Bedroom Speaker
  resource: http://192.168.1.10:3689/api/outputs/149669430557359
  <<: $SPEAKER_PARAMS
    method: PUT
    body_on: '{"selected": true}'
    body_off: '{"selected": false}'
    is_on_template: '{% if value_json is defined %} {{ value_json.selected }} {% else %} off {% endif %}'
    scan_interval: 5

- platform: rest
  name: Hallway Speaker
  resource: http://192.168.1.10:3689/api/outputs/36051160497996
  <<: *SPEAKER_PARAMS

- platform: rest
  name: AppleTV
  resource: http://192.168.1.10:3689/api/outputs/159280432546163
  <<: *SPEAKER_PARAMS

Replace the IP address of the resource with the IP of your daapd-server.

Step 2a : getting the know devices of your daapd-server and the id of those devices

To get all known outputs (devices) of the daapd server open a browser and type the address of your daapd-server followed by /api/outputs
For example: https://192.168.1.10:3689/api/outputs

Your browser will show your all known outputs and the corresponding id. It will look similar to this:

{ "outputs": [ { "id": "149669430557359", "name": "AirPort Express BedRoom", "type": "AirPlay", "selected": false, "has_password": false, "requires_auth": false, "needs_auth_key": false, "volume": 37 }, { "id": "36051160497996", "name": "AirportExpressHallway", "type": "AirPlay", "selected": true, "has_password": false, "requires_auth": false, "needs_auth_key": false, "volume": 37 }, { "id": "225178807873973", "name": "AllSpeakers+", "type": "AirPlay", "selected": false, "has_password": false, "requires_auth": false, "needs_auth_key": false, "volume": 37 }, { "id": "159280432546163", "name": "AppleTV", "type": "AirPlay", "selected": true, "has_password": false, "requires_auth": true, "needs_auth_key": false, "volume": 37 }, { "id": "225176754010055", "name": "Chromecast Bedroom+", "type": "AirPlay", "selected": false, "has_password": false, "requires_auth": false, "needs_auth_key": false, "volume": 37 }, { "id": "201465269782", "name": "core", "type": "AirPlay", "selected": false, "has_password": false, "requires_auth": false, "needs_auth_key": false, "volume": 37 }, { "id": "225179517502430", "name": "Home Mini Livingroom+", "type": "AirPlay", "selected": false, "has_password": false, "requires_auth": false, "needs_auth_key": false, "volume": 0 }, { "id": "225180256734299", "name": "Living Room 1_3722+", "type": "AirPlay", "selected": false, "has_password": false, "requires_auth": false, "needs_auth_key": false, "volume": 37 }, { "id": "2981933678", "name": "AllSpeakers", "type": "Chromecast", "selected": false, "has_password": false, "requires_auth": false, "needs_auth_key": false, "volume": 37 }, { "id": "2820081666", "name": "Chromecast Bedroom", "type": "Chromecast", "selected": false, "has_password": false, "requires_auth": false, "needs_auth_key": false, "volume": 37 }, { "id": "2751583723", "name": "Home Mini Livingroom", "type": "Chromecast", "selected": true, "has_password": false, "requires_auth": false, "needs_auth_key": false, "volume": 37 }, { "id": "59990543", "name": "HomeMini Bedroom", "type": "Chromecast", "selected": false, "has_password": false, "requires_auth": false, "needs_auth_key": false, "volume": 37 }, { "id": "4076771296", "name": "Living Room 1_3722", "type": "Chromecast", "selected": false, "has_password": false, "requires_auth": false, "needs_auth_key": false, "volume": 37 }, { "id": "0", "name": "Computer", "type": "ALSA", "selected": false, "has_password": false, "requires_auth": false, "needs_auth_key": false, "volume": 37 } ] }

That’s the JSON-Output plainly shown by your browser. After prettifying the output it will look like this:

{
    "outputs": [
        {
            "id": "149669430557359",
            "name": "AirPort Express BedRoom",
            "type": "AirPlay",
            "selected": false,
            "has_password": false,
            "requires_auth": false,
            "needs_auth_key": false,
            "volume": 37
        },
        {
            "id": "36051160497996",
            "name": "AirportExpressHallway",
            "type": "AirPlay",
            "selected": true,
            "has_password": false,
            "requires_auth": false,
            "needs_auth_key": false,
            "volume": 37
        },
        {
            "id": "225178807873973",
            "name": "AllSpeakers+",
            "type": "AirPlay",
            "selected": false,
            "has_password": false,
            "requires_auth": false,
            "needs_auth_key": false,
            "volume": 37
        },
        {
            "id": "159280432546163",
            "name": "AppleTV",
            "type": "AirPlay",
            "selected": true,
            "has_password": false,
            "requires_auth": true,
            "needs_auth_key": false,
            "volume": 37
        },
        {
            "id": "225176754010055",
            "name": "Chromecast Bedroom+",
            "type": "AirPlay",
            "selected": false,
            "has_password": false,
            "requires_auth": false,
            "needs_auth_key": false,
            "volume": 37
        },
        {
            "id": "201465269782",
            "name": "core",
            "type": "AirPlay",
            "selected": false,
            "has_password": false,
            "requires_auth": false,
            "needs_auth_key": false,
            "volume": 37
        },
        {
            "id": "225179517502430",
            "name": "Home Mini Livingroom+",
            "type": "AirPlay",
            "selected": false,
            "has_password": false,
            "requires_auth": false,
            "needs_auth_key": false,
            "volume": 0
        },
        {
            "id": "225180256734299",
            "name": "Living Room 1_3722+",
            "type": "AirPlay",
            "selected": false,
            "has_password": false,
            "requires_auth": false,
            "needs_auth_key": false,
            "volume": 37
        },
        {
            "id": "2981933678",
            "name": "AllSpeakers",
            "type": "Chromecast",
            "selected": false,
            "has_password": false,
            "requires_auth": false,
            "needs_auth_key": false,
            "volume": 37
        },
        {
            "id": "2820081666",
            "name": "Chromecast Bedroom",
            "type": "Chromecast",
            "selected": false,
            "has_password": false,
            "requires_auth": false,
            "needs_auth_key": false,
            "volume": 37
        },
        {
            "id": "2751583723",
            "name": "Home Mini Livingroom",
            "type": "Chromecast",
            "selected": true,
            "has_password": false,
            "requires_auth": false,
            "needs_auth_key": false,
            "volume": 37
        },
        {
            "id": "59990543",
            "name": "HomeMini Bedroom",
            "type": "Chromecast",
            "selected": false,
            "has_password": false,
            "requires_auth": false,
            "needs_auth_key": false,
            "volume": 37
        },
        {
            "id": "4076771296",
            "name": "Living Room 1_3722",
            "type": "Chromecast",
            "selected": false,
            "has_password": false,
            "requires_auth": false,
            "needs_auth_key": false,
            "volume": 37
        },
        {
            "id": "0",
            "name": "Computer",
            "type": "ALSA",
            "selected": false,
            "has_password": false,
            "requires_auth": false,
            "needs_auth_key": false,
            "volume": 37
        }
    ]
}

That’s better and gives you all the information you need. Now replace the part of the resource url after output/ with the id of your speaker.

Step 3: input_number.yaml

create a new file in your Home-Assistant configuration directory and name it input_number.yaml.
Edit the input_number.yaml as shown below:

bedroom_volume_slider:
name: Bedroom Volume
min: 0
max: 100
step: 1

hallway_volume_slider:
name: Hallway Volume
min: 0
max: 100
step: 1

appletv_volume_slider:
name: AppleTV Volume
min: 0
max: 100
step: 1

Save and close the file.

Tags:
Was this article helpful?
Dislike 0
Views: 65