diff --git a/FHEM/70_KODI.pm b/FHEM/70_KODI.pm index 4fcad4726..a18f3b3dc 100644 --- a/FHEM/70_KODI.pm +++ b/FHEM/70_KODI.pm @@ -114,7 +114,7 @@ sub KODI_Initialize($$) $hash->{ReadyFn} = "KODI_Ready"; $hash->{UndefFn} = "KODI_Undefine"; $hash->{AttrFn} = "KODI_Attr"; - $hash->{AttrList} = "compatibilityMode:kodi,plex offMode:quit,hibernate,shutdown,suspend updateInterval disable:0,1 jsonResponseReading:0,1 " . $readingFnAttributes; + $hash->{AttrList} = "compatibilityMode:kodi,plex offMode:quit,hibernate,shutdown,suspend updateInterval disable:0,1 jsonResponseReading:0,1 pvrEnabled:0,1 " . $readingFnAttributes; $data{RC_makenotify}{XBMC} = "KODI_RCmakenotify"; $data{RC_layout}{KODI_RClayout} = "KODI_RClayout"; @@ -1476,20 +1476,51 @@ sub KODI_PlayerCommand($$$) return KODI_Call($hash,$req,1); } +sub KODI_IsPvrEnabled($) +{ + my ($hash) = @_; + return AttrVal($hash->{NAME}, 'pvrEnabled', 1); +} + +sub KODI_PvrGetProperties($) +{ + my ($hash) = @_; + my $name = $hash->{NAME}; + Log3($name, 4, "$name: KODI_PvrGetProperties"); + + return undef if not KODI_IsPvrEnabled($hash); + + my $obj = { + "method" => "PVR.GetProperties", + "params" => { + "properties" => ["available","recording","scanning"] + } + }; + return KODI_Call($hash,$obj,1); +} + sub KODI_PvrUpdateChannels($) { my ($hash) = @_; + + return undef if not KODI_IsPvrEnabled($hash); + + fhem("deletereading $hash->{NAME} channel_.*", 1); fhem("deletereading $hash->{NAME} channelgroup_.*", 1); KODI_PvrGetChannelGroups($hash, "tv"); KODI_PvrGetChannelGroups($hash, "radio"); + + return undef; } sub KODI_PvrGetChannelGroups($$) { my ($hash,$type) = @_; + return undef if not KODI_IsPvrEnabled($hash); + my $id = KODI_CreateId($hash); my $req = { 'method' => 'PVR.GetChannelGroups', @@ -1503,6 +1534,8 @@ sub KODI_PvrGetChannels($$) { my ($hash,$channelGroupId) = @_; + return undef if not KODI_IsPvrEnabled($hash); + my $id = KODI_CreateId($hash); my $req = { 'method' => 'PVR.GetChannels', @@ -1956,6 +1989,8 @@ sub KODI_HTTP_Request($$@)