FHEM - Anwendungen > Multimedia

[Neues Modul] BOSE SoundTouch

(1/131) > >>

Das Modul ist ab sofort im offiziellen FHEM Repository. Bitte beachtet die benötigten Perl Libraries vor Verwendung.

Hallo zusammen,

hier ein neues Modul zur Steuerung der BOSE SoundTouch Familie. Die unterstützten Features können dem Changelog unten entnommen werden.

Folgende Libraries werden benötigt:
sudo apt-get install libwww-perl libmojolicious-perl libxml-simple-perl libnet-bonjour-perl libev-perl libdigest-perl-md5-perl
libmojolicious-perl muss >=5.54 sein, unter wheezy steht nur 2.x zur Verfügung. In so einem Fall kann über
sudo apt-get install cpanminus
sudo cpanm Mojolicious
die aktuellste Version installiert werden.

define bose_system BOSEST
Nach einer Minute erscheinen die Player unter "Unsorted"

Einrichtung TTS
sudo apt-get install libexif-dev libjpeg-dev libflac-dev libvorbis-dev libsqlite3-dev libavformat-dev libid3tag0-dev
sudo apt-get build-dep minidlna
mkdir minidlna
cd minidlna
git clone git://git.code.sf.net/p/minidlna/git minidlna-git
cd minidlna-git
./autogen.sh && ./configure && make (wenn ihr hier Fehler habt, dann bitte posten)
sudo make install

/etc/minidlna.conf (alles andere default!)

--- Code: ---media_dir=/var/lib/minidlna
--- Ende Code ---


--- Code: ---#!/bin/sh
# MiniDLNA initscript
# Based on the mediatomb debian package.
# Original authors: Tor Krill <tor@excito.com>
#                   Leonhard Wimmer <leo@mediatomb.cc>
#                   Andres Mejia <mcitadel@gmail.com>
# Modified by: Benoît Knecht <benoit.knecht@fsfe.org>
# Provides:          minidlna
# Required-Start:    $network $local_fs $remote_fs
# Required-Stop::    $network $local_fs $remote_fs
# Should-Start:      $all
# Should-Stop:       $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start minidlna at boot time
# Description:       Manage the minidlna daemon, a DLNA/UPnP-AV media server.

unset USER

# PATH should only include /usr/* if it runs after the mountnfs.sh script
DESC="DLNA/UPnP-AV media server"

# Exit if the package is not installed
[ -x $DAEMON ] || exit 0

# Read configuration variable file if it is present
[ -r $DEFAULT ] && . $DEFAULT

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

# Do not start the daemon if NO_START is enabled in DEFAULT
if [ "$START_DAEMON" != "yes" ] && [ "$1" != "stop" ]; then
        log_warning_msg "$NAME: Not starting $DESC."
        log_warning_msg "$NAME: Disabled in $DEFAULT."
        exit 0

# Set the default configuration file
if [ -z $CONFIGFILE ]; then

# Set the default log file
if [ -z $LOGFILE ]; then

# Run as `minidlna' if USER is not specified or is `root'
if [ -z $USER ]; then

# If no group is specified, use USER
if [ -z $GROUP ]; then


# Function that starts the daemon/service
        # Return
        #   0 if daemon has been started
        #   1 if daemon was already running
        #   2 if daemon could not be started
        touch $LOGFILE && chown $USER:$GROUP $LOGFILE || return 2
        if [ ! -d $PIDDIR ]; then
            mkdir $PIDDIR || return 2
        chown $USER:$GROUP $PIDDIR || return 2

        start-stop-daemon --start --quiet --pidfile $PIDFILE \
                --chuid $USER:$GROUP --exec $DAEMON --test > /dev/null \
                || return 1
        start-stop-daemon --start --quiet --pidfile $PIDFILE \
                --chuid $USER:$GROUP --exec $DAEMON -- \
                $DAEMON_ARGS \
                || return 2

# Function that stops the daemon/service
        # Return
        #   0 if daemon has been stopped
        #   1 if daemon was already stopped
        #   2 if daemon could not be stopped
        #   other if a failure occurred
        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --exec $DAEMON
        [ "$RETVAL" = 2 ] && return 2
        # Wait for children to finish too if this is a daemon that forks
        # and if the daemon is only ever run from this initscript.
        start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
        [ "$?" = 2 ] && return 2
        # Many daemons don't delete their pidfiles when they exit.
        rm -rf $PIDDIR
        return "$RETVAL"

# Function that signals log rotation to the daemon/service
        start-stop-daemon --stop --quiet --signal USR1 --pidfile $PIDFILE --exec $DAEMON

