mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
SONOS: Bugfixes and new features, see changelog in file.
git-svn-id: https://svn.fhem.de/fhem/trunk@14650 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
4912e959fb
commit
9f203de0ac
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
########################################################################################
|
########################################################################################
|
||||||
#
|
#
|
||||||
# SONOSPLAYER.pm (c) by Reiner Leins, Juni 2017
|
# SONOSPLAYER.pm (c) by Reiner Leins, July 2017
|
||||||
# rleins at lmsoft dot de
|
# rleins at lmsoft dot de
|
||||||
#
|
#
|
||||||
# $Id$
|
# $Id$
|
||||||
@ -409,7 +409,7 @@ sub SONOSPLAYER_SimulateCurrentTrackPosition() {
|
|||||||
|
|
||||||
readingsBeginUpdate($hash);
|
readingsBeginUpdate($hash);
|
||||||
|
|
||||||
my $trackDurationSec = SONOS_GetTimeSeconds(ReadingsVal($hash->{NAME}, 'currentTrackDuration', 0)) - 1;
|
my $trackDurationSec = SONOS_GetTimeSeconds(ReadingsVal($hash->{NAME}, 'currentTrackDuration', 0));
|
||||||
|
|
||||||
my $trackPositionSec = 0;
|
my $trackPositionSec = 0;
|
||||||
if (ReadingsVal($hash->{NAME}, 'transportState', 'STOPPED') eq 'PLAYING') {
|
if (ReadingsVal($hash->{NAME}, 'transportState', 'STOPPED') eq 'PLAYING') {
|
||||||
@ -500,7 +500,7 @@ sub SONOSPLAYER_Get($@) {
|
|||||||
} elsif (lc($reading) eq 'ethernetportstatus') {
|
} elsif (lc($reading) eq 'ethernetportstatus') {
|
||||||
my $portNum = $a[2];
|
my $portNum = $a[2];
|
||||||
|
|
||||||
readingsSingleUpdate($hash, 'LastActionResult', 'Portstatus properly returned', 1);
|
SONOS_readingsSingleUpdate($hash, 'LastActionResult', 'Portstatus properly returned', 1);
|
||||||
|
|
||||||
my $url = ReadingsVal($name, 'location', '');
|
my $url = ReadingsVal($name, 'location', '');
|
||||||
$url =~ s/(^http:\/\/.*?)\/.*/$1\/status\/enetports/;
|
$url =~ s/(^http:\/\/.*?)\/.*/$1\/status\/enetports/;
|
||||||
@ -516,7 +516,7 @@ sub SONOSPLAYER_Get($@) {
|
|||||||
} elsif (lc($reading) eq 'alarm') {
|
} elsif (lc($reading) eq 'alarm') {
|
||||||
my $id = $a[2];
|
my $id = $a[2];
|
||||||
|
|
||||||
readingsSingleUpdate($hash, 'LastActionResult', 'Alarm-Hash properly returned', 1);
|
SONOS_readingsSingleUpdate($hash, 'LastActionResult', 'Alarm-Hash properly returned', 1);
|
||||||
|
|
||||||
my @idList = split(',', ReadingsVal($name, 'AlarmListIDs', ''));
|
my @idList = split(',', ReadingsVal($name, 'AlarmListIDs', ''));
|
||||||
if (!SONOS_isInList($id, @idList)) {
|
if (!SONOS_isInList($id, @idList)) {
|
||||||
@ -1011,7 +1011,7 @@ sub SONOSPLAYER_Set($@) {
|
|||||||
foreach my $dev (SONOS_getAllSonosplayerDevices()) {
|
foreach my $dev (SONOS_getAllSonosplayerDevices()) {
|
||||||
push(@sonosDevs, $dev->{NAME}) if ($dev->{NAME} ne $hash->{NAME});
|
push(@sonosDevs, $dev->{NAME}) if ($dev->{NAME} ne $hash->{NAME});
|
||||||
}
|
}
|
||||||
readingsSingleUpdate($hash, 'LastActionResult', 'AddMember: Wrong Sonos-Devicename "'.$value.'". Use one of "'.join('", "', @sonosDevs).'"', 1);
|
SONOS_readingsSingleUpdate($hash, 'LastActionResult', 'AddMember: Wrong Sonos-Devicename "'.$value.'". Use one of "'.join('", "', @sonosDevs).'"', 1);
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -1027,7 +1027,7 @@ sub SONOSPLAYER_Set($@) {
|
|||||||
foreach my $dev (SONOS_getAllSonosplayerDevices()) {
|
foreach my $dev (SONOS_getAllSonosplayerDevices()) {
|
||||||
push(@sonosDevs, $dev->{NAME}) if ($dev->{NAME} ne $hash->{NAME});
|
push(@sonosDevs, $dev->{NAME}) if ($dev->{NAME} ne $hash->{NAME});
|
||||||
}
|
}
|
||||||
readingsSingleUpdate($hash, 'LastActionResult', 'RemoveMember: Wrong Sonos-Devicename "'.$value.'". Use one of "'.join('", "', @sonosDevs).'"', 1);
|
SONOS_readingsSingleUpdate($hash, 'LastActionResult', 'RemoveMember: Wrong Sonos-Devicename "'.$value.'". Use one of "'.join('", "', @sonosDevs).'"', 1);
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -1063,7 +1063,7 @@ sub SONOSPLAYER_Set($@) {
|
|||||||
# Anweisung an den alten linken Lautsprecher absetzen
|
# Anweisung an den alten linken Lautsprecher absetzen
|
||||||
SONOS_DoWork($udn, 'separateStereoPair', uri_escape($leftPlayerShort.':LF,LF;'.$rightPlayerShort.':RF,RF'));
|
SONOS_DoWork($udn, 'separateStereoPair', uri_escape($leftPlayerShort.':LF,LF;'.$rightPlayerShort.':RF,RF'));
|
||||||
} elsif (lc($key) eq 'reboot') {
|
} elsif (lc($key) eq 'reboot') {
|
||||||
readingsSingleUpdate($hash, 'LastActionResult', 'Reboot properly initiated', 1);
|
SONOS_readingsSingleUpdate($hash, 'LastActionResult', 'Reboot properly initiated', 1);
|
||||||
|
|
||||||
my $url = ReadingsVal($name, 'location', '');
|
my $url = ReadingsVal($name, 'location', '');
|
||||||
$url =~ s/(^http:\/\/.*?)\/.*/$1\/reboot/;
|
$url =~ s/(^http:\/\/.*?)\/.*/$1\/reboot/;
|
||||||
@ -1072,12 +1072,12 @@ sub SONOSPLAYER_Set($@) {
|
|||||||
} elsif (lc($key) eq 'wifi') {
|
} elsif (lc($key) eq 'wifi') {
|
||||||
$value = lc($value);
|
$value = lc($value);
|
||||||
if ($value ne 'on' && $value ne 'off' && $value ne 'persist-off') {
|
if ($value ne 'on' && $value ne 'off' && $value ne 'persist-off') {
|
||||||
readingsSingleUpdate($hash, 'LastActionResult', 'Wrong parameter "'.$value.'". Use one of "off", "persist-off" or "on".', 1);
|
SONOS_readingsSingleUpdate($hash, 'LastActionResult', 'Wrong parameter "'.$value.'". Use one of "off", "persist-off" or "on".', 1);
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
readingsSingleUpdate($hash, 'LastActionResult', 'WiFi properly set to '.$value, 1);
|
SONOS_readingsSingleUpdate($hash, 'LastActionResult', 'WiFi properly set to '.$value, 1);
|
||||||
|
|
||||||
my $url = ReadingsVal($name, 'location', '');
|
my $url = ReadingsVal($name, 'location', '');
|
||||||
$url =~ s/(^http:\/\/.*?)\/.*/$1\/wifictrl?wifi=$value/;
|
$url =~ s/(^http:\/\/.*?)\/.*/$1\/wifictrl?wifi=$value/;
|
||||||
@ -1239,6 +1239,7 @@ sub SONOSPLAYER_Delete($$) {
|
|||||||
SONOSPLAYER_DeleteIfExists($hash->{NAME}.'RG_Favourites');
|
SONOSPLAYER_DeleteIfExists($hash->{NAME}.'RG_Favourites');
|
||||||
SONOSPLAYER_DeleteIfExists($hash->{NAME}.'RG_Playlists');
|
SONOSPLAYER_DeleteIfExists($hash->{NAME}.'RG_Playlists');
|
||||||
SONOSPLAYER_DeleteIfExists($hash->{NAME}.'RG_Radios');
|
SONOSPLAYER_DeleteIfExists($hash->{NAME}.'RG_Radios');
|
||||||
|
SONOSPLAYER_DeleteIfExists($hash->{NAME}.'RG_Queue');
|
||||||
|
|
||||||
# Das Entfernen des Sonos-Devices selbst übernimmt Fhem
|
# Das Entfernen des Sonos-Devices selbst übernimmt Fhem
|
||||||
return undef;
|
return undef;
|
||||||
|
@ -723,26 +723,27 @@ sub subscribe {
|
|||||||
my $ua = LWP::UserAgent->new(timeout => 20);
|
my $ua = LWP::UserAgent->new(timeout => 20);
|
||||||
my $response = $ua->request($request);
|
my $response = $ua->request($request);
|
||||||
|
|
||||||
if ($response->is_success &&
|
if ($response->is_success) {
|
||||||
$response->code == 200) {
|
if ($response->code == 200) {
|
||||||
my $sid = $response->header('SID');
|
my $sid = $response->header('SID');
|
||||||
$timeout = $response->header('Timeout');
|
$timeout = $response->header('Timeout');
|
||||||
if ($timeout =~ /^Second-(\d+)$/) {
|
if ($timeout =~ /^Second-(\d+)$/) {
|
||||||
$timeout = $1;
|
$timeout = $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $subscription = UPnP::ControlPoint::Subscription->new(
|
my $subscription = UPnP::ControlPoint::Subscription->new(
|
||||||
Service => $self,
|
Service => $self,
|
||||||
Callback => $callback,
|
Callback => $callback,
|
||||||
SID => $sid,
|
SID => $sid,
|
||||||
Timeout => $timeout,
|
Timeout => $timeout,
|
||||||
EventSubURL => "$url");
|
EventSubURL => "$url");
|
||||||
$cp->addSubscription($subscription);
|
$cp->addSubscription($subscription);
|
||||||
return $subscription;
|
return $subscription;
|
||||||
}
|
} else {
|
||||||
else {
|
carp("Subscription request successful but answered with error: " . $response->code . " " . $response->message);
|
||||||
carp("Subscription request failed with error: " .
|
}
|
||||||
$response->code . " " . $response->message);
|
} else {
|
||||||
|
carp("Subscription request failed with error: " . $response->code . " " . $response->message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user