createState("PlexMonitor.PlexVis.Title", { name: 'Title', role: 'string', read: true, write: true,}); createState("PlexMonitor.PlexVis.FileName", { name: 'FileName', role: 'string', read: true, write: true,}); createState("PlexMonitor.PlexVis.Event", { name: 'Event', role: 'string', read: true, write: true,}); createState("PlexMonitor.PlexVis.Summary", { name: 'Summary', role: 'string', read: true, write: true,}); createState("PlexMonitor.PlexVis.Thumb", { name: 'Thumb', role: 'string', read: true, write: true,}); createState("PlexMonitor.PlexVis.Player", { name: 'Player', role: 'string', read: true, write: true,}); createState("PlexMonitor.PlexVis.Change", { name: 'Change', role: 'string', read: true, write: true,}); createState("PlexMonitor.PlexVis.AnzahlPlayer", { name: 'AnzahlPlayer', role: 'string', read: true, write: true,}); var Dpunkte7=[]; var Dpunkte=[]; schedule(" * * * * *", function () { var obj = getObject("system.adapter.plex.0"); if(obj.common.enabled){ // prüft ob plex läuft // log("plex adapter läuft"); Dpunkte=[]; $("plex.0._playing.*").each(function (id, c) { // array mit playern var idHelper=id.substring(16); //log(idHelper); var idBool=false; if (idHelper.indexOf(".") ==-1) idBool=true; if (getObject(id).type=="channel" && idBool )Dpunkte.push(id); }); // log(Dpunkte.toString()); setState("PlexMonitor.PlexVis.AnzahlPlayer",Dpunkte.length.toString()); log(Dpunkte7.toString()); } else {/*log("plex adapter nicht")*/} }); /* $("plex.0._playing.*.datetime").each(function (id, c) { Dpunkte7.push(id); }); */ // on({id: Dpunkte7, ack: true, change: "any"}, function (obj) { var x = new RegExp("\plex\.0\._playing\.*\.datetime$") on( {id:x, change: "any"}, function (obj) { var value1 = obj.state.val; var dp2 = obj.id ; //log(JSON.stringify(obj)); doTheWork(dp2,value1); }); function doTheWork(gibObject, value) { //setState("controll-own.0.HANDY.SeenSQLMatrix",value); //für mich - aussage und datenbank setState("PlexMonitor.PlexVis.Change",value) for (var index in Dpunkte) { // log(dp2 + Dpunkte[index]); if(gibObject.includes(Dpunkte[index])) {/*log("___________Player ist : "+Dpunkte[index]);*/setState("PlexMonitor.PlexVis.Player",Dpunkte[index].substring(16));var playerMoment=Dpunkte[index];} } var timeout = setTimeout(function () { setStateDelayed("PlexMonitor.PlexVis.Thumb","http://192.168.178.157:8181/pms_image_proxy?img="+(getState(playerMoment+".Metadata.thumb").val+"&width=300&height=450&fallback=poster"),1000); setStateDelayed("PlexMonitor.PlexVis.Summary",getState(playerMoment+".Metadata.summary").val, 200); /* log(getState(playerMoment+".Metadata.summary").val);*/ // log(getState(playerMoment+".event").val); if (getState(playerMoment+".event").val=="media.resume") { setState("PlexMonitor.PlexVis.Event","media.play");} else{setState("PlexMonitor.PlexVis.Event",getState(playerMoment+".event").val);} setState("controll-own.0.HANDY.SeenSQLMatrix",getState(playerMoment+".Metadata.file.name").val); //für mich - aussage und datenbank setState("PlexMonitor.PlexVis.FileName",getState(playerMoment+".Metadata.file.name").val) setState("PlexMonitor.PlexVis.Title",getState(playerMoment+".Metadata.title").val) }, 1500); }