2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-07 16:59:18 +00:00

70_XBMC: added attribute "disable", added reading "tvshowid"

git-svn-id: https://svn.fhem.de/fhem/trunk@9661 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
vbs2 2015-10-25 12:44:05 +00:00
parent c909a319c3
commit aa0e73272f
2 changed files with 58 additions and 6 deletions

View File

@ -1,5 +1,7 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- feature: 70_XBMC: -added disable attribute
-added reading tvshowid
- feature: new module 00_SIGNALduino.pm and 90_SIGNALduino_un: added
SIGNALduino module and firmware
- feature: new module 14_Hideki.pm: added module for sensors with hideki

View File

@ -29,7 +29,8 @@ sub XBMC_Initialize($$)
$hash->{ReadFn} = "XBMC_Read";
$hash->{ReadyFn} = "XBMC_Ready";
$hash->{UndefFn} = "XBMC_Undefine";
$hash->{AttrList} = "fork:enable,disable compatibilityMode:xbmc,plex offMode:quit,hibernate,shutdown,standby updateInterval " . $readingFnAttributes;
$hash->{AttrFn} = "XBMC_Attr";
$hash->{AttrList} = "fork:enable,disable compatibilityMode:xbmc,plex offMode:quit,hibernate,shutdown,standby updateInterval disable:1,0 " . $readingFnAttributes;
$data{RC_makenotify}{XBMC} = "XBMC_RCmakenotify";
$data{RC_layout}{XBMC_RClayout} = "XBMC_RClayout";
@ -75,6 +76,28 @@ sub XBMC_Define($$)
return undef;
}
sub XBMC_Attr($$$$)
{
my ($cmd, $name, $attr, $value) = @_;
my $hash = $defs{$name};
if($attr eq "disable") {
if($cmd eq "set" && ($value || !defined($value))) {
XBMC_Disconnect($hash);
$hash->{STATE} = "Disabled";
} else {
if (AttrVal($hash->{NAME}, 'disable', 0)) {
$hash->{STATE} = "Initialized";
my $dev = $hash->{DeviceName};
$readyfnlist{"$name.$dev"} = $hash;
}
}
}
return undef;
}
# Force a connection attempt to XBMC as soon as possible
# (e.g. you know you just started it and want to connect immediately without waiting up to 60 s)
sub XBMC_Connect($)
@ -103,9 +126,25 @@ sub XBMC_Connect($)
return undef;
}
# kills child process trying to connect (if existing)
sub XBMC_KillConnectionChild($)
{
my ($hash) = @_;
return if !$hash->{CHILDPID};
kill 'KILL', $hash->{CHILDPID};
undef $hash->{CHILDPID};
}
sub XBMC_Ready($)
{
my ($hash) = @_;
if (AttrVal($hash->{NAME}, 'disable', 0)) {
return;
}
if($hash->{Protocol} eq 'tcp') {
if(AttrVal($hash->{NAME},'fork','disable') eq 'enable') {
if($hash->{CHILDPID} && !(kill 0, $hash->{CHILDPID})) {
@ -153,10 +192,19 @@ sub XBMC_Undefine($$)
RemoveInternalTimer($hash);
XBMC_Disconnect($hash);
return undef;
}
sub XBMC_Disconnect($)
{
my ($hash) = @_;
if($hash->{Protocol} eq 'tcp') {
DevIo_CloseDev($hash);
}
return undef;
XBMC_KillConnectionChild($hash);
}
sub XBMC_Init($)
@ -293,7 +341,7 @@ sub XBMC_PlayerGetItem($$)
"method" => "Player.GetItem",
"params" => {
"properties" => ["artist", "album", "thumbnail", "file", "title",
"track", "year", "streamdetails"]
"track", "year", "streamdetails", "tvshowid"]
}
};
if($playerid >= 0) {
@ -387,7 +435,7 @@ sub XBMC_ResetMediaReadings($)
# delete streamdetails readings
# NOTE: we actually delete the readings (unlike the other readings)
# because they are stream count dependent
fhem("deletereading $hash->{NAME} sd_.*");
fhem("deletereading $hash->{NAME} sd_.*", 1);
}
sub XBMC_ResetPlayerReadings($)
@ -1590,6 +1638,8 @@ sub XBMC_HTTP_Request($$@)
which will move the search for XBMC into a separate process.</li>
<li>updateInterval<br>
The interval which is used to check if Kodi is still alive (by sending a JSON ping) and also it is used to update current player item.</li>
<li>disable<br>
Disables the device. All connections will be closed immediately.</li>
</ul>
</ul>