Module für XBMC

Begonnen von Dennis B., 06 Januar 2013, 22:32:24

Vorheriges Thema - Nächstes Thema

vbs

Du brauchst auch defaultmäßig nur Port 9090 für RPC. Wenn du die "Fernbedienbarkeit" in Kodi aktivierst, sollte die auf 9090 verfügbar sein. Kenne jedoch max2play nicht.

---
Was C0mmanda gesagt hat ^^ Meinte ich mit "FHEM will nicht mit dem "normalen" Webserver reden, sondern mit dem JSON-Server"

TWART016

Jetzt funkioniert es :D Vermutlich lage es mal wieder am Neustart  ???

vbs


Aki1988

Hallo,
erst einmal vielen Dank für das Modul. Das senden von Befehlen funktioniert ganz gut.
Ich habe aber ein Problem mit den Logs. Ich möchte den PlayStatus eines separaten RPi+OSMC (in eine SQL Datenbank mittels DBLog) mit loggen. Also habe ich in FHEM beim Gerät folgende Attribute gesetzt (gesamte definition der Vollständigkeit halber):
define UG.Kino.RPi.Kodi XBMC UG-Kino-RPi-Kodi.fritz.box tcp
attr UG.Kino.RPi.Kodi DbLogExclude .*
attr UG.Kino.RPi.Kodi DbLogInclude playStatus
attr UG.Kino.RPi.Kodi compatibilityMode xbmc
attr UG.Kino.RPi.Kodi devStateIcon opened:rc_GREEN:on disconnected:rc_RED:off Initialized:message_socket_disabled
attr UG.Kino.RPi.Kodi event-on-change-reading playStatus
attr UG.Kino.RPi.Kodi fork enable
attr UG.Kino.RPi.Kodi offMode shutdown
attr UG.Kino.RPi.Kodi room KODI
attr UG.Kino.RPi.Kodi updateInterval 60


Das loggen funktioniert auch generell in die Datenbank. Frage ich nach einem Film die Datenbank ab, bekomme ich folgende Logs:
| 2016-12-02 21:24:53 | UG.Kino.RPi.Kodi | XBMC | playStatus: playing | playStatus | playing |      |
| 2016-12-02 21:24:53 | UG.Kino.RPi.Kodi | XBMC | playStatus: stopped | playStatus | stopped |      |
| 2016-12-02 21:24:53 | UG.Kino.RPi.Kodi | XBMC | playStatus: playing | playStatus | playing |      |
| 2016-12-02 21:24:53 | UG.Kino.RPi.Kodi | XBMC | playStatus: stopped | playStatus | stopped |      |
| 2016-12-02 21:24:53 | UG.Kino.RPi.Kodi | XBMC | playStatus: playing | playStatus | playing |      |
| 2016-12-02 21:24:53 | UG.Kino.RPi.Kodi | XBMC | playStatus: stopped | playStatus | stopped |      |
| 2016-12-02 21:24:54 | UG.Kino.RPi.Kodi | XBMC | playStatus: playing | playStatus | playing |      |
| 2016-12-02 21:24:54 | UG.Kino.RPi.Kodi | XBMC | playStatus: stopped | playStatus | stopped |      |
| 2016-12-02 21:24:54 | UG.Kino.RPi.Kodi | XBMC | playStatus: playing | playStatus | playing |      |
| 2016-12-02 21:24:54 | UG.Kino.RPi.Kodi | XBMC | playStatus: stopped | playStatus | stopped |      |
| 2016-12-02 21:24:54 | UG.Kino.RPi.Kodi | XBMC | playStatus: playing | playStatus | playing |      |
| 2016-12-02 21:24:54 | UG.Kino.RPi.Kodi | XBMC | playStatus: stopped | playStatus | stopped |      |
| 2016-12-02 21:24:54 | UG.Kino.RPi.Kodi | XBMC | playStatus: playing | playStatus | playing |      |
| 2016-12-02 21:24:55 | UG.Kino.RPi.Kodi | XBMC | playStatus: stopped | playStatus | stopped |      |
| 2016-12-02 21:24:55 | UG.Kino.RPi.Kodi | XBMC | playStatus: playing | playStatus | playing |      |
| 2016-12-02 21:24:55 | UG.Kino.RPi.Kodi | XBMC | playStatus: stopped | playStatus | stopped |      |
| 2016-12-02 21:24:55 | UG.Kino.RPi.Kodi | XBMC | playStatus: playing | playStatus | playing |      |
| 2016-12-02 21:24:55 | UG.Kino.RPi.Kodi | XBMC | playStatus: stopped | playStatus | stopped |      |
| 2016-12-02 21:24:55 | UG.Kino.RPi.Kodi | XBMC | playStatus: playing | playStatus | playing |      |
| 2016-12-02 21:24:56 | UG.Kino.RPi.Kodi | XBMC | playStatus: stopped | playStatus | stopped |      |