case "$1" in
    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
    case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
       status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
        log_daemon_msg "Restarting $DESC" "$NAME"
        case "$?" in
                if [ "$1" = "force-reload" ]; then
                        # Rescan the collection
                        DAEMON_ARGS="$DAEMON_ARGS -R"
                case "$?" in
                        0) log_end_msg 0 ;;
                        1) log_end_msg 1 ;; # Old process is still running
                        *) log_end_msg 1 ;; # Failed to start
                # Failed to stop
                log_end_msg 1
        log_daemon_msg "Reopening log file $LOGFILE"
        log_end_msg $?
        echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload|rotate}" >&2
        exit 3

--- Ende Code ---


--- Code: ---v1.5.6 - 20160611
 - FEATURE: auto-zone, start zone-play if speakers are playing the same (contentItemLocation)
             attr <name> autoZone on (default: off)
 - BUGFIX: set zone only from master device as slave devices might not always report the truth (known bug at BOSE)
 - CHANGE: set zonemember_X to UDN instead of player name
 - CHANGE: delete TTS files after 30 days
 - CHANGE: reduce number of http calls after each discovery process
 - CHANGE: reduce number of http calls for key presses

v1.5.5 - 20160510
 - BUGFIX: fix unitiliazed value in handleDeviceByIp

v1.5.4 - 20160509
 - FEATURE: restore volume when speaker goes online
             allows to power off the box completely without loosing
             previous volume settings
 - BUGFIX: fix possible unitialized value
 - BUGFIX: fix next which should be return
 - BUGFIX: sometimes double-tap feature wasn't working due to BOSE not
           updating zones for slave speakers

v1.5.3 - 20160425
 - FEATURE: support static IPs (should only be used if device can't be discovered)
            attr bose_system staticIPs,
 - FEATURE: support speak channel name (useful for SoundTouch w/o display)
            attr <name> speakChannel 1-6
            attr <name> speakChannel 2,3,5,6
 - BUGFIX: retry websocket setup every 5s if it fails
 - BUGFIX: update supportClockDisplay reading only on reconnect
 - CHANGE: remove user attr from main device

v1.5.2 - 20160403
 - FEATURE: support clock display (SoundTouch 20/30)
             set <name> clock enable/disable

v1.5.1 - 20160330
 - CHANGE: updated documentation (again many thx to Miami!)
 - FEATURE: support triple-tap (currently no function implemented: any ideas? :))
 - CHANGE: change back channel even after speakOff
 - BUGFIX: unitialized value fixed

 - FEATURE: support SetExtensions (on-for-timer,...)
 - FEATURE: support TTS (TextToSpeach) via Google Translate
            set <name> speak "This is a test message"
 - FEATURE: support volume control for TTS
            set <name> speak "This message has different volume" 30
 - FEATURE: support different languages for TTS
            set <name> speak "Das ist ein deutscher Test" de
            set <name> speak "Das ist ein deutscher Test" 30 de
 - FEATURE: support off (instead of resume) after TTS messages (restores only volume settings)
            set <name> speakOff "Music is going to switch off now. Good night." 30 en
 - FEATURE: speak "not available" text on Google Captcha
            can be disabled by ttsSpeakOnError = 0
 - FEATURE: set default TTS language via ttsLanguage attribute
 - FEATURE: automatically add DLNA server running on the same
            server as FHEM to the BOSE library
 - FEATURE: automatically add all DLNA servers to BOSE library
            requires autoAddDLNAServers = 1 attribute for "main" (not players!)
 - FEATURE: reuse cached TTS files for 30 days
 - FEATURE: set DLNA TTS directory via ttsDirectory attribute
 - FEATURE: set DLNA TTS server via ttsDLNAServer attribute
            only needed if the DLNA server is not the FHEM server
 - FEATURE: support ttsVolume for speak
            ttsVolume = 20 (set volume 20 for speak)
            ttsVolume = +20 (increase volume by 20 from current level)
 - FEATURE: add html documentation (provided by Miami)
 - FEATURE: support relative volume settings with +/-
            set <name> volume +3
            set <name> speak "This is a louder message" +10
 - FEATURE: new reading "connectedDLNAServers" (blanks are replaced by "-")
 - FEATURE: support add/remove DLNA servers to the BOSE library
            set <name> addDLNAServer RPi
            set <name> removeDLNAServer RPi
 - FEATURE: add readings for channel_07-20
 - FEATURE: support saveChannel to save current channel to channel_07-20
 - FEATURE: support bass settings only if available (/bassCapabilities)
 - FEATURE: support bluetooth only if available (/sources)
 - FEATURE: support switch source to airplay (untested)
 - BUGFIX: update zone on Player discovery
 - BUGFIX: fixed some uninitialized variables
 - CHANGE: limit recent_X readings to 15 max

 - FEATURE: support multi-room (playEverywhere, stopPlayEverywhere)
 - FEATURE: show current zone members in readings
 - FEATURE: support createZone <deviceID1>,<deviceID2>,...
 - FEATURE: support addToZone <deviceID1>,<deviceID2>,...
 - FEATURE: support removeFromZone <deviceID1>,<deviceID2>,...
 - FEATURE: add "double-tap" multi-room feature
            double-tap (<1s) a hardware preset button to
            enable or disable the multi-room feature
 - FEATURE: support bass settings
 - FEATURE: support infoUpdated (e.g. deviceName change)
 - FEATURE: support mute on/off/toggle
 - FEATURE: support recent channel list
            set name recent X
            names for recent list entries are shown in readings
 - FEATURE: support channel_07-20 by attribute
            format:name|location|source|sourceAccount or
                        name|location|source| if no sourceAccount
 - FEATURE: support bluetooth/bt-discover/aux mode
 - FEATURE: support ignoreDeviceIDs for main define
 - CHANGE: reading channel_X => channel_0X (e.g. channel_02)

 - FEATURE: print module version on startup of main module
 - FEATURE: support device rename (e.g. BOSE_... => wz_BOSE)
 - FEATURE: show preset itemNames in channel_X reading
 - FEATURE: automatically update preset readings on change
 - FEATURE: add description reading (could be very long)
 - CHANGE: change log level for not implemented events to 4
 - CHANGE: use only one processXml function for websocket and http
 - BUGFIX: fix set off/on more than once within 1 second
 - BUGFIX: fix warnings during setup process
 - BUGFIX: support umlauts in all readings
 - BUGFIX: handle XMLin errors with eval
 - BUGFIX: handle "set" when speaker wasn't found yet

 - FEATURE: support prev/next track

 - FEATURE: update channel based on websocket events
 - BUGFIX: specify minimum libmojolicious-perl version
 - BUGFIX: reconnect websocket if handshake fails
 - BUGFIX: presence reading fixed
 - CHANGE: websocket request timeout changed to 10s (prev. 5s)
 - CHANGE: clockDisplayUpdated message handled now

 - CHANGE: completely drop ithreads (reduces memory usage)
 - CHANGE: search for new devices every 60s (BlockingCall)
 - CHANGE: check presence status based on websocket connection
 - BUGFIX: removed arguments and readings for main BOSEST
 - FEATURE: read volume on startup

  - fix "EV does not work with ithreads."

  - fix memory leak
  - use select instead of usleep

  - bugfix for on/off support

  - [b]autodiscover BOSE SoundTouch players: autocreate BOSE_<deviceID>[/b]
  - add alias for newly created devices
  - update IP if the player IP changes
  - automatically re-connect websocket
  - support UTF-8 names with umlauts
  - reconnect websocket when connection closed
  - add firmware version & IP readings
  - automatically update /info on IP update
  - state: offline,playing,stopped,paused,online (online means standby)
  - support on/off commands based on current state
  - add support more readings for now_playing

 - connect to websocket to receive speaker events (now playing, ...)
 - support stop/play/pause/power
 - change preset to channel according to DevGuidelinesAV
 - read /info on startup

 - define BOSE Soundtouch based on fixed IP
 - change volume via /volume
 - change preset via /key
