mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-28 05:01:57 +00:00
70_KODI: reworked/fixed handling of attribute "disable"
git-svn-id: https://svn.fhem.de/fhem/trunk@25898 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
e4e5dc7630
commit
3cba270070
@ -158,25 +158,51 @@ sub KODI_Define($$)
|
||||
|
||||
$attr{$hash->{NAME}}{"updateInterval"} = 60;
|
||||
|
||||
return KODI_Connect( $hash, 0 );
|
||||
my $ret = undef;
|
||||
$ret = KODI_Connect( $hash, 0 ) if (!AttrVal($hash->{NAME}, 'disable', 0));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
sub KODI_Attr($$$$)
|
||||
{
|
||||
my ($cmd, $name, $attr, $value) = @_;
|
||||
my $hash = $defs{$name};
|
||||
my ($mode, $devName, $attrName, $attrValue) = @_;
|
||||
my $hash = $defs{$devName};
|
||||
|
||||
if($attr eq "disable") {
|
||||
if($cmd eq "set" && ($value || !defined($value))) {
|
||||
KODI_Disconnect($hash);
|
||||
$hash->{STATE} = "Disabled";
|
||||
} else {
|
||||
if (AttrVal($hash->{NAME}, 'disable', 0)) {
|
||||
$hash->{STATE} = "Initialized";
|
||||
# handling for "disable" borrowed from 70_MEDIAPORTAL, thanks
|
||||
|
||||
my $dev = $hash->{DeviceName};
|
||||
$readyfnlist{"$name.$dev"} = $hash;
|
||||
my $disableChange = 0;
|
||||
if($mode eq 'set') {
|
||||
if ($attrName eq 'disable') {
|
||||
if ($attrValue && AttrVal($devName, $attrName, 0) != 1) {
|
||||
$disableChange = 1;
|
||||
}
|
||||
|
||||
if (!$attrValue && AttrVal($devName, $attrName, 0) != 0) {
|
||||
$disableChange = 1;
|
||||
}
|
||||
}
|
||||
} elsif ($mode eq 'del') {
|
||||
if ($attrName eq 'disable') {
|
||||
if (AttrVal($devName, $attrName, 0) != 0) {
|
||||
$disableChange = 1;
|
||||
$attrValue = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($disableChange) {
|
||||
# Wenn die Verbindung beendet werden muss...
|
||||
if ($attrValue) {
|
||||
Log3($devName, 3, "$devName: Call AttributeFn: Stop Connection...");
|
||||
DevIo_CloseDev($hash);
|
||||
$hash->{STATE} = "Disabled";
|
||||
}
|
||||
|
||||
# Wenn die Verbindung gestartet werden muss...
|
||||
if (!$attrValue) {
|
||||
Log3($devName, 3, "$devName: Call AttributeFn: Start Connection...");
|
||||
$hash->{STATE} = "Initialized";
|
||||
KODI_Connect($hash, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -265,8 +291,6 @@ sub KODI_Undefine($$)
|
||||
my $name = $hash->{NAME};
|
||||
Log3($name, 4, "$name: KODI_Undefine");
|
||||
|
||||
RemoveInternalTimer($hash);
|
||||
|
||||
KODI_Disconnect($hash);
|
||||
|
||||
return undef;
|
||||
@ -276,6 +300,7 @@ sub KODI_Disconnect($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
if($hash->{Protocol} eq 'tcp') {
|
||||
RemoveInternalTimer($hash);
|
||||
DevIo_CloseDev($hash);
|
||||
}
|
||||
}
|
||||
@ -1940,7 +1965,7 @@ sub KODI_HTTP_Request($$@)
|
||||
<li><b>audiolibrary</b> - Possible values: cleanfinished, cleanstarted, remove, scanfinished, scanstarted, update</li>
|
||||
<li><b>currentAlbum</b> - album of the current song/musicvideo</li>
|
||||
<li><b>currentArtist</b> - artist of the current song/musicvideo</li>
|
||||
<li><b>currentAudioStream_*</b> - informations about currently active audio stream</li>
|
||||
<li><b>currentAudioStream_*</b> - information about currently active audio stream</li>
|
||||
<li><b>currentMedia</b> - file/URL of the media item being played</li>
|
||||
<li><b>currentTitle</b> - title of the current media item</li>
|
||||
<li><b>currentTrack</b> - track of the current song/musicvideo</li>
|
||||
|
Loading…
x
Reference in New Issue
Block a user