Insgesammt ca 18.000 Zeilen für einen zwei Stunden Film. Wie man sieht 6 mal pro Sekunde einen Status Wechsel von playing auf stopped und zurück. Kann sich das jemand erklären?

Noch ein kurzer überblick über meine Konfiguration:
1x RPi mit FHEM
1x RPi mit OSMC (KODI wird von FHEM abgefragt und streamt Filme von einer Windowsfreigabe)
1x Ubuntu Server mit MariaDB (=SQL Server wird von FHEM gefüllt)
1x Dateiserver (stellt Filme im Netzwerk bereit - KODI spielt von hier Filme ab)

vbs

Ich würde auch hier erstmal FHEM aus der Gleichung rausnehmen und mich mit Telnet auf den JSON Port verbinden. Scheint so zu sein, dass Kodi permanent Events feuert? Hätte ich erstmal keine Idee. Evtl. mal im Kodi-Forum fragen.

Aki1988

Hallo,
also nach abhören der Telnet Verbindung ist mir nichts aufgefallen. Also habe ich das Gerät noch einmal gelöscht und neu angelegt. Und siehe da, es funktionierte. Also habe ich meine Alten Einstellungen nacheinander wieder angefügt. Das Status Flackern fing an als ich das Attribut "fork" enabled habe. Ich werde es heute Abend nach dem Film nochmal beobachten. Ohne das Attribut "fork enable" funktioniert das auslesen. Also tatsächlich kein Kodi Problem sondern ein Fhem Problem - zumindest bei mir.

vbs

Dann bitte einmal ein (verbose) Log posten. Am besten mit Events dabei.

romibaer

Hey - danke für deine Arbeit und das klasse Modul.

Kann mir eventuell jemand sagen, wie ich an die ChannelId`s aus Kodi rankomme ?
Übern Log konnte ich jetzt ein paar raussehen - und auch erfolgreich hin und her schalten - aber die gibts doch sicher auch irgendwo als Liste?
Ich hab den Mega-Thread hier noch nicht ganz durchgewühlt aber über die Suche und das was ich bisher gelesen habe - konnte mir leider nicht weiterhelfen.
(Kodi läuft in 16,1 auf Win10)

Kann mir da eventuell jemand unter die Arme greifen ?

Besten Dank

nesges

Zitat von: romibaer am 14 Januar 2017, 18:14:54
Kann mir eventuell jemand sagen, wie ich an die ChannelId`s aus Kodi rankomme ?

Du kannst sie über die JSON-RPC Schnittstelle abfragen. Setze dein Kodi-Device auf verbose 5, dann sendest du einen PVR.GetChannelGroups Request um die channelgroupids abzufragen. Die Antwort findest du im fhem.log. Mit den/der ID sendest du einen PVR.GetChannels Request und siehst die Antwort wiederum im fhem.log.

PVR.GetChannelGroups

attr B_XBMC verbose 5
set B_XBMC jsonraw {"id":4711,"method":"PVR.GetChannelGroups","params":{"channeltype":"tv"},"jsonrpc":"2.0"}


fhem.log:
2017.02.01 11:00:18 5: XBMC_Read: Incoming data: {"id":4711,"jsonrpc":"2.0","result":{"channelgroups":[{"channelgroupid":1,"channeltype":"tv","label":"Alle Kanäle"}],"limits":{"end":1,"start":0,"total":1}}}


PVR.GetChannels

set B_XBMC jsonraw {"id":4712,"method":"PVR.GetChannels","params":{"channelgroupid":1},"jsonrpc":"2.0"}