--- Ende Code ---

Coole Sache!
Wenn hier weiterentwickelt wird, wollte ich mal auf eine existierende Guideline für einheitliche Befehlssätze in allen fhem-Audio-Modulen aufmerksam machen, vielleicht kann man sich ja daran oriientieren:
'key' gibt es da bspw. nicht.

Gruß + viel Erfolg,

Hallo Dominik,
ich freue mich das du damit angefangen hast, auch BOSE Soundtouch in FHEM als Modul aufzunehmen.

Leider kann ich nicht mit Programmieren, da ich wenig PEARL Kenntnisse habe.
Jedoch freue ich mich darauf als Nutzer davon zu profitieren.

vielen Dank schon mal



--- Zitat von: UliM am 06 Januar 2016, 04:26:08 ---Hi,
Coole Sache!
Wenn hier weiterentwickelt wird, wollte ich mal auf eine existierende Guideline für einheitliche Befehlssätze in allen fhem-Audio-Modulen aufmerksam machen, vielleicht kann man sich ja daran oriientieren:
'key' gibt es da bspw. nicht.

Gruß + viel Erfolg,

--- Ende Zitat ---
Hi Uli,
danke für die Info. Den Guide kannte ich noch nicht.
Keine Sorge 'key' ist nicht als Befehl gedacht, mit /key meinte ich nur den WebService (http://IP:8090/key) über welchen der Befehl an das BOSE System geschickt wird.

Werde dann bei der weiteren Implementierung die Guidelines berücksichtigen.


Update auf v0.2 im 1. Post.

Es werden nun auch Events vom WebSocket (Port 8080) verarbeitet und in Readings hinterlegt. Aktuell noch nicht für alle Events implementiert. Zukünftig soll es dadurch möglich sein die Preset Tasten auch für andere Funktionen zu nutzen :)


[0] Themen-Index

[#] Nächste Seite

Zur normalen Ansicht wechseln