djm300 / airtunes2mqtt

MQTT controlled Multi-Room Audio based on Airplay/Airtunes :speaker:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

airtunes2mqtt

mqtt-smarthome NPM version Dependency Status Build Status XO code style License

MQTT controlled Multi-Room Audio based on Airplay/Airtunes 🔈

This is a little daemon that can retrieve an audio stream via TCP socket or from a Alsa Loopback device and stream it to Airplay/Airtunes compatible receivers. Via MQTT you can control the receivers volume and enable/disable the receivers. I'm using it in conjunction with Mopidy to create a Multiroom Smarthome-integrated audio playback system with several Airplay Speakers.

Based on lperrins node_airtunes - all credits belong to him. Also thanks to Adam Duncan for creating a fork that works with recent versions of Node.js.

Installation

Prerequisite: Node.js >= 6

$ sudo npm install -g airtunes2mqtt
$ airtunes2mqtt --help

I suggest to use pm2 to manage the airtunes2mqtt process (start on system boot, manage log files, ...).

Command Line Options

Usage: airtunes2mqtt [options]

Options:
  --version        Show version number                                 [boolean]
  -h, --help       Show help                                           [boolean]
  -u, --mqtt-url   mqtt broker url. May contain user/password
                                                   [default: "mqtt://127.0.0.1"]
  -s, --speaker    name:host:port or name:host:portStart:portEnd of speaker. May
                   be repeated.                                       [required]
  -n, --name       instance name. used as mqtt client id and as prefix for
                   connected topic                         [default: "airtunes"]
  -v, --verbosity  possible values: "error", "warn", "info", "debug"
                                                               [default: "info"]
  -p, --port       TCP Listen port for audio reception          [default: 12346]
  -l, --loopback   Use Alsa loopback device instead of TCP listener    [boolean]
  -d, --device     Alsa loopback device               [default: "hw:Loopback,1"]

Example Command Line

$ airtunes2mqtt -s LivingRoom:192.168.2.100:5000 Kitchen:192.168.2.103:5000 -s SoundFly:192.168.2.105:1024:1032 -v debug

Example Mopidy Configuration

[audio]
output = audioconvert ! audio/x-raw,format=S16LE,rate=44100,channels=2,layout=interleaved ! tcpclientsink host=127.0.0.1 port=12346

Topics

subscribed

  • airtunes/set/<speaker-name>/enable - Enable or disable a speaker (payload can be true, false, 0 or `1)
  • airtunes/set/<speaker-name>/disable - Disable a speaker (payload is irrelevant)
  • airtunes/set/<speaker-name>/volume - Set a speakers volume (payload has to be a number between 0 and 100)

published

  • airtunes/connected - Publishes 1 after airtunes2mqtt started, 2 when a client is connected via tcp socket respectively when the alsa loopback device is connected and 0 as last will.
  • airtunes/status/activeSpeakers - Number of currently enables speakers.
  • airtunes/status/speaker/enable - Actual speaker state.
  • airtunes/status/speaker/volume - Actual speaker volume.

License

Copyright (c) 2015-2018 Sebastian 'hobbyquaker' Raff hq@ccu.io

About

MQTT controlled Multi-Room Audio based on Airplay/Airtunes :speaker:

License:MIT License


Languages

Language:JavaScript 100.0%