fhem.log:
2017.02.01 11:01:14 5: XBMC_Read: Incoming data: {"id":4712,"jsonrpc":"2.0","result":{"channels":[{"channelid":31,"label":"Das Erste SD"},{"channelid":30,"label":"ZDF SD"},{"channelid":33,"label":"Das Erste"},{"channelid":26,"label":"ZDF"},{"channelid":29,"label":"ProSieben"},{"channelid":13,"label":"ProSieben maxx"},{"channelid":2,"label":"VOX"},{"channelid":25,"label":"Sixx"},{"channelid":14,"label":"kabeleins"},{"channelid":24,"label":"sat.1"},{"channelid":3,"label":"sat.1 Gold"},{"channelid":11,"label":"RTL"},{"channelid":16,"label":"RTL II"},{"channelid":6,"label":"Super RTL"},{"channelid":32,"label":"RTL NITRO"},{"channelid":21,"label":"TELE 5"},{"channelid":4,"label":"KiKA"},{"channelid":34,"label":"arte"},{"channelid":36,"label":"ZDFneo"},{"channelid":15,"label":"ZDFinfo"},{"channelid":27,"label":"ZDFkultur"},{"channelid":20,"label":"einsfestival"},{"channelid":35,"label":"eins|plus"},{"channelid":18,"label":"3sat"},{"channelid":1,"label":"BR"},{"channelid":23,"label":"hr"},{"channelid":8,"label":"mdr HD"},{"channelid":19,"label":"NDR HH"},{"channelid":10,"label":"rbb"},{"channelid":22,"label":"SWR"},{"channelid":28,"label":"WDR"},{"channelid":7,"label":"tagesschau24"},{"channelid":12,"label":"phoenix"},{"channelid":9,"label":"n-tv"},{"channelid":5,"label":"Disney Channel"},{"channelid":17,"label":"nickelodeon CH"}],"limits":{"end":36,"start":0,"total":36}}}

vbs

Ich kann bei Bedarf fehlende API-Funktion in das Modul einbauen, wenn das hilft.

nesges

Zitat von: vbs am 01 Februar 2017, 12:08:27
Ich kann bei Bedarf fehlende API-Funktion in das Modul einbauen, wenn das hilft.

Apropos :-) Ich hab verschiedene GUI.ActivateWindow-Requests in einer Funktion ausserhalb des Moduls implementiert, bei Interesse baue ich sie als neuen Befehl in die aktuelle Version ein und schicke sie dir.


# mostly according to http://kodi.wiki/view/Opening_Windows_and_Dialogs
our %kodi_windownames = (
    Settings                    => [ 'settings' ],
    # video
    VideoRoot                   => [ 'videos', 'library://video/' ],
    Movies                      => [ 'videos', 'videodb://movies/' ],
    MovieGenres                 => [ 'videos', 'videodb://movies/genres/' ],
    MovieTitles                 => [ 'videos', 'videodb://movies/titles/' ],
    MovieYears                  => [ 'videos', 'videodb://movies/years/' ],
    MovieActors                 => [ 'videos', 'videodb://movies/actors/' ],
    MovieDirectors              => [ 'videos', 'videodb://movies/directors/' ],
    MovieStudios                => [ 'videos', 'videodb://movies/studios/' ],
    MovieSets                   => [ 'videos', 'videodb://movies/sets/' ],
    MovieCountries              => [ 'videos', 'videodb://movies/countries/' ],
    MovieTags                   => [ 'videos', 'videodb://movies/tags/' ],
    RecentlyAddedMovies         => [ 'videos', 'videodb://recentlyaddedmovies/' ],
    TvShows                     => [ 'videos', 'videodb://tvshows/' ],
    TvShowGenres                => [ 'videos', 'videodb://tvshows/genres/' ],
    TvShowTitles                => [ 'videos', 'videodb://tvshows/titles/' ],
    TvShowYears                 => [ 'videos', 'videodb://tvshows/years/' ],
    TvShowActors                => [ 'videos', 'videodb://tvshows/actors/' ],
    TvShowStudios               => [ 'videos', 'videodb://tvshows/studios/' ],
    RecentlyAddedEpisodes       => [ 'videos', 'videodb://recentlyaddedepisodes/' ],
    InProgressTvShows           => [ 'videos', 'library://video/inprogressshows.xml/' ],    # !
    MusicVideos                 => [ 'videos', 'videodb://musicvideos/' ],
    MusicVideoGenres            => [ 'videos', 'videodb://musicvideos/genres/' ],
    MusicVideoTitles            => [ 'videos', 'videodb://musicvideos/titles/' ],
    MusicVideoYears             => [ 'videos', 'videodb://musicvideos/years/' ],
    MusicVideoArtists           => [ 'videos', 'videodb://musicvideos/artists/' ],
    MusicVideoAlbums            => [ 'videos', 'videodb://musicvideos/albums/' ],
    MusicVideoDirectors         => [ 'videos', 'videodb://musicvideos/directors/' ],
    MusicVideoStudios           => [ 'videos', 'videodb://musicvideos/studios/' ],
    RecentlyAddedMusicVideos    => [ 'videos', 'videodb://recentlyaddedmusicvideos/' ],
    VideoPlaylists              => [ 'videos', 'special://videoplaylists/' ],
    VideoAddons                 => [ 'videos', 'addons://sources/video/' ],
    VideoFiles                  => [ 'videos', 'sources://video/' ],
   
    # music
    MusicRoot                   => [ 'music', 'library://music/' ],
    Genres                      => [ 'music', 'musicdb://genres/' ],
    Artists                     => [ 'music', 'musicdb://artists/' ],
    Albums                      => [ 'music', 'musicdb://albums/' ],
    Song                        => [ 'music', 'musicdb://songs/' ],
    Top100                      => [ 'music', 'musicdb://top100/' ],
    Top100Songs                 => [ 'music', 'library://music/top100/top100songs.xml/' ],      # !
    Top100Albums                => [ 'music', 'library://music/top100/top100albums.xml/' ],     # !
    RecentlyAddedAlbums         => [ 'music', 'musicdb://recentlyaddedalbums/' ],
    RecentlyPlayedAlbums        => [ 'music', 'musicdb://recentlyplayedalbums/' ],
    Compilations                => [ 'music', 'musicdb://compilations/' ],
    Years                       => [ 'music', 'musicdb://years/' ],
    Singles                     => [ 'music', 'musicdb://singles/' ],
    MusicFiles                  => [ 'music', 'sources://music/' ],
    MusicPlaylists              => [ 'music', 'special://musicplaylists/' ],
    MusicAddons                 => [ 'music', 'addons://sources/audio/' ],
   
    # programs
    ProgramAddons               => [ 'programs', 'addons://sources/executable/' ],
    AndroidApps                 => [ 'programs', 'androidapp://sources/apps/' ],
   
    # addons
    Addons                      => [ 'addonbrowser' ],
    #UpdateAvailable             => [ 'addonbrowser', 'addons://outdated/' ],
    #CurrentlyDownloading        => [ 'addonbrowser', 'addons://downloading/' ],
    #RecentlyUpdated             => [ 'addonbrowser', 'addons://recently_updated/' ],
    #Repositories                => [ 'addonbrowser', 'addons://repos/' ],
    #InstallZip                  => [ 'addonbrowser', 'addons://install/' ],
    AddonSearch                 => [ 'addonbrowser', 'addons://search/' ],
   
    FileManager => [ 'filemanager' ],
    EventLog => [ 'eventlog' ],
    SubTitles => [ 'subtitlesearch' ],
    MovieInformation => [ 'movieinformation' ],
   
    # SystemInfo => [ 'settingssysteminfo' ],
    # Profile => [ 'settingsprofile' ],
    # Pictures => [ 'mypics' ],
    # Weather => [ 'myweather' ],
    # PVR => [ 'mypvrchannels' ],
);

