2017-01-24 13:29:30 +00:00
###############################################################################
2017-02-25 06:42:15 +00:00
#
2017-01-24 13:29:30 +00:00
# Developed with Kate
#
2018-03-13 19:14:29 +00:00
# (c) 2017-2018 Copyright: Marko Oldenburg (leongaultier at gmail dot com)
2017-01-24 13:29:30 +00:00
# All rights reserved
#
2017-02-20 05:52:39 +00:00
# Special thanks goes to comitters:
2017-04-26 04:38:01 +00:00
# - Olaf Schnicke Thanks for many many Code
# - Dieter Hehlgans Thanks for Commandref
2017-02-20 05:52:39 +00:00
#
#
2017-01-24 13:29:30 +00:00
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# any later version.
#
# The GNU General Public License can be found at
# http://www.gnu.org/copyleft/gpl.html.
# A copy is found in the textfile GPL.txt and important notices to the license
# from the author is found in LICENSE.txt distributed with these scripts.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# $Id$
#
###############################################################################
package main ;
use strict ;
use warnings ;
2017-02-03 07:54:57 +00:00
use JSON qw( decode_json ) ;
use Encode qw( encode_utf8 ) ;
2017-03-12 20:27:53 +00:00
use URI::Escape ;
2017-05-09 10:23:49 +00:00
#use Data::Dumper;
2017-01-24 13:29:30 +00:00
2021-02-28 18:51:13 +00:00
my $ version = "1.0.5" ;
2017-03-12 20:27:53 +00:00
2017-01-24 13:29:30 +00:00
# Declare functions
sub HEOSPlayer_Initialize ($) ;
sub HEOSPlayer_Define ($$) ;
sub HEOSPlayer_Undef ($$) ;
sub HEOSPlayer_Attr (@) ;
sub HEOSPlayer_Parse ($$) ;
sub HEOSPlayer_WriteReadings ($$) ;
sub HEOSPlayer_Set ($$@) ;
2017-01-26 13:53:29 +00:00
sub HEOSPlayer_PreProcessingReadings ($$) ;
2017-01-27 21:22:30 +00:00
sub HEOSPlayer_GetPlayerInfo ($) ;
sub HEOSPlayer_GetPlayState ($) ;
2017-03-14 08:44:30 +00:00
sub HEOSPlayer_GetQueue ($) ;
2017-01-27 21:22:30 +00:00
sub HEOSPlayer_GetNowPlayingMedia ($) ;
2017-02-02 08:43:45 +00:00
sub HEOSPlayer_GetPlayMode ($) ;
2017-02-09 10:43:17 +00:00
sub HEOSPlayer_GetVolume ($) ;
2017-02-20 05:52:39 +00:00
sub HEOSPlayer_Get ($$@) ;
2017-02-21 05:50:31 +00:00
sub HEOSPlayer_GetMute ($) ;
2017-04-26 04:22:04 +00:00
sub HEOSPlayer_MakePlayLink ($$$$$$$$) ;
2017-03-12 20:27:53 +00:00
2017-01-27 21:22:30 +00:00
2017-01-24 13:29:30 +00:00
sub HEOSPlayer_Initialize ($) {
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
my ( $ hash ) = @ _ ;
2017-02-20 05:52:39 +00:00
$ hash - > { Match } = '.*{"command":."player.*|.*{"command":."event/player.*|.*{"command":."event\/repeat_mode_changed.*|.*{"command":."event\/shuffle_mode_changed.*|.*{"command":."event\/favorites_changed.*' ;
2017-02-25 06:42:15 +00:00
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
# Provider
$ hash - > { SetFn } = "HEOSPlayer_Set" ;
2017-02-22 09:19:23 +00:00
$ hash - > { GetFn } = "HEOSPlayer_Get" ;
2017-01-24 13:29:30 +00:00
$ hash - > { DefFn } = "HEOSPlayer_Define" ;
$ hash - > { UndefFn } = "HEOSPlayer_Undef" ;
$ hash - > { AttrFn } = "HEOSPlayer_Attr" ;
$ hash - > { ParseFn } = "HEOSPlayer_Parse" ;
$ hash - > { AttrList } = "IODev " .
"disable:1 " .
2017-02-09 10:43:17 +00:00
"mute2play:1 " .
2017-03-15 04:18:34 +00:00
"channelring:1 " .
2017-01-24 13:29:30 +00:00
$ readingFnAttributes ;
foreach my $ d ( sort keys % { $ modules { HEOSPlayer } { defptr } } ) {
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
my $ hash = $ modules { HEOSPlayer } { defptr } { $ d } ;
2017-02-25 06:42:15 +00:00
$ hash - > { VERSION } = $ version ;
2017-01-24 13:29:30 +00:00
}
}
sub HEOSPlayer_Define ($$) {
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
my ( $ hash , $ def ) = @ _ ;
my @ a = split ( "[ \t]+" , $ def ) ;
splice ( @ a , 1 , 1 ) ;
my $ iodev ;
my $ i = 0 ;
2017-02-25 06:42:15 +00:00
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
foreach my $ param ( @ a ) {
if ( $ param =~ m/IODev=([^\s]*)/ ) {
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
$ iodev = $ 1 ;
splice ( @ a , $ i , 3 ) ;
last ;
}
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
$ i + + ;
}
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
return "too few parameters: define <name> HEOSPlayer <pid>" if ( @ a < 2 ) ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
my ( $ name , $ pid ) = @ a ;
$ hash - > { PID } = $ pid ;
$ hash - > { VERSION } = $ version ;
AssignIoPort ( $ hash , $ iodev ) if ( ! $ hash - > { IODev } ) ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
if ( defined ( $ hash - > { IODev } - > { NAME } ) ) {
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
Log3 $ name , 3 , "HEOSPlayer ($name) - I/O device is " . $ hash - > { IODev } - > { NAME } ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
} else {
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
Log3 $ name , 1 , "HEOSPlayer ($name) - no I/O device" ;
}
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
$ iodev = $ hash - > { IODev } - > { NAME } ;
my $ code = abs ( $ pid ) ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
$ code = $ iodev . "-" . $ code if ( defined ( $ iodev ) ) ;
my $ d = $ modules { HEOSPlayer } { defptr } { $ code } ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
return "HEOSPlayer device $hash->{pid} on HEOSMaster $iodev already defined as $d->{NAME}."
2017-02-25 06:42:15 +00:00
if ( defined ( $ d ) && $ d - > { IODev } == $ hash - > { IODev } && $ d - > { NAME } ne $ name ) ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
Log3 $ name , 3 , "HEOSPlayer ($name) - defined with Code: $code" ;
2017-02-02 08:43:45 +00:00
$ attr { $ name } { room } = "HEOS" if ( ! defined ( $ attr { $ name } { room } ) ) ;
$ attr { $ name } { devStateIcon } = "on:10px-kreis-gruen off:10px-kreis-rot" if ( ! defined ( $ attr { $ name } { devStateIcon } ) ) ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
if ( $ init_done ) {
2017-02-27 08:39:48 +00:00
2017-02-09 10:43:17 +00:00
InternalTimer ( gettimeofday ( ) + int ( rand ( 2 ) ) , "HEOSPlayer_GetPlayerInfo" , $ hash , 0 ) ;
InternalTimer ( gettimeofday ( ) + int ( rand ( 4 ) ) , "HEOSPlayer_GetPlayState" , $ hash , 0 ) ;
InternalTimer ( gettimeofday ( ) + int ( rand ( 6 ) ) , "HEOSPlayer_GetNowPlayingMedia" , $ hash , 0 ) ;
InternalTimer ( gettimeofday ( ) + int ( rand ( 8 ) ) , "HEOSPlayer_GetPlayMode" , $ hash , 0 ) ;
InternalTimer ( gettimeofday ( ) + int ( rand ( 10 ) ) , "HEOSPlayer_GetVolume" , $ hash , 0 ) ;
2017-02-27 08:39:48 +00:00
InternalTimer ( gettimeofday ( ) + int ( rand ( 12 ) ) , "HEOSPlayer_GetMute" , $ hash , 0 ) ;
2017-03-15 04:18:34 +00:00
InternalTimer ( gettimeofday ( ) + int ( rand ( 14 ) ) , "HEOSPlayer_GetQueue" , $ hash , 0 ) ;
2017-02-27 08:39:48 +00:00
2017-01-26 13:53:29 +00:00
} else {
2017-02-27 08:39:48 +00:00
2017-02-09 10:43:17 +00:00
InternalTimer ( gettimeofday ( ) + 15 + int ( rand ( 2 ) ) , "HEOSPlayer_GetPlayerInfo" , $ hash , 0 ) ;
InternalTimer ( gettimeofday ( ) + 15 + int ( rand ( 4 ) ) , "HEOSPlayer_GetPlayState" , $ hash , 0 ) ;
InternalTimer ( gettimeofday ( ) + 15 + int ( rand ( 6 ) ) , "HEOSPlayer_GetNowPlayingMedia" , $ hash , 0 ) ;
InternalTimer ( gettimeofday ( ) + 15 + int ( rand ( 8 ) ) , "HEOSPlayer_GetPlayMode" , $ hash , 0 ) ;
InternalTimer ( gettimeofday ( ) + 15 + int ( rand ( 10 ) ) , "HEOSPlayer_GetVolume" , $ hash , 0 ) ;
2017-03-15 04:18:34 +00:00
InternalTimer ( gettimeofday ( ) + 15 + int ( rand ( 12 ) ) , "HEOSPlayer_GetMute" , $ hash , 0 ) ;
InternalTimer ( gettimeofday ( ) + 15 + int ( rand ( 14 ) ) , "HEOSPlayer_GetQueue" , $ hash , 0 ) ;
2017-01-24 13:29:30 +00:00
}
2017-02-27 08:39:48 +00:00
2017-02-02 08:43:45 +00:00
readingsBeginUpdate ( $ hash ) ;
readingsBulkUpdate ( $ hash , 'state' , 'Initialized' ) ;
readingsBulkUpdate ( $ hash , 'volumeUp' , 5 ) ;
readingsBulkUpdate ( $ hash , 'volumeDown' , 5 ) ;
readingsEndUpdate ( $ hash , 1 ) ;
2017-02-27 08:39:48 +00:00
2017-02-09 10:43:17 +00:00
$ modules { HEOSPlayer } { defptr } { $ code } = $ hash ;
2017-01-24 13:29:30 +00:00
return undef ;
}
sub HEOSPlayer_Undef ($$) {
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
my ( $ hash , $ arg ) = @ _ ;
my $ pid = $ hash - > { PID } ;
my $ name = $ hash - > { NAME } ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
RemoveInternalTimer ( $ hash ) ;
my $ code = abs ( $ pid ) ;
$ code = $ hash - > { IODev } - > { NAME } . "-" . $ code if ( defined ( $ hash - > { IODev } - > { NAME } ) ) ;
delete ( $ modules { HEOSPlayer } { defptr } { $ code } ) ;
2017-02-27 08:39:48 +00:00
2017-01-27 21:22:30 +00:00
Log3 $ name , 3 , "HEOSPlayer ($name) - device $name deleted with Code: $code" ;
2017-01-24 13:29:30 +00:00
return undef ;
}
sub HEOSPlayer_Attr (@) {
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
my ( $ cmd , $ name , $ attrName , $ attrVal ) = @ _ ;
my $ hash = $ defs { $ name } ;
my $ token = $ hash - > { IODev } - > { TOKEN } ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
if ( $ attrName eq "disable" ) {
if ( $ cmd eq "set" and $ attrVal eq "1" ) {
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
readingsSingleUpdate ( $ hash , "state" , "disabled" , 1 ) ;
Log3 $ name , 3 , "HEOSPlayer ($name) - disabled" ;
2017-02-27 08:39:48 +00:00
} elsif ( $ cmd eq "del" ) {
2017-01-24 13:29:30 +00:00
readingsSingleUpdate ( $ hash , "state" , "active" , 1 ) ;
Log3 $ name , 3 , "HEOSPlayer ($name) - enabled" ;
}
}
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
if ( $ attrName eq "disabledForIntervals" ) {
if ( $ cmd eq "set" ) {
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
Log3 $ name , 3 , "HEOSPlayer ($name) - enable disabledForIntervals" ;
readingsSingleUpdate ( $ hash , "state" , "Unknown" , 1 ) ;
2017-02-27 08:39:48 +00:00
} elsif ( $ cmd eq "del" ) {
2017-01-24 13:29:30 +00:00
readingsSingleUpdate ( $ hash , "state" , "active" , 1 ) ;
Log3 $ name , 3 , "HEOSPlayer ($name) - delete disabledForIntervals" ;
}
}
}
2017-02-20 05:52:39 +00:00
sub HEOSPlayer_Get ($$@) {
2017-02-27 08:39:48 +00:00
2017-02-20 05:52:39 +00:00
my ( $ hash , $ name , @ aa ) = @ _ ;
my ( $ cmd , @ args ) = @ aa ;
my $ pid = $ hash - > { PID } ;
my $ result = "" ;
2017-03-12 20:27:53 +00:00
my $ me = { } ;
2017-04-26 04:22:04 +00:00
my $ ret ;
2017-02-27 08:39:48 +00:00
2017-04-26 04:22:04 +00:00
$ me - > { cl } = $ hash - > { CL } if ( ref ( $ hash - > { CL } ) eq 'HASH' ) ;
$ me - > { name } = $ hash - > { NAME } ;
$ me - > { pid } = $ hash - > { PID } ;
2017-02-20 05:52:39 +00:00
#Leerzeichen müßen für die Rückgabe escaped werden sonst werden sie falsch angezeigt
2017-03-12 20:27:53 +00:00
if ( $ cmd eq 'channelscount' ) {
2017-02-27 08:39:48 +00:00
2017-02-20 05:52:39 +00:00
#gibt die Favoritenanzahl zurück
2017-02-25 06:42:15 +00:00
return scalar ( @ { $ hash - > { IODev } { helper } { favorites } } ) if ( defined $ hash - > { IODev } { helper } { favorites } ) ;
2017-02-27 08:39:48 +00:00
2017-03-12 20:27:53 +00:00
} elsif ( $ cmd eq 'ls' ) {
my $ param = shift ( @ args ) ;
$ param = '' if ( ! $ param ) ;
if ( $ param eq '' ) {
2017-04-26 04:22:04 +00:00
if ( $ me - > { cl } - > { TYPE } eq 'FHEMWEB' ) {
$ ret = '<div class="container">' ;
$ ret . = '<h3 style="text-align: center;">Musik</h3><hr>' ;
$ ret . = '<div class="list-group">' ;
} else {
$ ret = "Musik\n" ;
$ ret . = sprintf ( "%-15s %s\n" , 'key' , 'title' ) ;
}
foreach my $ item ( @ { $ hash - > { IODev } { helper } { sources } } ) {
$ ret . = HEOSPlayer_MakePlayLink ( $ me - > { cl } - > { TYPE } , $ hash - > { NAME } , $ item - > { sid } , $ item - > { type } , $ item - > { name } , $ item - > { image_url } , 128 , 50 ) ;
2017-03-12 20:27:53 +00:00
}
2017-04-26 04:22:04 +00:00
$ ret . = HEOSPlayer_MakePlayLink ( $ me - > { cl } - > { TYPE } , $ hash - > { NAME } , "1025" , "heos_service" , "Playlist" , "https://production.ws.skyegloup.com:443/media/images/service/logos/musicsource_logo_playlists.png" , 128 , 32 ) ;
2017-03-12 20:27:53 +00:00
2017-04-26 04:22:04 +00:00
$ ret . = HEOSPlayer_MakePlayLink ( $ me - > { cl } - > { TYPE } , $ hash - > { NAME } , "1026" , "heos_service" , "Verlauf" , "https://production.ws.skyegloup.com:443/media/images/service/logos/musicsource_logo_history.png" , 128 , 32 ) ;
2017-03-12 20:27:53 +00:00
2017-04-26 04:22:04 +00:00
$ ret . = HEOSPlayer_MakePlayLink ( $ me - > { cl } - > { TYPE } , $ hash - > { NAME } , "1027" , "heos_service" , "Eingänge" , "https://production.ws.skyegloup.com:443/media/images/service/logos/musicsource_logo_aux.png" , 128 , 32 ) ;
2017-03-12 20:27:53 +00:00
2017-04-26 04:22:04 +00:00
$ ret . = HEOSPlayer_MakePlayLink ( $ me - > { cl } - > { TYPE } , $ hash - > { NAME } , "1028" , "heos_service" , "Favoriten" , "https://production.ws.skyegloup.com:443/media/images/service/logos/musicsource_logo_favorites.png" , 128 , 32 ) ;
2017-03-12 20:27:53 +00:00
2017-04-26 04:22:04 +00:00
$ ret . = HEOSPlayer_MakePlayLink ( $ me - > { cl } - > { TYPE } , $ hash - > { NAME } , "1029" , "heos_service" , "Warteschlange" , "https://production.ws.skyegloup.com:443/media/images/service/logos/musicsource_logo_playlists.png" , 128 , 32 ) ;
2017-03-12 20:27:53 +00:00
2017-04-26 04:22:04 +00:00
if ( $ me - > { cl } - > { TYPE } eq 'FHEMWEB' ) {
$ ret . = '</div></div>' ;
$ ret =~ s/&/&/g ;
$ ret =~ s/'/'/g ;
$ ret =~ s/\n/<br>/g ;
$ ret = "<pre>$ret</pre>" if ( $ ret =~ m/ / ) ;
$ ret = "<html>$ret</html>" ;
2017-08-25 19:34:27 +00:00
}
2017-04-26 04:22:04 +00:00
2017-03-12 20:27:53 +00:00
return $ ret ;
} else {
2017-04-26 04:22:04 +00:00
my ( $ sid , $ cid ) = split /,/ , $ param ;
2017-03-12 20:27:53 +00:00
if ( $ sid eq "1025" ) {
$ me - > { sourcename } = "Playlist" ;
} elsif ( $ sid eq "1026" ) {
$ me - > { sourcename } = "Verlauf" ;
} elsif ( $ sid eq "1027" ) {
$ me - > { sourcename } = "Eingänge" ;
} elsif ( $ sid eq "1028" ) {
$ me - > { sourcename } = "Favoriten" ;
} elsif ( $ sid eq "1029" ) {
$ me - > { sourcename } = "Warteschlange" ;
} else {
my @ sids = map { $ _ - > { name } } grep { $ _ - > { sid } =~ /$sid/i } ( @ { $ hash - > { IODev } { helper } { sources } } ) ;
$ me - > { sourcename } = $ sids [ 0 ] if ( scalar @ sids > 0 ) ;
}
my $ heosCmd = "browseSource" ;
my $ action ;
2017-03-15 04:18:34 +00:00
if ( defined $ sid && defined $ cid && $ cid ne "" ) {
2017-03-12 20:27:53 +00:00
if ( $ sid eq "1027" ) {
$ action = "sid=$cid" ;
} elsif ( $ sid eq "1026" ) {
$ me - > { sourcename } . = "/$cid" ;
$ action = "sid=$sid&cid=$cid" ;
} else {
my @ cids = map { $ _ - > { name } } grep { $ _ - > { cid } =~ /\Q$cid\E/i } ( @ { $ hash - > { IODev } { helper } { media } } ) ;
$ me - > { sourcename } . = "/" . $ cids [ 0 ] if ( scalar @ cids > 0 ) ;
$ action = "sid=$sid&cid=$cid" ;
}
2017-03-15 04:18:34 +00:00
} elsif ( defined $ sid && $ sid eq "1029" ) {
2017-04-26 04:22:04 +00:00
if ( $ me - > { cl } - > { TYPE } eq 'FHEMWEB' ) {
2017-03-15 04:18:34 +00:00
2017-04-26 04:22:04 +00:00
$ ret = '<div class="container">' ;
$ ret . = '<h2 style="text-align: center;">' . $ hash - > { NAME } . '</h2>' ;
$ ret . = '<h3 style="text-align: center;">Warteschlange</h3><hr>' ;
$ ret . = '<div class="container" style="display: inline-block;width: 50%;"><a href="#" onClick="FW_cmd(' . "'$FW_ME$FW_subdir?XHR=1&cmd" . uri_escape ( '=set ' . $ hash - > { NAME } . ' clearQueue' ) . "')" . '" style="cursor:pointer;"><img style="width: 32px; height: 32px;display: block;margin-left: auto;margin-right: auto;" src="' . "$FW_ME$FW_subdir" . '/images/fhemSVG/recycling.svg"></a></div>' ;
$ ret . = '<div class="list-group">' ;
} else {
$ ret . = "Warteschlange von $hash->{NAME} \n" ;
$ ret . = sprintf ( "%-15s %s\n" , 'key' , 'title' ) ;
}
2017-03-15 04:18:34 +00:00
my $ x = 0 ;
2017-04-26 04:22:04 +00:00
my $ itemtext ;
my $ itemkey ;
2017-03-15 04:18:34 +00:00
foreach my $ item ( @ { $ hash - > { helper } { queue } } ) {
2017-04-26 04:22:04 +00:00
$ itemtext = $ item - > { artist } ;
$ itemtext . = ( defined $ item - > { artist } ) ? ( ", " . $ item - > { album } ) : ( $ item - > { album } ) if ( defined $ item - > { album } ) ;
$ itemkey = '1029,' . + + $ x ;
if ( $ me - > { cl } - > { TYPE } eq 'FHEMWEB' ) {
my $ xcmd = 'cmd' . uri_escape ( '=set ' . $ hash - > { NAME } . ' input ' . $ itemkey ) ;
$ xcmd = "FW_cmd('$FW_ME$FW_subdir?XHR=1&$xcmd')" ;
$ ret . = '<a href="#" onClick="' . $ xcmd . '" class="list-group-item"><h4 class="list-group-item-heading">' . $ item - > { song } . '</h4><p class="list-group-item-text">' . $ itemtext . "</p></a>" ;
#$ret .= HEOSPlayer_MakePlayLink($hash->{NAME}, "1029,".++$x, "heos_queue", $item->{song}, $item->{image_url}, 64, 64);
} else {
$ ret . = sprintf ( "%-15s %s\n" , $ itemkey , $ item - > { song } . ", " . $ itemtext )
}
2017-03-15 04:18:34 +00:00
}
if ( $ me - > { cl } - > { TYPE } eq 'FHEMWEB' ) {
2017-04-26 04:22:04 +00:00
$ ret . = '</div></div>' ;
2017-03-15 04:18:34 +00:00
$ ret =~ s/&/&/g ;
$ ret =~ s/'/'/g ;
$ ret =~ s/\n/<br>/g ;
$ ret = "<pre>$ret</pre>" if ( $ ret =~ m/ / ) ;
$ ret = "<html>$ret</html>" ;
2017-08-25 19:34:27 +00:00
}
2017-03-15 04:18:34 +00:00
2017-04-26 04:22:04 +00:00
asyncOutput ( $ me - > { cl } , $ ret ) ;
2017-03-12 20:27:53 +00:00
} else {
$ action = "sid=$sid" ;
}
IOWrite ( $ hash , $ heosCmd , $ action , $ me ) ;
Log3 $ name , 4 , "HEOSPlayer ($name) - IOWrite: $heosCmd $action IODevHash=$hash->{IODev}" ;
return undef ;
}
2017-02-27 08:39:48 +00:00
}
2017-03-12 20:27:53 +00:00
my $ list = 'channelscount:noArg ls' ;
2017-02-20 05:52:39 +00:00
return "Unknown argument $cmd, choose one of $list" ;
}
2017-01-24 13:29:30 +00:00
sub HEOSPlayer_Set ($$@) {
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
my ( $ hash , $ name , @ aa ) = @ _ ;
my ( $ cmd , @ args ) = @ aa ;
2017-01-26 13:53:29 +00:00
my $ pid = $ hash - > { PID } ;
2017-01-24 13:29:30 +00:00
my $ action ;
my $ heosCmd ;
2017-02-02 08:43:45 +00:00
my $ rvalue ;
2017-02-25 06:42:15 +00:00
my $ favoritcount = 1 ;
my $ qcount = 1 ;
2017-02-27 12:35:51 +00:00
my $ string = "pid=$pid" ;
2017-01-24 13:29:30 +00:00
2017-03-12 20:27:53 +00:00
return undef unless ( ReadingsVal ( $ name , "state" , "off" ) eq "on" ) ;
2017-01-24 13:29:30 +00:00
2017-01-26 13:53:29 +00:00
if ( $ cmd eq 'getPlayerInfo' ) {
2017-03-17 16:52:07 +00:00
return "usage: $cmd" if ( @ args != 0 ) ;
2017-02-27 08:39:48 +00:00
2017-02-02 08:43:45 +00:00
$ heosCmd = $ cmd ;
2017-02-27 08:39:48 +00:00
2017-01-26 20:53:39 +00:00
} elsif ( $ cmd eq 'getPlayState' ) {
2017-03-17 16:52:07 +00:00
return "usage: $cmd" if ( @ args != 0 ) ;
2017-02-27 08:39:48 +00:00
2017-02-02 08:43:45 +00:00
$ heosCmd = $ cmd ;
2017-02-27 08:39:48 +00:00
2017-02-02 08:43:45 +00:00
} elsif ( $ cmd eq 'getPlayMode' ) {
2017-03-17 16:52:07 +00:00
return "usage: $cmd" if ( @ args != 0 ) ;
2017-02-27 08:39:48 +00:00
2017-02-02 08:43:45 +00:00
$ heosCmd = $ cmd ;
2017-02-27 08:39:48 +00:00
2017-01-26 13:53:29 +00:00
} elsif ( $ cmd eq 'getNowPlayingMedia' ) {
2017-03-17 16:52:07 +00:00
return "usage: $cmd" if ( @ args != 0 ) ;
2017-02-27 08:39:48 +00:00
2017-02-02 08:43:45 +00:00
$ heosCmd = $ cmd ;
2017-02-27 08:39:48 +00:00
2017-02-02 08:43:45 +00:00
} elsif ( $ cmd eq 'repeat' ) {
2017-03-17 16:52:07 +00:00
my $ param = "one|all|off" ;
return "usage: $cmd $param" if ( @ args != 1 || ! grep { $ _ =~ /$args[0]/ } split ( /\|/ , $ param ) ) ;
2017-02-27 08:39:48 +00:00
2017-02-02 08:43:45 +00:00
$ heosCmd = 'setPlayMode' ;
2017-02-27 08:39:48 +00:00
$ rvalue = 'on_' . $ args [ 0 ] ;
$ rvalue = 'off' if ( $ rvalue eq 'on_off' ) ;
2017-02-25 06:42:15 +00:00
$ action = "repeat=$rvalue&shuffle=" . ReadingsVal ( $ name , 'shuffle' , 'off' ) ;
2017-02-27 08:39:48 +00:00
2017-02-02 08:43:45 +00:00
} elsif ( $ cmd eq 'shuffle' ) {
2017-03-17 16:52:07 +00:00
my $ param = "on|off" ;
return "usage: $cmd $param" if ( @ args != 1 || ! grep { $ _ =~ /$args[0]/ } split ( /\|/ , $ param ) ) ;
2017-02-27 08:39:48 +00:00
2017-02-02 08:43:45 +00:00
$ heosCmd = 'setPlayMode' ;
2017-02-27 08:39:48 +00:00
$ rvalue = 'on_' . ReadingsVal ( $ name , 'repeat' , 'off' ) ;
$ rvalue = 'off' if ( $ rvalue eq 'on_off' ) ;
2017-02-02 08:43:45 +00:00
$ action = "repeat=$rvalue&shuffle=$args[0]" ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
} elsif ( $ cmd eq 'play' ) {
2017-03-17 16:52:07 +00:00
return "usage: $cmd" if ( @ args != 0 ) ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
$ heosCmd = 'setPlayState' ;
2017-01-27 21:22:30 +00:00
$ action = "state=$cmd" ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
} elsif ( $ cmd eq 'stop' ) {
2017-03-17 16:52:07 +00:00
return "usage: $cmd" if ( @ args != 0 ) ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
$ heosCmd = 'setPlayState' ;
2017-01-27 21:22:30 +00:00
$ action = "state=$cmd" ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
} elsif ( $ cmd eq 'pause' ) {
2017-03-17 16:52:07 +00:00
return "usage: $cmd" if ( @ args != 0 ) ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
$ heosCmd = 'setPlayState' ;
2017-01-27 21:22:30 +00:00
$ action = "state=$cmd" ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
} elsif ( $ cmd eq 'mute' ) {
2017-03-17 16:52:07 +00:00
my $ param = "on|off" ;
return "usage: $cmd $param" if ( @ args != 1 || ! grep { $ _ =~ /$args[0]/ } split ( /\|/ , $ param ) ) ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
$ heosCmd = 'setMute' ;
$ action = "state=$args[0]" ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
} elsif ( $ cmd eq 'volume' ) {
2017-03-17 16:52:07 +00:00
return "usage: $cmd 0-100" if ( @ args != 1 || $ args [ 0 ] !~ /(\d+)/ || $ args [ 0 ] > 100 || $ args [ 0 ] < 0 ) ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
$ heosCmd = 'setVolume' ;
$ action = "level=$args[0]" ;
2017-02-27 08:39:48 +00:00
2017-02-02 08:43:45 +00:00
} elsif ( $ cmd eq 'volumeUp' ) {
2017-03-17 16:52:07 +00:00
return "usage: $cmd 0-10" if ( @ args != 1 || $ args [ 0 ] !~ /(\d+)/ || $ args [ 0 ] > 10 || $ args [ 0 ] < 1 ) ;
2017-02-27 08:39:48 +00:00
2017-02-09 10:43:17 +00:00
$ heosCmd = $ cmd ;
2017-02-02 08:43:45 +00:00
$ action = "step=$args[0]" ;
2017-02-27 08:39:48 +00:00
2017-02-02 08:43:45 +00:00
} elsif ( $ cmd eq 'volumeDown' ) {
2017-03-17 16:52:07 +00:00
return "usage: $cmd 0-10" if ( @ args != 1 || $ args [ 0 ] !~ /(\d+)/ || $ args [ 0 ] > 10 || $ args [ 0 ] < 1 ) ;
2017-02-27 08:39:48 +00:00
2017-02-09 10:43:17 +00:00
$ heosCmd = $ cmd ;
2017-02-02 08:43:45 +00:00
$ action = "step=$args[0]" ;
2017-02-27 08:39:48 +00:00
2017-02-20 05:52:39 +00:00
} elsif ( $ cmd eq 'groupWithMember' ) {
2017-03-17 16:52:07 +00:00
return "usage: $cmd" if ( @ args != 1 ) ;
2017-02-27 08:39:48 +00:00
2017-02-27 13:59:46 +00:00
foreach ( split ( '\,' , $ args [ 0 ] ) ) {
2017-03-15 04:18:34 +00:00
$ string . = ",$defs{$_}->{PID}" if ( defined $ defs { $ _ } ) ;
2017-02-27 13:59:46 +00:00
printf "String: $string\n" ;
}
2017-02-20 05:52:39 +00:00
$ heosCmd = 'createGroup' ;
2017-02-27 08:39:48 +00:00
2017-03-12 20:27:53 +00:00
} elsif ( $ cmd eq 'groupClear' ) {
2017-03-17 16:52:07 +00:00
return "usage: $cmd" if ( @ args != 0 ) ;
2017-02-27 08:39:48 +00:00
2017-02-21 05:50:31 +00:00
$ heosCmd = 'createGroup' ;
2017-02-27 08:39:48 +00:00
2017-02-20 05:52:39 +00:00
} elsif ( $ cmd eq 'next' ) {
2017-03-17 16:52:07 +00:00
return "usage: $cmd" if ( @ args != 0 ) ;
2017-02-27 08:39:48 +00:00
2017-02-25 06:42:15 +00:00
$ heosCmd = 'playNext' ;
2017-02-27 08:39:48 +00:00
2017-02-20 05:52:39 +00:00
} elsif ( $ cmd eq 'prev' ) {
2017-03-17 16:52:07 +00:00
return "usage: $cmd" if ( @ args != 0 ) ;
2017-02-27 08:39:48 +00:00
2017-02-20 05:52:39 +00:00
$ heosCmd = 'playPrev' ;
2017-02-27 08:39:48 +00:00
2017-02-25 06:42:15 +00:00
} elsif ( $ cmd =~ /channel/ ) {
2017-02-27 08:39:48 +00:00
2017-03-12 20:27:53 +00:00
my $ favorit = ReadingsVal ( $ name , "channel" , 1 ) ;
2017-02-27 08:39:48 +00:00
2017-02-25 06:42:15 +00:00
$ favoritcount = scalar ( @ { $ hash - > { IODev } { helper } { favorites } } ) if ( defined $ hash - > { IODev } { helper } { favorites } ) ;
2017-02-20 05:52:39 +00:00
$ heosCmd = 'playPresetStation' ;
2017-02-27 08:39:48 +00:00
2017-02-25 06:42:15 +00:00
if ( $ cmd eq 'channel' ) {
2017-03-15 04:18:34 +00:00
return "usage: channel 1-$favoritcount" if ( @ args != 1 || $ args [ 0 ] !~ /(\d+)/ || $ args [ 0 ] > $ favoritcount || $ args [ 0 ] < 1 ) ;
2017-02-27 08:39:48 +00:00
2017-03-12 20:27:53 +00:00
$ action = "preset=$args[0]" ;
2017-02-27 08:39:48 +00:00
2017-02-25 06:42:15 +00:00
} elsif ( $ cmd eq 'channelUp' ) {
2017-03-12 20:27:53 +00:00
return "usage: $cmd" if ( @ args != 0 ) ;
2017-02-27 08:39:48 +00:00
2017-03-15 04:18:34 +00:00
+ + $ favorit ;
if ( $ favorit > $ favoritcount ) {
if ( AttrVal ( $ name , 'channelring' , 0 ) == 1 ) {
$ favorit = 1 ;
} else {
$ favorit = $ favoritcount ;
}
}
2017-03-12 20:27:53 +00:00
$ action = "preset=" . $ favorit ;
2017-02-27 08:39:48 +00:00
2017-02-25 06:42:15 +00:00
} elsif ( $ cmd eq 'channelDown' ) {
2017-03-12 20:27:53 +00:00
return "usage: $cmd" if ( @ args != 0 ) ;
2017-03-15 04:18:34 +00:00
- - $ favorit ;
if ( $ favorit <= 0 ) {
if ( AttrVal ( $ name , 'channelring' , 0 ) == 1 ) {
$ favorit = $ favoritcount ;
} else {
$ favorit = 1 ;
}
}
2017-03-12 20:27:53 +00:00
$ action = "preset=" . $ favorit ;
2017-02-25 06:42:15 +00:00
}
2017-02-27 08:39:48 +00:00
2017-03-12 20:27:53 +00:00
} elsif ( $ cmd =~ /Queue/ ) {
$ heosCmd = $ cmd ;
2017-03-15 04:18:34 +00:00
if ( $ cmd eq 'playQueueItem' ) {
2017-03-12 20:27:53 +00:00
$ qcount = scalar ( @ { $ hash - > { helper } { queue } } ) if ( defined $ hash - > { helper } { queue } ) ;
2017-03-15 04:18:34 +00:00
return "usage: queue 1-$qcount" if ( @ args != 1 || $ args [ 0 ] !~ /(\d+)/ || $ args [ 0 ] > $ qcount || $ args [ 0 ] < 1 ) ;
2017-03-12 20:27:53 +00:00
$ action = "qid=$args[0]" ;
} elsif ( $ cmd eq 'clearQueue' ) {
#löscht die Warteschlange
return "usage: $cmd" if ( @ args != 0 ) ;
delete $ hash - > { helper } { queue } ;
} elsif ( $ cmd eq 'saveQueue' ) {
#speichert die aktuelle Warteschlange als Playlist ab
return "usage: saveQueue" if ( @ args != 1 ) ;
$ action = "name=$args[0]" ;
}
2017-02-25 06:42:15 +00:00
} elsif ( $ cmd =~ /Playlist/ ) {
2017-02-27 08:39:48 +00:00
2017-03-12 20:27:53 +00:00
my $ mid ;
my $ cid = $ args [ 0 ] ;
2021-02-28 18:51:13 +00:00
my @ path ;
@ path = split ( "," , $ args [ 0 ] ) if ( @ args != 0 && $ args [ 0 ] =~ /,/ ) ;
2017-03-12 20:27:53 +00:00
$ cid = $ path [ 0 ] if ( scalar @ path > 0 ) ;
$ mid = $ path [ 1 ] if ( scalar @ path > 1 ) ;
2017-02-25 06:42:15 +00:00
2017-03-12 20:27:53 +00:00
if ( scalar @ args != 0 ) {
if ( $ cid !~ /^-*[0-9]+$/ ) {
2017-02-27 08:39:48 +00:00
2017-03-12 20:27:53 +00:00
my @ cids = map { $ _ - > { cid } } grep { $ _ - > { name } =~ /\Q$cid\E/i } ( @ { $ hash - > { IODev } { helper } { playlists } } ) ;
return "usage: $cmd name" if ( scalar @ cids <= 0 ) ;
2017-02-27 08:39:48 +00:00
2017-03-12 20:27:53 +00:00
$ cid = $ cids [ 0 ] ;
}
if ( $ cmd eq 'playPlaylist' ) {
$ heosCmd = $ cmd ;
$ action = "sid=1025&cid=$cid&aid=4" ;
} elsif ( $ cmd eq 'playPlaylistItem' ) {
return "usage: playPlaylistItem name,nr" if ( scalar @ path < 2 ) ;
$ heosCmd = 'playPlaylist' ;
$ action = "sid=1025&cid=$cid&mid=$mid&aid=4" ;
2017-02-25 06:42:15 +00:00
} elsif ( $ cmd eq 'deletePlaylist' ) {
2017-02-27 08:39:48 +00:00
2017-02-25 06:42:15 +00:00
$ heosCmd = $ cmd ;
2017-03-12 20:27:53 +00:00
$ action = "cid=$cid" ;
2017-02-25 06:42:15 +00:00
$ string = "sid=1025" ;
}
2017-02-27 08:39:48 +00:00
2017-02-20 05:52:39 +00:00
} else {
2017-03-12 20:27:53 +00:00
2017-02-25 06:42:15 +00:00
my @ playlists = map { $ _ - > { name } } ( @ { $ hash - > { IODev } { helper } { playlists } } ) ;
2017-03-12 20:27:53 +00:00
return "usage: $cmd name|id" . join ( "," , @ playlists ) ;
2017-02-20 05:52:39 +00:00
}
2017-02-27 08:39:48 +00:00
2017-03-12 20:27:53 +00:00
} elsif ( $ cmd eq 'aux' ) {
return "usage: $cmd" if ( @ args != 0 ) ;
2017-02-27 08:39:48 +00:00
2017-03-12 20:27:53 +00:00
my $ auxname = @ { $ hash - > { helper } { aux } } [ 0 ] - > { mid } ;
$ heosCmd = 'playInput' ;
$ action = "input=$auxname" ;
Log3 $ name , 4 , "HEOSPlayer ($name) - set aux to $auxname" ;
readingsSingleUpdate ( $ hash , "input" , $ args [ 0 ] , 1 ) ;
2017-02-27 08:39:48 +00:00
2017-03-12 20:27:53 +00:00
} elsif ( $ cmd eq 'input' ) {
2017-03-15 04:18:34 +00:00
return "usage: $cmd sid[,cid][,mid]" if ( @ args != 1 ) ;
2017-03-12 20:27:53 +00:00
my $ param = shift ( @ args ) ;
2017-04-26 04:22:04 +00:00
my ( $ sid , $ cid , $ mid ) = split /,/ , $ param ;
2017-03-15 04:18:34 +00:00
return "usage: $cmd sid[,cid][,mid]" unless ( defined $ sid || $ sid eq "" ) ;
if ( $ sid eq "1024" ) {
return "usage: $cmd sid,cid[,mid]" unless ( defined ( $ cid ) && defined ( $ mid ) ) ;
#Server abspielen
$ heosCmd = 'playPlaylist' ;
$ action = "sid=$sid&cid=$cid&aid=4" ;
$ action = "sid=$sid&cid=$cid&mid=$mid&aid=4" if ( defined ( $ mid ) ) ;
} elsif ( $ sid eq "1025" ) {
return "usage: $cmd sid,cid[,mid]" unless ( defined ( $ cid ) ) ;
#Playlist abspielen
$ heosCmd = 'playPlaylist' ;
$ action = "sid=$sid&cid=$cid&aid=4" ;
$ action = "sid=$sid&cid=$cid&mid=$mid&aid=4" if ( defined ( $ mid ) ) ;
} elsif ( $ sid eq "1026" ) {
return "usage: $cmd sid,cid,mid" unless ( defined ( $ cid ) ) ;
#Verlauf abspielen
if ( $ cid eq "TRACKS" ) {
2017-03-12 20:27:53 +00:00
$ heosCmd = 'playPlaylist' ;
$ action = "sid=$sid&cid=$cid&aid=4" ;
$ action = "sid=$sid&cid=$cid&mid=$mid&aid=4" if ( defined ( $ mid ) ) ;
2017-02-25 06:42:15 +00:00
2017-03-15 04:18:34 +00:00
} elsif ( $ cid eq "STATIONS" ) {
2017-03-12 20:27:53 +00:00
2017-03-15 04:18:34 +00:00
$ heosCmd = 'playStream' ;
$ action = "sid=$sid&cid=$cid&mid=$mid" ;
}
2017-03-12 20:27:53 +00:00
2017-03-15 04:18:34 +00:00
} elsif ( $ sid eq "1027" ) {
return "usage: $cmd sid,spid,mid" unless ( defined ( $ cid ) ) ;
#Eingang abspielen
$ heosCmd = 'playInput' ;
$ action = "input=$mid" ;
$ action = "spid=$cid&" . $ action if ( $ pid ne $ cid ) ;
} elsif ( $ sid eq "1028" ) {
return "usage: $cmd sid,nr" unless ( defined ( $ cid ) ) ;
#Favoriten abspielen
$ heosCmd = 'playPresetStation' ;
$ action = "preset=$cid" ;
} elsif ( $ sid eq "1029" ) {
return "usage: $cmd sid,qid" unless ( defined ( $ cid ) ) ;
#Warteschlange abspielen
2017-04-26 04:22:04 +00:00
$ heosCmd = 'playQueueItem' ;
2017-03-15 04:18:34 +00:00
$ action = "qid=$cid" ;
2017-12-13 09:04:13 +00:00
} elsif ( $ sid eq "url" ) {
#URL abspielen
$ heosCmd = 'playStream' ;
#$action = "url=".substr($param,4);
$ action = "url=$cid" ;
#getestet mit "set HEOSPlayer_Name input url,http://sender.eldoradio.de:8000/128.mp3" ich wollte [cid] nicht nutzen da in einer url ja durchaus mehrere Kommata vorkommen können ob das mit dem substr() so toll ich kann ich leider nicht beurteilen. Auch würde ich bei der $sid ein lc($sid) drum machen aber da es nirgendwo ist :-)
2017-03-15 04:18:34 +00:00
} else {
if ( $ sid > 0 && $ sid < 1024 ) {
return "usage: $cmd sid,cid,mid" unless ( defined ( $ cid ) && defined ( $ mid ) ) ;
#Radio abspielen
$ heosCmd = 'playStream' ;
$ action = "sid=$sid&cid=$cid&mid=$mid" ;
2017-03-12 20:27:53 +00:00
} else {
2017-03-15 04:18:34 +00:00
return "usage: $cmd sid,cid[,mid]" unless ( defined ( $ cid ) ) ;
#Server abspielen
$ heosCmd = 'playPlaylist' ;
$ action = "sid=$sid&cid=$cid&aid=4" ;
$ action = "sid=$sid&cid=$cid&mid=$mid&aid=4" if ( defined ( $ mid ) ) ;
2017-02-20 05:52:39 +00:00
}
}
2017-03-15 04:18:34 +00:00
2017-01-24 13:29:30 +00:00
} else {
2017-05-09 10:23:49 +00:00
#### alte get Befehle sollen raus
#### getPlayerInfo:noArg getPlayState:noArg getNowPlayingMedia:noArg getPlayMode:noArg
my $ list = "play:noArg stop:noArg pause:noArg mute:on,off volume:slider,0,5,100 volumeUp:slider,0,1,10 volumeDown:slider,0,1,10 repeat:one,all,off shuffle:on,off next:noArg prev:noArg input" ;
2017-03-12 20:27:53 +00:00
my @ players = devspec2array ( "TYPE=HEOSPlayer:FILTER=NAME!=$name" ) ;
$ list . = " groupWithMember:multiple-strict," . join ( "," , @ players ) if ( scalar @ players > 0 ) ;
$ list . = " groupClear:noArg" if ( defined ( $ defs { "HEOSGroup" . abs ( $ pid ) } ) && $ defs { "HEOSGroup" . abs ( $ pid ) } - > { STATE } eq "on" ) ;
2017-02-25 06:42:15 +00:00
2017-02-20 05:52:39 +00:00
#Parameterlisten für FHEMWeb zusammen bauen
2017-03-12 20:27:53 +00:00
my $ favoritcount = scalar ( @ { $ hash - > { IODev } { helper } { favorites } } ) if ( defined $ hash - > { IODev } { helper } { favorites } ) ;
if ( defined $ favoritcount && $ favoritcount > 0 ) {
$ list . = " channel:slider,1,1," . scalar ( @ { $ hash - > { IODev } { helper } { favorites } } ) ;
$ list . = " channelUp:noArg channelDown:noArg" if ( $ favoritcount > 1 )
}
if ( defined ( $ hash - > { helper } { queue } ) && ref ( $ hash - > { helper } { queue } ) eq "ARRAY" && scalar ( @ { $ hash - > { helper } { queue } } ) > 0 ) {
2017-02-27 08:39:48 +00:00
2017-03-15 04:18:34 +00:00
$ list . = " playQueueItem:slider,1,1," . scalar ( @ { $ hash - > { helper } { queue } } ) if ( defined $ hash - > { helper } { queue } ) ;
2017-03-12 20:27:53 +00:00
$ list . = " clearQueue:noArg saveQueue" ;
}
2017-02-20 05:52:39 +00:00
if ( defined $ hash - > { IODev } { helper } { playlists } ) {
2017-02-27 08:39:48 +00:00
2017-03-12 20:27:53 +00:00
my @ playlists = map { my % n ; $ n { name } = $ _ - > { name } ; $ n { name } =~ s/\s+/\ /g ; $ n { name } } ( @ { $ hash - > { IODev } { helper } { playlists } } ) ;
2017-03-15 04:18:34 +00:00
2017-02-25 06:42:15 +00:00
$ list . = " playPlaylist:" . join ( "," , @ playlists ) if ( scalar @ playlists > 0 ) ;
$ list . = " deletePlaylist:" . join ( "," , @ playlists ) if ( scalar @ playlists > 0 ) ;
2017-02-20 05:52:39 +00:00
}
2017-08-22 10:13:40 +00:00
2017-03-12 20:27:53 +00:00
$ list . = " aux:noArg" if ( exists $ hash - > { helper } { aux } ) ;
2017-01-24 13:29:30 +00:00
return "Unknown argument $cmd, choose one of $list" ;
}
2017-02-27 12:35:51 +00:00
2017-01-26 13:53:29 +00:00
$ string . = "&$action" if ( defined ( $ action ) ) ;
2017-03-12 20:27:53 +00:00
IOWrite ( $ hash , "$heosCmd" , "$string" , undef ) ;
2017-02-02 08:43:45 +00:00
Log3 $ name , 4 , "HEOSPlayer ($name) - IOWrite: $heosCmd $string IODevHash=$hash->{IODev}" ;
2017-01-24 13:29:30 +00:00
return undef ;
}
sub HEOSPlayer_Parse ($$) {
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
my ( $ io_hash , $ json ) = @ _ ;
my $ name = $ io_hash - > { NAME } ;
my $ pid ;
my $ decode_json ;
2017-02-27 08:39:48 +00:00
my $ code ;
2017-01-24 13:29:30 +00:00
2018-02-28 09:08:41 +00:00
$ decode_json = eval { decode_json ( encode_utf8 ( $ json ) ) } ;
if ( $@ ) {
Log3 $ name , 3 , "HEOSPlayer ($name) - JSON error while request: $@" ;
return ;
}
2017-02-27 08:39:48 +00:00
2017-02-25 06:42:15 +00:00
Log3 $ name , 4 , "HEOSPlayer - ParseFn wurde aufgerufen" ;
2017-01-24 13:29:30 +00:00
if ( defined ( $ decode_json - > { pid } ) ) {
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
$ pid = $ decode_json - > { pid } ;
2017-02-25 06:42:15 +00:00
$ code = abs ( $ pid ) ;
2017-01-24 13:29:30 +00:00
$ code = $ io_hash - > { NAME } . "-" . $ code if ( defined ( $ io_hash - > { NAME } ) ) ;
2017-02-27 08:39:48 +00:00
if ( my $ hash = $ modules { HEOSPlayer } { defptr } { $ code } ) {
2017-03-12 20:27:53 +00:00
IOWrite ( $ hash , 'getPlayerInfo' , "pid=$hash->{PID}" , undef ) ;
2017-04-26 04:22:04 +00:00
readingsSingleUpdate ( $ hash , "state" , "on" , 1 ) ;
2017-02-25 06:42:15 +00:00
Log3 $ hash - > { NAME } , 4 , "HEOSPlayer ($hash->{NAME}) - find logical device: $hash->{NAME}" ;
Log3 $ hash - > { NAME } , 4 , "HEOSPlayer ($hash->{NAME}) - find PID in root from decode_json" ;
2017-01-24 13:29:30 +00:00
return $ hash - > { NAME } ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
} else {
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
my $ devname = "HEOSPlayer" . abs ( $ pid ) ;
return "UNDEFINED $devname HEOSPlayer $pid IODev=$name" ;
}
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
} else {
2017-02-27 08:39:48 +00:00
my % message = map { my ( $ key , $ value ) = split "=" ; $ key = > $ value } split ( '&' , $ decode_json - > { heos } { message } ) ;
$ pid = $ message { pid } if ( defined ( $ message { pid } ) ) ;
2017-03-12 20:27:53 +00:00
$ pid = $ decode_json - > { payload } { pid } if ( ref ( $ decode_json - > { payload } ) ne "ARRAY" && defined ( $ decode_json - > { payload } { pid } ) ) ;
2017-02-27 08:39:48 +00:00
Log3 $ name , 4 , "HEOSPlayer ($name) PID: $pid" ;
2017-02-27 12:12:32 +00:00
2017-02-25 06:42:15 +00:00
$ code = abs ( $ pid ) ;
2017-01-24 13:29:30 +00:00
$ code = $ io_hash - > { NAME } . "-" . $ code if ( defined ( $ io_hash - > { NAME } ) ) ;
2017-02-27 08:39:48 +00:00
2017-03-12 20:27:53 +00:00
if ( my $ hash = $ modules { HEOSPlayer } { defptr } { $ code } ) {
2017-01-24 13:29:30 +00:00
my $ name = $ hash - > { NAME } ;
2017-03-12 20:27:53 +00:00
HEOSPlayer_WriteReadings ( $ hash , $ decode_json ) ;
Log3 $ name , 4 , "HEOSPlayer ($name) - find logical device: $hash->{NAME}" ;
2017-01-24 13:29:30 +00:00
return $ hash - > { NAME } ;
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
} else {
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
my $ devname = "HEOSPlayer" . abs ( $ pid ) ;
return "UNDEFINED $devname HEOSPlayer $pid IODev=$name" ;
}
}
}
sub HEOSPlayer_WriteReadings ($$) {
2017-02-27 08:39:48 +00:00
2017-01-24 13:29:30 +00:00
my ( $ hash , $ decode_json ) = @ _ ;
my $ name = $ hash - > { NAME } ;
2017-02-25 06:42:15 +00:00
2017-02-27 08:39:48 +00:00
2017-03-15 04:18:34 +00:00
Log3 $ name , 4 , "HEOSPlayer ($name) - processing data to write readings" ;
2017-01-24 13:29:30 +00:00
############################
2017-01-26 13:53:29 +00:00
#### Aufbereiten der Daten soweit nötig (bei Events zum Beispiel)
2017-01-27 21:22:30 +00:00
my $ readingsHash = HEOSPlayer_PreProcessingReadings ( $ hash , $ decode_json )
2017-02-25 06:42:15 +00:00
if ( $ decode_json - > { heos } { message } =~ /^pid=/ and $ decode_json - > { heos } { command } ne "player\/get_now_playing_media" ) ;
2017-01-26 13:53:29 +00:00
############################
#### schreiben der Readings
readingsBeginUpdate ( $ hash ) ;
2017-01-26 20:53:39 +00:00
### Event Readings
2017-01-28 16:06:00 +00:00
if ( ref ( $ readingsHash ) eq "HASH" ) {
2017-02-27 08:39:48 +00:00
2017-01-27 21:22:30 +00:00
Log3 $ name , 4 , "HEOSPlayer ($name) - response json Hash back from HEOSPlayer_PreProcessingReadings" ;
2017-01-26 20:53:39 +00:00
my $ t ;
my $ v ;
2017-02-27 08:39:48 +00:00
2017-02-09 10:43:17 +00:00
while ( ( $ t , $ v ) = each ( % { $ readingsHash } ) ) {
2017-02-25 06:42:15 +00:00
readingsBulkUpdate ( $ hash , $ t , $ v ) if ( defined ( $ v ) ) ;
2017-01-26 20:53:39 +00:00
}
}
2017-02-25 06:42:15 +00:00
2017-01-26 13:53:29 +00:00
### PlayerInfos
2017-01-24 13:29:30 +00:00
readingsBulkUpdate ( $ hash , 'name' , $ decode_json - > { payload } { name } ) ;
readingsBulkUpdate ( $ hash , 'gid' , $ decode_json - > { payload } { gid } ) ;
readingsBulkUpdate ( $ hash , 'model' , $ decode_json - > { payload } { model } ) ;
readingsBulkUpdate ( $ hash , 'version' , $ decode_json - > { payload } { version } ) ;
readingsBulkUpdate ( $ hash , 'network' , $ decode_json - > { payload } { network } ) ;
readingsBulkUpdate ( $ hash , 'lineout' , $ decode_json - > { payload } { lineout } ) ;
readingsBulkUpdate ( $ hash , 'control' , $ decode_json - > { payload } { control } ) ;
readingsBulkUpdate ( $ hash , 'ip-address' , $ decode_json - > { payload } { ip } ) ;
2017-02-25 06:42:15 +00:00
2017-01-26 13:53:29 +00:00
### playing Infos
2017-01-27 21:22:30 +00:00
readingsBulkUpdate ( $ hash , 'currentMedia' , $ decode_json - > { payload } { type } ) ;
readingsBulkUpdate ( $ hash , 'currentTitle' , $ decode_json - > { payload } { song } ) ;
readingsBulkUpdate ( $ hash , 'currentAlbum' , $ decode_json - > { payload } { album } ) ;
readingsBulkUpdate ( $ hash , 'currentArtist' , $ decode_json - > { payload } { artist } ) ;
readingsBulkUpdate ( $ hash , 'currentImageUrl' , $ decode_json - > { payload } { image_url } ) ;
readingsBulkUpdate ( $ hash , 'currentMid' , $ decode_json - > { payload } { mid } ) ;
readingsBulkUpdate ( $ hash , 'currentQid' , $ decode_json - > { payload } { qid } ) ;
readingsBulkUpdate ( $ hash , 'currentSid' , $ decode_json - > { payload } { sid } ) ;
readingsBulkUpdate ( $ hash , 'currentStation' , $ decode_json - > { payload } { station } ) ;
2017-02-25 06:42:15 +00:00
2017-02-20 05:52:39 +00:00
#sucht in den Favoriten nach der aktuell gespielten Radiostation und aktualisiert den channel wenn diese enthalten ist
my @ presets = map { $ _ - > { name } } ( @ { $ hash - > { IODev } { helper } { favorites } } ) ;
my $ search = ReadingsVal ( $ name , "currentStation" , undef ) ;
my ( @ index ) = grep { $ presets [ $ _ ] eq $ search } 0 .. $# presets if ( defined $ search ) ;
2017-02-27 08:39:48 +00:00
2017-02-20 05:52:39 +00:00
readingsBulkUpdate ( $ hash , 'channel' , $ index [ 0 ] + 1 ) if ( scalar @ index > 0 ) ;
2017-01-26 13:53:29 +00:00
readingsEndUpdate ( $ hash , 1 ) ;
Log3 $ name , 5 , "HEOSPlayer ($name) - readings set for $name" ;
2017-01-24 13:29:30 +00:00
return undef ;
}
2017-01-27 21:22:30 +00:00
2017-01-26 13:53:29 +00:00
###############
2017-01-27 21:22:30 +00:00
### my little Helpers
2017-01-26 13:53:29 +00:00
sub HEOSPlayer_PreProcessingReadings ($$) {
2017-02-27 08:39:48 +00:00
2017-01-26 13:53:29 +00:00
my ( $ hash , $ decode_json ) = @ _ ;
my $ name = $ hash - > { NAME } ;
my $ reading ;
2017-01-27 21:22:30 +00:00
my % buffer ;
2017-02-27 08:39:48 +00:00
my % message = map { my ( $ key , $ value ) = split "=" ; $ key = > $ value } split ( '&' , $ decode_json - > { heos } { message } ) ;
Log3 $ name , 4 , "HEOSPlayer ($name) - preprocessing readings" ;
if ( $ decode_json - > { heos } { command } =~ /play_state/ or $ decode_json - > { heos } { command } =~ /player_state_changed/ ) {
$ buffer { 'playStatus' } = $ message { state } ;
2017-01-26 13:53:29 +00:00
2017-02-09 10:43:17 +00:00
} elsif ( $ decode_json - > { heos } { command } =~ /volume_changed/ or $ decode_json - > { heos } { command } =~ /set_volume/ or $ decode_json - > { heos } { command } =~ /get_volume/ ) {
2017-02-25 06:42:15 +00:00
2017-01-27 21:22:30 +00:00
my @ value = split ( '&' , $ decode_json - > { heos } { message } ) ;
2017-02-25 06:42:15 +00:00
$ buffer { 'volume' } = $ message { level } ;
$ buffer { 'mute' } = $ message { mute } if ( $ decode_json - > { heos } { command } =~ /volume_changed/ ) ;
2017-02-09 10:43:17 +00:00
if ( defined ( $ buffer { 'mute' } ) && AttrVal ( $ name , 'mute2play' , 0 ) == 1 ) {
2017-03-12 20:27:53 +00:00
IOWrite ( $ hash , 'setPlayState' , "pid=$hash->{PID}&state=play" , undef ) if $ buffer { 'mute' } eq "off" ;
IOWrite ( $ hash , 'setPlayState' , "pid=$hash->{PID}&state=stop" , undef ) if $ buffer { 'mute' } eq "on" ;
2017-02-02 08:43:45 +00:00
}
2017-02-27 08:39:48 +00:00
2017-02-25 06:42:15 +00:00
} elsif ( $ decode_json - > { heos } { command } =~ /play_mode/ or $ decode_json - > { heos } { command } =~ /repeat_mode_changed/ or $ decode_json - > { heos } { command } =~ /shuffle_mode_changed/ ) {
2017-02-27 08:39:48 +00:00
$ buffer { 'shuffle' } = $ message { shuffle } ;
2017-02-25 06:42:15 +00:00
$ buffer { 'repeat' } = $ message { repeat } ;
2018-03-08 09:41:46 +00:00
$ buffer { 'repeat' } =~ s/.*\_(.*)/$1/g if ( defined ( $ buffer { 'repeat' } ) ) ;
2017-02-27 08:39:48 +00:00
2017-02-21 05:50:31 +00:00
} elsif ( $ decode_json - > { heos } { command } =~ /get_mute/ ) {
2017-02-27 08:39:48 +00:00
2017-02-25 06:42:15 +00:00
$ buffer { 'mute' } = $ message { state } ;
2017-02-27 08:39:48 +00:00
2017-02-02 08:43:45 +00:00
} elsif ( $ decode_json - > { heos } { command } =~ /volume_up/ or $ decode_json - > { heos } { command } =~ /volume_down/ ) {
2017-02-27 08:39:48 +00:00
2017-02-25 06:42:15 +00:00
$ buffer { 'volumeUp' } = $ message { step } if ( $ decode_json - > { heos } { command } =~ /volume_up/ ) ;
2017-03-12 20:27:53 +00:00
$ buffer { 'volumeDown' } = $ message { step } if ( $ decode_json - > { heos } { command } =~ /volume_down/ ) ;
2017-02-27 08:39:48 +00:00
2017-02-20 05:52:39 +00:00
} elsif ( $ decode_json - > { heos } { command } =~ /player_now_playing_changed/ or $ decode_json - > { heos } { command } =~ /favorites_changed/ ) {
2017-03-12 20:27:53 +00:00
IOWrite ( $ hash , 'getNowPlayingMedia' , "pid=$hash->{PID}" , undef ) ;
2017-02-27 08:39:48 +00:00
2017-02-20 05:52:39 +00:00
} elsif ( $ decode_json - > { heos } { command } =~ /play_preset/ ) {
2017-02-27 08:39:48 +00:00
$ buffer { 'channel' } = $ message { preset }
2017-02-20 05:52:39 +00:00
} elsif ( $ decode_json - > { heos } { command } =~ /play_input/ ) {
2017-02-27 08:39:48 +00:00
$ buffer { 'input' } = $ message { input } ;
2017-02-22 09:19:23 +00:00
} elsif ( $ decode_json - > { heos } { command } =~ /playback_error/ ) {
2017-02-27 08:39:48 +00:00
$ buffer { 'error' } = $ message { error } ;
2017-01-26 13:53:29 +00:00
} else {
2017-02-27 08:39:48 +00:00
2017-03-15 04:18:34 +00:00
Log3 $ name , 4 , "HEOSPlayer ($name) - no match found" ;
2017-02-02 08:43:45 +00:00
return undef ;
2017-01-26 13:53:29 +00:00
}
2017-02-27 08:39:48 +00:00
2017-01-27 21:22:30 +00:00
Log3 $ name , 4 , "HEOSPlayer ($name) - Match found for decode_json" ;
return \ % buffer ;
}
sub HEOSPlayer_GetPlayerInfo ($) {
2017-02-27 08:39:48 +00:00
2017-01-27 21:22:30 +00:00
my $ hash = shift ;
2017-02-25 06:42:15 +00:00
2017-02-27 08:39:48 +00:00
2017-01-27 21:22:30 +00:00
RemoveInternalTimer ( $ hash , 'HEOSPlayer_GetPlayerInfo' ) ;
2017-03-12 20:27:53 +00:00
IOWrite ( $ hash , 'getPlayerInfo' , "pid=$hash->{PID}" , undef ) ;
2017-01-27 21:22:30 +00:00
}
sub HEOSPlayer_GetPlayState ($) {
2017-02-27 08:39:48 +00:00
2017-01-27 21:22:30 +00:00
my $ hash = shift ;
2017-02-25 06:42:15 +00:00
2017-02-27 08:39:48 +00:00
2017-01-27 21:22:30 +00:00
RemoveInternalTimer ( $ hash , 'HEOSPlayer_GetPlayState' ) ;
2017-03-12 20:27:53 +00:00
IOWrite ( $ hash , 'getPlayState' , "pid=$hash->{PID}" , undef ) ;
2017-01-26 13:53:29 +00:00
}
2017-02-02 08:43:45 +00:00
sub HEOSPlayer_GetPlayMode ($) {
2017-02-27 08:39:48 +00:00
2017-02-02 08:43:45 +00:00
my $ hash = shift ;
2017-02-25 06:42:15 +00:00
2017-02-27 08:39:48 +00:00
2017-02-02 08:43:45 +00:00
RemoveInternalTimer ( $ hash , 'HEOSPlayer_GetPlayMode' ) ;
2017-03-12 20:27:53 +00:00
IOWrite ( $ hash , 'getPlayMode' , "pid=$hash->{PID}" , undef ) ;
2017-02-02 08:43:45 +00:00
}
2017-01-27 21:22:30 +00:00
sub HEOSPlayer_GetNowPlayingMedia ($) {
2017-02-27 08:39:48 +00:00
2017-01-27 21:22:30 +00:00
my $ hash = shift ;
2017-02-25 06:42:15 +00:00
2017-02-27 08:39:48 +00:00
2017-01-27 21:22:30 +00:00
RemoveInternalTimer ( $ hash , 'HEOSPlayer_GetNowPlayingMedia' ) ;
2017-03-12 20:27:53 +00:00
IOWrite ( $ hash , 'getNowPlayingMedia' , "pid=$hash->{PID}" , undef ) ;
2017-01-27 21:22:30 +00:00
}
2017-01-24 13:29:30 +00:00
2017-02-09 10:43:17 +00:00
sub HEOSPlayer_GetVolume ($) {
2017-02-27 08:39:48 +00:00
2017-02-09 10:43:17 +00:00
my $ hash = shift ;
2017-02-25 06:42:15 +00:00
2017-02-27 08:39:48 +00:00
2017-02-09 10:43:17 +00:00
RemoveInternalTimer ( $ hash , 'HEOSPlayer_GetVolume' ) ;
2017-03-12 20:27:53 +00:00
IOWrite ( $ hash , 'getVolume' , "pid=$hash->{PID}" , undef ) ;
2017-02-09 10:43:17 +00:00
}
2017-02-21 05:50:31 +00:00
sub HEOSPlayer_GetMute ($) {
2017-02-27 08:39:48 +00:00
2017-02-21 05:50:31 +00:00
my $ hash = shift ;
2017-02-25 06:42:15 +00:00
2017-02-27 08:39:48 +00:00
2017-02-21 05:50:31 +00:00
RemoveInternalTimer ( $ hash , 'HEOSPlayer_GetMute' ) ;
2017-03-12 20:27:53 +00:00
IOWrite ( $ hash , 'getMute' , "pid=$hash->{PID}" , undef ) ;
2017-02-21 05:50:31 +00:00
}
2017-02-25 06:42:15 +00:00
sub HEOSPlayer_GetQueue ($) {
2017-02-27 08:39:48 +00:00
2017-02-25 06:42:15 +00:00
my $ hash = shift ;
2017-02-27 08:39:48 +00:00
2017-02-25 06:42:15 +00:00
RemoveInternalTimer ( $ hash , 'HEOSPlayer_GetQueue' ) ;
2017-03-12 20:27:53 +00:00
IOWrite ( $ hash , 'getQueue' , "pid=$hash->{PID}" , undef ) ;
2017-02-25 06:42:15 +00:00
}
2017-01-24 13:29:30 +00:00
2017-04-26 04:22:04 +00:00
sub HEOSPlayer_MakePlayLink ($$$$$$$$) {
2017-01-24 13:29:30 +00:00
2017-04-26 04:22:04 +00:00
my ( $ type , $ name , $ sid , $ itemtype , $ itemname , $ itemurl , $ xsize , $ ysize ) = @ _ ;
if ( $ type eq 'FHEMWEB' ) {
2017-01-24 13:29:30 +00:00
2017-04-26 04:22:04 +00:00
my $ xcmd = 'cmd' . uri_escape ( '=get ' . $ name . ' ls ' . $ sid ) ;
my $ xtext = $ sid ;
$ xcmd = 'cmd' . uri_escape ( '=set ' . $ name . ' input ' . $ sid ) if ( $ itemtype eq "heos_queue" ) ;
$ ysize = '10.75em' if ( ! defined ( $ ysize ) ) ;
$ xcmd = "FW_cmd('$FW_ME$FW_subdir?XHR=1&$xcmd')" ;
return '<a onClick="' . $ xcmd . '" class="list-group-item active" style="display: flex;align-items: center;cursor:pointer;"><img style="width: ' . $ xsize . 'px; height: ' . $ ysize . 'px;" src="' . $ itemurl . '"><h5 class="list-group-item-heading" style="padding: 10px;">' . $ itemname . "</h5></a>" ;
2017-01-24 13:29:30 +00:00
2017-04-26 04:22:04 +00:00
} else {
return sprintf ( "%-15s %s\n" , $ sid , $ itemname ) ;
2017-03-15 04:18:34 +00:00
2017-04-26 04:22:04 +00:00
}
2017-03-15 04:18:34 +00:00
}
sub HEOSPlayer_makeImage ($$) {
my ( $ url , $ xsize , $ ysize ) = @ _ ;
my $ ret . = "<img src=\"$url\" width=\"$xsize\" height=\"$ysize\" style=\"float:left;\">\n" ;
return $ ret ;
2017-03-12 20:27:53 +00:00
}
2017-01-24 13:29:30 +00:00
2017-02-20 05:52:39 +00:00
2017-04-26 04:38:01 +00:00
1 ;
2017-03-15 04:18:34 +00:00
2017-04-26 04:38:01 +00:00
= pod
= item device
= item summary Modul to controls the Denon multiroom soundsystem
= item summary_DE Modul zum steuern des Denon Multiroom - Soundsystem
= begin html
< a name = "HEOSPlayer" > </a>
<h3> HEOSPlayer </h3>
<ul>
<u> <b> HEOSPlayer </b> </u>
<br> <br>
In combination with HEOSMaster and HEOSGroup this FHEM Module controls the Denon multiroom soundsystem using a telnet socket connection and the HEOS Command Line Interface ( CLI ) .
<br> <br>
Once the master device is created , the players and groups of Your system are automatically recognized and created in FHEM . From now on the players and groups can be controlled and changes in the HEOS app or at the Receiver are synchronized with the state and media readings of the players and groups .
< a name = "HEOSPlayerreadings" > </a>
<br> <br>
<b> Readings </b>
<ul>
<li> channel - nr of now playing favorite </li>
<li> currentAlbum - name of now playing album </li>
<li> currentArtist - name of now playing artist </li>
<li> currentImageUrl - URL of cover art , station logo , etc . </li>
<li> currentMedia - type of now playing media ( song | station | genre | artist | album | container ) </li>
<li> currentMid - media ID </li>
<li> currentQid - queue ID </li>
<li> currentSid - source ID </li>
<li> currentStation - name of now playing station </li>
<li> currentTitle - name of now playing title </li>
2017-05-09 10:23:49 +00:00
<li> error - last error </li>
<li> gid - ID of group , in which player is member </li>
2017-04-26 04:38:01 +00:00
<li> ip - address - ip address of the player </li>
<li> lineout - lineout level type ( variable | Fixed ) </li>
<li> model - model of HEOS speaker ( e . g . HEOS 1 ) </li>
<li> mute - player mute state ( on | off ) </li>
<li> name - name of player ( received from app ) </li>
<li> network - network connection type ( wired | wifi ) </li>
<li> playStatus - state of player ( play | pause | stop ) </li>
<li> repeat - player repeat state ( on_all | on_one | off ) </li>
<li> shuffle - player shuffle state ( on | off ) </li>
<li> state - state of player connection ( on | off ) </li>
<li> version - software version of HEOS speaker </li>
<li> volume - player volume level ( 0 - 100 ) </li>
<li> volumeDown - player volume step level ( 1 - 10 , default 5 ) </li>
<li> volumeUp - player volume step level ( 1 - 10 , default 5 ) </li>
</ul>
<br> <br>
< a name = "HEOSPlayerset" > </a>
<b> set </b>
<ul>
<li> aux - uses source at aux - input of player </li>
<li> channel & ltnr & gt - plays favorite & ltnr & gt created with app </li>
<li> channelUp - switches to next favorite </li>
<li> channelDown - switches to previous favorite </li>
<li> clear queue - clears the queue </li>
<li> deletePlaylist & ltmyList & gt - clears playlist & ltmyList & gt </li>
<li> set & lthp1 & gt groupWithMember & lthp2 & gt - creates group with hp1 as leader and hp2 as member </li>
<li> input sid [ , cid ] [ , mid ] - set input source - id [ , container - id ] [ , media - id ] </li>
2017-05-09 10:23:49 +00:00
<ul>
<code> Example: set kitchen input 1027 , 1772574848 , inputs / tvaudio <br>
starts "tv audio" on player "kitchen" </code>
</ul>
2017-04-26 04:38:01 +00:00
<li> mute on | off - set mute state on | off </li>
<li> next - play next title in queue </li>
<li> pause - set state of player to "pause" </li>
<li> play - set state of player to "play" </li>
<li> playPlaylist & ltmyList & gt - play playlist & ltmyList & gt </li>
<li> playQueueItem & ltnr & gt - play title & ltnr & gt in queue </li>
<li> prev - play previous title in queue </li>
<li> repeat - set player repeat state ( on_all | on_one | off ) </li>
<li> saveQueue & ltmyList & gt - save queue as & ltmyList & gt </li>
<li> shuffle - set player shuffle state on | off </li>
<li> stop - set state of player to "stop" </li>
<li> volume - set volume 0 .. 100 </li>
<li> volumeDown - reduce volume by & ltvolumeDown & gt </li>
<li> volumeUp - increase volume by & ltvolumeUp & gt </li>
</ul>
<br> <br>
< a name = "HEOSPlayerget" > </a>
<b> get </b>
<ul>
<li> ls - list music sources ( input , playlists , favorites , music services , ... ) </li>
<li> channelscount - number of favorites </li>
</ul>
<br> <br>
< a name = "HEOSPlayerstate" > </a>
<b> state </b>
<ul>
<li> state of player connection ( on | off ) </li>
</ul>
<br> <br>
< a name = "HEOSPlayerattributes" > </a>
<b> attributes </b>
<ul>
<li> channelring - when reaching the last favorite ChannelUp /Down switches in circle, i.e. to the first/ last favorite again </li>
2017-05-09 10:23:49 +00:00
<li> mute2play - if mute switch on speaker is pressed , the stream stops </li>
2017-04-26 04:38:01 +00:00
</ul>
</ul>
= end html
= begin html_DE
< a name = "HEOSPlayer" > </a>
<h3> HEOSPlayer </h3>
<ul>
<u> <b> HEOSPlayer </b> </u>
<br> <br>
In Kombination mit HEOSMaster and HEOSGroup steuert dieses FHEM Modul das Denon Multiroom - Soundsystem mit Hilfe einer telnet Socket - Verbindung und dem HEOS Command Line Interface ( CLI ) .
<br> <br>
Nachdem der Master einmal angelegt ist werden die Player und Gruppierungen des Systems automatisch erkannt und in FHEM angelegt . Von da an k & oumlnnen die Player und Gruppierungen gesteuert werden und Ver & aumlnderungen in der HEOS App oder am Reveiver werden mit dem Status und den Media Readings der Player und Gruppierungen synchronisiert .
< a name = "HEOSPlayerreadings" > </a>
<br> <br>
<b> Readings </b>
<ul>
<li> channel - Nr des gerade abgespielten Favoriten </li>
<li> currentAlbum - Name des gerade abgespielten Albums </li>
<li> currentArtist - Name des gerade abgespielten K & uumlnstlers </li>
<li> currentImageUrl - URL des Albumcovers , Senderlogos , etc . </li>
<li> currentMedia - Medientyp des gerade abgespielten Streams ( song | station | genre | artist | album | container ) </li>
<li> currentMid - media ID </li>
<li> currentQid - queue ID </li>
<li> currentSid - source ID </li>
<li> currentStation - Name des gerade abgespielten Senders </li>
<li> currentTitle - Name des gerade abgespielten Titels </li>
2017-05-09 10:23:49 +00:00
<li> error - letzte Fehlermeldung </li>
<li> gid - ID der Gruppe , in der der Player Mitglied ist </li>
2017-04-26 04:38:01 +00:00
<li> ip - address - IP - Adresse des Players </li>
<li> lineout - lineout level type ( variable | Fixed ) </li>
<li> model - Modell des HEOS Lautsprechers ( z . B . HEOS 1 ) </li>
<li> mute - Player mute Status ( on | off ) </li>
<li> name - Name des Players ( aus der App & uumlbernommen ) </li>
<li> network - Netzwerkverbindung ( wired | wifi ) </li>
<li> playStatus - Status des Players ( play | pause | stop ) </li>
<li> repeat - Player Repeat Status ( on_all | on_one | off ) </li>
<li> shuffle - Player Shuffle Status ( on | off ) </li>
<li> state - Status der Player - Verbindung ( on | off ) </li>
<li> version - Softwareversion des HEOS Lautsprechers </li>
<li> volume - aktuelle Lautst & aumlrke ( 0 - 100 ) </li>
<li> volumeDown - Schrittweite Lautst & aumlrke ( 1 - 10 , default 5 ) </li>
<li> volumeUp - Schrittweite Lautst & aumlrke ( 1 - 10 , default 5 ) </li>
</ul>
<br> <br>
< a name = "HEOSPlayerset" > </a>
<b> set </b>
<ul>
<li> aux - aktiviert die Quelle am AUX - Eingang des Players </li>
<li> channel & ltnr & gt - spielt den vorher mit der App erstellten Favoriten & ltnr & gt ab </li>
<li> channelUp - schaltet auf den n & aumlchsten Favoriten in der Favoritenliste um </li>
<li> channelDown - schaltet auf vorherigen Favoriten in der Favoritenliste um </li>
<li> clear queue - l & oumlscht die Warteschlange </li>
<li> deletePlaylist & ltmyList & gt - l & oumlscht die Playlist & ltmyList & gt </li>
<li> set & lthp1 & gt groupWithMember & lthp2 & gt - erzeugt eine Gruppierung mit hp1 als Leader und hp2 als Mitglied </li>
<li> input sid [ , cid ] [ , mid ] - setze input source - id [ , container - id ] [ , media - id ] </li>
2017-05-09 10:23:49 +00:00
<ul>
<code> Beispiel: set K & uumlche input 1027 , 1772574848 , inputs / tvaudio <br>
startet "TV-Audio" auf dem Player "Küche" </code>
</ul>
2017-04-26 04:38:01 +00:00
<li> mute on | off - setzt den mute Status on | off </li>
<li> next - spielt n & aumlchsten Titel in Warteschlange </li>
<li> pause - setzt den Status des Players auf "pause" </li>
<li> play - setzt den Status des Players auf "play" </li>
<li> playPlaylist & ltmyList & gt - spielt die Playlist & ltmyList & gt ab </li>
<li> playQueueItem & ltnr & gt - spielt Titel & ltnr & gt in Warteschlange </li>
<li> prev - spielt vorherigen Titel in Warteschlange </li>
<li> repeat - setzt den Player Repeat Status ( on_all | on_one | off ) </li>
<li> saveQueue & ltmyList & gt - speichert die Warteschlange als Playlist & ltmyList & gt </li>
<li> shuffle - setzt den Player Shuffle Status auf on | off </li>
<li> stop - setzt den Status des Players auf "stop" </li>
<li> volume - setzt die Lautst & aumlrke auf 0 .. 100 </li>
<li> volumeDown - verringert die Lautst & aumlrke um & ltvolumeDown & gt </li>
<li> volumeUp - erh & oumlht die Lautst & aumlrke um & ltvolumeUp & gt </li>
</ul>
<br> <br>
< a name = "HEOSPlayerget" > </a>
<b> get </b>
<ul>
2017-05-09 10:23:49 +00:00
<li> ls - listet Musikquellen ( Eing & aumlnge , Playlists , Favoriten , Musik - Dienste , ... ) </li>
2017-04-26 04:38:01 +00:00
<li> channelscount - Anzahl der Favoriten </li>
</ul>
<br> <br>
< a name = "HEOSPlayerstate" > </a>
<b> state </b>
<ul>
<li> Status der Player - Verbindung ( on | off ) </li>
</ul>
<br> <br>
< a name = "HEOSPlayerattributes" > </a>
<b> attributes </b>
<ul>
<li> channelring - Beim Erreichen des letzten Favoriten schaltet ChannelUp /Down im Kreis, also wieder auf den ersten/ letzten Favoriten </li>
<li> mute2play - Beim Bet & aumltigen der Mute - Taste am Lautsprecher wird auch der Stream angehalten </li>
</ul>
</ul>
2017-05-09 10:23:49 +00:00
2017-04-26 04:38:01 +00:00
= end html_DE
= cut