mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-19 06:36:04 +00:00
Sonos: DeleteFn eingebaut
git-svn-id: https://svn.fhem.de/fhem/trunk@7324 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
411c433da6
commit
2dd26490f5
@ -407,6 +407,7 @@ sub SONOS_Initialize ($) {
|
|||||||
# Normal Defines
|
# Normal Defines
|
||||||
$hash->{DefFn} = 'SONOS_Define';
|
$hash->{DefFn} = 'SONOS_Define';
|
||||||
$hash->{UndefFn} = 'SONOS_Undef';
|
$hash->{UndefFn} = 'SONOS_Undef';
|
||||||
|
$hash->{DeleteFn} = 'SONOS_Delete';
|
||||||
$hash->{ShutdownFn} = 'SONOS_Shutdown';
|
$hash->{ShutdownFn} = 'SONOS_Shutdown';
|
||||||
$hash->{ReadFn} = "SONOS_Read";
|
$hash->{ReadFn} = "SONOS_Read";
|
||||||
$hash->{ReadyFn} = "SONOS_Ready";
|
$hash->{ReadyFn} = "SONOS_Ready";
|
||||||
@ -5691,6 +5692,37 @@ sub SONOS_Undef ($$) {
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
########################################################################################
|
||||||
|
#
|
||||||
|
# SONOS_Delete - Implements DeleteFn function
|
||||||
|
#
|
||||||
|
# Parameter hash = hash of the master, name
|
||||||
|
#
|
||||||
|
########################################################################################
|
||||||
|
sub SONOS_Delete($$) {
|
||||||
|
my ($hash, $name) = @_;
|
||||||
|
|
||||||
|
# Erst alle SonosPlayer-Devices löschen
|
||||||
|
for my $player (SONOS_getAllSonosplayerDevices()) {
|
||||||
|
CommandDelete(undef, $player->{NAME});
|
||||||
|
}
|
||||||
|
|
||||||
|
# Den SubProzess beenden
|
||||||
|
# Wenn wir einen eigenen UPnP-Server gestartet haben, diesen hier auch wieder beenden, ansonsten nichts tun...
|
||||||
|
if ($SONOS_StartedOwnUPnPServer) {
|
||||||
|
# Da die Verbindung bereits durch UndefFn beendet wurde, muss sie hier neu aufgebaut werden, damit ich den Subprozess selbst beenden kann (vorher wurde nur die Verbindung beendet)...
|
||||||
|
DevIo_OpenDev($hash, 1, undef);
|
||||||
|
DevIo_SimpleWrite($hash, "shutdown\n", 0);
|
||||||
|
DevIo_CloseDev($hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Etwas warten...
|
||||||
|
select(undef, undef, undef, 1);
|
||||||
|
|
||||||
|
# Das Entfernen des Sonos-Devices selbst übernimmt Fhem
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
########################################################################################
|
########################################################################################
|
||||||
#
|
#
|
||||||
# SONOS_Shutdown - Implements ShutdownFn function
|
# SONOS_Shutdown - Implements ShutdownFn function
|
||||||
|
@ -175,6 +175,7 @@ sub SONOSPLAYER_Initialize ($) {
|
|||||||
|
|
||||||
$hash->{DefFn} = "SONOSPLAYER_Define";
|
$hash->{DefFn} = "SONOSPLAYER_Define";
|
||||||
$hash->{UndefFn} = "SONOSPLAYER_Undef";
|
$hash->{UndefFn} = "SONOSPLAYER_Undef";
|
||||||
|
$hash->{DeleteFn} = "SONOSPLAYER_Delete";
|
||||||
$hash->{GetFn} = "SONOSPLAYER_Get";
|
$hash->{GetFn} = "SONOSPLAYER_Get";
|
||||||
$hash->{SetFn} = "SONOSPLAYER_Set";
|
$hash->{SetFn} = "SONOSPLAYER_Set";
|
||||||
$hash->{StateFn} = "SONOSPLAYER_State";
|
$hash->{StateFn} = "SONOSPLAYER_State";
|
||||||
@ -725,6 +726,43 @@ sub SONOSPLAYER_Undef ($) {
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
########################################################################################
|
||||||
|
#
|
||||||
|
# SONOSPLAYER_Delete - Implements DeleteFn function
|
||||||
|
#
|
||||||
|
# Parameter hash = hash of the master, name
|
||||||
|
#
|
||||||
|
########################################################################################
|
||||||
|
sub SONOSPLAYER_Delete($$) {
|
||||||
|
my ($hash, $name) = @_;
|
||||||
|
|
||||||
|
# Alle automatisch erzeugten Komponenten mit entfernen, sofern es sie noch gibt...
|
||||||
|
SONOSPLAYER_DeleteIfExists($hash->{NAME}.'RC_Notify');
|
||||||
|
SONOSPLAYER_DeleteIfExists($hash->{NAME}.'RC_Weblink');
|
||||||
|
SONOSPLAYER_DeleteIfExists($hash->{NAME}.'RC');
|
||||||
|
|
||||||
|
SONOSPLAYER_DeleteIfExists($hash->{NAME}.'RG');
|
||||||
|
SONOSPLAYER_DeleteIfExists($hash->{NAME}.'RG_Favourites');
|
||||||
|
SONOSPLAYER_DeleteIfExists($hash->{NAME}.'RG_Playlists');
|
||||||
|
SONOSPLAYER_DeleteIfExists($hash->{NAME}.'RG_Radios');
|
||||||
|
|
||||||
|
# Das Entfernen des Sonos-Devices selbst übernimmt Fhem
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
########################################################################################
|
||||||
|
#
|
||||||
|
# SONOSPLAYER_DeleteIfExists - Deletes the Device with the given Name
|
||||||
|
#
|
||||||
|
# Parameter hash = hash of the master, name
|
||||||
|
#
|
||||||
|
########################################################################################
|
||||||
|
sub SONOSPLAYER_DeleteIfExists($) {
|
||||||
|
my ($name) = @_;
|
||||||
|
|
||||||
|
CommandDelete(undef, $name) if ($main::defs{$name});
|
||||||
|
}
|
||||||
|
|
||||||
########################################################################################
|
########################################################################################
|
||||||
#
|
#
|
||||||
# SONOSPLAYER_Log - Log to the normal Log-command with additional Infomations like Thread-ID and the prefix 'SONOSPLAYER'
|
# SONOSPLAYER_Log - Log to the normal Log-command with additional Infomations like Thread-ID and the prefix 'SONOSPLAYER'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user