sub kodi_activatewindow($$;$) {
    my $kodi = shift;
    my $window = shift;
    my $path = shift;
   
    my $params;
    if($path) {
        $params = {window => $window,parameters => [ $path ]};
    } else {
        $params = {window => $window};
    }
   
    my $hash = $defs{$kodi};
    my $data = {
        method => 'GUI.ActivateWindow',
        params => $params
    };
    XBMC_Call($hash,$data,1);
}

sub kodi_activatewindow_byname($$) {
    my $kodi = shift;
    my $name = shift;

    our %kodi_windownames;
   
    kodi_activatewindow($kodi, $kodi_windownames{$name}[0], $kodi_windownames{$name}[1]);
}


Die Liste ist sicher noch zu erweitern, aber ich finde keine gescheite Doku dazu.

vbs


C0mmanda

Zitat von: vbs am 01 Februar 2017, 12:08:27
Ich kann bei Bedarf fehlende API-Funktion in das Modul einbauen, wenn das hilft.

Ich weiß nicht ob die API das hergibt, was ich aktuell jedoch am meisten vermisse:

Inhalte aus den Bibliotheken aus FHEM heraus abspielen zu können und zwar ohne dies statisch einprogrammieren zu müssen. Denke hier vor allem an Musik.
Ich vermute mal wenn man Kodi mit SQL-Datenbank am laufen hat sollte das doch möglich sein?!
(Nur eine Vermutung, bin selbst absolut unfähig sowas zu programmieren).

grtz
CmdA

nesges

Im Anhang wie angekündigt eine Testversion(!) des Moduls, die den neuen Befehl "activatewindow" implementiert, mit dem benannte Fenster in Kodi geöffnet werden können. Eine Liste der Fenster ist als Set-Parameter hinterlegt und dokumentiert.

Entwicklungstechnisch weiß ich nicht, ob es Ok ist Packagevariablen (our %XBMC_WindowNames) zu nutzen. Ich habe allerdings auch keinen Hinweis aufs Gegenteil gefunden.

C0mmanda

Scheint problemlos zu funktionieren. Danke dafür.

Wäre es möglich die TVChannels auch unterzubringen?

grtz
CmdA