Moin,
mal ein bissl Arbeit gemacht Jetzt wird angezeigt ob der Server läuft. Was läuft (dabei ist momentan nur Video-Content + PVR abgedeckt).
Zum Nodes importieren:
JavaScript
[
{
"id": "6c0230df.62aff8",
"type": "tab",
"label": "Kodi",
"disabled": false,
"info": ""
},
{
"id": "ca0e80d.d92ef8",
"type": "ping",
"z": "6c0230df.62aff8",
"mode": "timed",
"name": "Server Pingen",
"host": "192.168.123.101",
"timer": "5",
"inputs": 0,
"x": 190,
"y": 260,
"wires": [
[
"45cd1134.ca532"
]
]
},
{
"id": "3d9709e.5434cf6",
"type": "ui_switch",
"z": "6c0230df.62aff8",
"name": "",
"label": "Mediencenter läuft",
"tooltip": "",
"group": "6fc15530.2c7c3c",
"order": 0,
"width": 0,
"height": 0,
"passthru": true,
"decouple": "false",
"topic": "",
"style": "",
"onvalue": "true",
"onvalueType": "bool",
"onicon": "",
"oncolor": "",
"offvalue": "false",
"offvalueType": "bool",
"officon": "",
"offcolor": "",
"x": 630,
"y": 260,
"wires": [
[
"8e0fae5e.32cb3"
]
]
},
{
"id": "45cd1134.ca532",
"type": "function",
"z": "6c0230df.62aff8",
"name": "",
"func": "if(msg.payload==false){\n msg.payload=false;\n}\nelse msg.payload=true;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 380,
"y": 260,
"wires": [
[
"3d9709e.5434cf6"
]
]
},
{
"id": "3a5c02bf.4f63ae",
"type": "http request",
"z": "6c0230df.62aff8",
"name": "",
"method": "POST",
"ret": "obj",
"paytoqs": "ignore",
"url": "http://192.168.123.101/jsonrpc?request={\"jsonrpc\": \"2.0\", \"method\": \"Player.GetItem\", \"params\": { \"properties\": [\"title\", \"album\", \"artist\", \"season\", \"episode\", \"duration\", \"showtitle\", \"tvshowid\", \"thumbnail\", \"file\", \"fanart\", \"streamdetails\"], \"playerid\": 1 }, \"id\": \"VideoGetItem\"}",
"tls": "",
"persist": false,
"proxy": "",
"authType": "basic",
"x": 1290,
"y": 260,
"wires": [
[
"bcf67c78.2d31e8"
]
]
},
{
"id": "9acd940e.345f88",
"type": "ui_text",
"z": "6c0230df.62aff8",
"group": "6fc15530.2c7c3c",
"order": 0,
"width": 0,
"height": 0,
"name": "Ausgabe",
"label": "",
"format": "{{msg.payload}}",
"layout": "col-center",
"x": 1900,
"y": 260,
"wires": []
},
{
"id": "bcf67c78.2d31e8",
"type": "function",
"z": "6c0230df.62aff8",
"name": "Nach Typ andere Ausgabe",
"func": "\nif(msg.payload.result.item.label!=false){\n if(msg.payload.result.item.type==\"channel\"){\n msg.payload=\"<p>Sender: \"+msg.payload.result.item.label+\"</p><p>Es läuft: \"+msg.payload.result.item.title+\"</p>\"; \n }\n else if(msg.payload.result.item.type==\"movie\")\n {\n hour=Math.floor(msg.payload.result.item.streamdetails.video[0].duration/3600);\n minute=Math.floor(msg.payload.result.item.streamdetails.video[0].duration%3600/60);\n second=Math.floor(msg.payload.result.item.streamdetails.video[0].duration%60);\n if(hour < 10){\n hour = \"0\"+hour;\n }\n if(minute < 10){\n minute = \"0\"+minute;\n }\n if(second < 10){\n second = \"0\"+second;\n }\n msg.payload=\"<p>Filmtitel: \"+msg.payload.result.item.title+\"</p><p>Filmlänge: \"+hour+\":\"+minute+\":\"+second+\"</p>\";\n }\n else if(msg.payload.result.item.type==\"episode\")\n {\n hour=Math.floor(msg.payload.result.item.streamdetails.video[0].duration/3600);\n minute=Math.floor(msg.payload.result.item.streamdetails.video[0].duration%3600/60);\n second=Math.floor(msg.payload.result.item.streamdetails.video[0].duration%60);\n if(hour < 10){\n hour = \"0\"+hour;\n }\n if(minute < 10){\n minute = \"0\"+minute;\n }\n if(second < 10){\n second = \"0\"+second;\n }\n msg.payload=\"<p>Serientitel: \"+msg.payload.result.item.showtitle+\"</p><p>Episode: \"+msg.payload.result.item.title+\"</p><p>Episodenlänge: \"+hour+\":\"+minute+\":\"+second+\"</p>\";\n }\n}\nelse{\n msg.payload=\"Es wird nichts abgespielt.\";\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1560,
"y": 260,
"wires": [
[
"9acd940e.345f88"
]
]
},
{
"id": "8179f813.b9e4d8",
"type": "function",
"z": "6c0230df.62aff8",
"name": "",
"func": "if (msg.payload==true){\nmsg.payload = '{\"jsonrpc\": \"2.0\", \"method\": \"Player.GetItem\", \"params\": { \"properties\": [\"title\", \"album\", \"artist\", \"season\", \"episode\", \"duration\", \"showtitle\", \"tvshowid\", \"thumbnail\", \"file\", \"fanart\", \"streamdetails\"], \"playerid\": 1 }, \"id\": \"VideoGetItem\"}';\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1060,
"y": 260,
"wires": [
[
"3a5c02bf.4f63ae"
]
]
},
{
"id": "8e0fae5e.32cb3",
"type": "switch",
"z": "6c0230df.62aff8",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "true"
},
{
"t": "false"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 850,
"y": 260,
"wires": [
[
"8179f813.b9e4d8"
],
[
"f10df51a.0f3388"
]
]
},
{
"id": "f10df51a.0f3388",
"type": "function",
"z": "6c0230df.62aff8",
"name": "",
"func": "if(msg.payload==false){\nmsg.payload=\"Mediacenter läuft nicht.\";\nreturn msg;\n}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1270,
"y": 380,
"wires": [
[
"9acd940e.345f88"
]
]
},
{
"id": "6fc15530.2c7c3c",
"type": "ui_group",
"name": "Kodi",
"tab": "2b3ed7f6.b24dc8",
"order": 3,
"disp": true,
"width": 8,
"collapse": false
},
{
"id": "2b3ed7f6.b24dc8",
"type": "ui_tab",
"name": "Wetter - Smarthome - Kodi",
"icon": "star",
"order": 1,
"disabled": false,
"hidden": false
}
]
Alles anzeigen
Im Flow HTTP Request muss noch die IP(in der Anforderung) sowie die Logindaten für Kodi im Basic Auth ergänzt werden.Diese legt man bei Kodi in Einstellungen -> Dienste -> Steuerung fest.
Im Flow Server Pingen die IP von euren Mediacenter rein.
Damit geh ich sicher das keine unnötigen Abfragen an der Server gestellt werden welche dann zu "unreachable" Meldungen im Log führen würden.
Wenn ich mal Music Content mit drin habe wird das hier angepasst.
Viel Spaß.