[{"id":"18c0caa.fe73f35","type":"tcp in","server":"client","host":"172.16.130.254","port":"1012","datamode":"stream","datatype":"buffer","newline":" \\n","topic":"FritzBox Telnet Calls","name":"tcp: ### IP ADRESSE FritzBox ANPASSEN ###","base64":false,"x":262,"y":250,"z":"64b98f40.9b467","wires":[["fc1188c1.03ee78"]]},{"id":"a9d14156.562ec","type":"comment","name":"FRITZ!box Anrufernummer, RING, Anruferliste (doppelklick für mehr Infos)","info":"To work first you need to activate tcp port 1012 on your Fritz!Box by dialing #96*5*\n\nChange TCP node to point at IP address of router\n\n-----------------------------------------------------------------------------------------\n\nFür jede Call ID werden auf Wunsch (siehe KONFIGURATION) folgende Variablen angelegt:\n\n// [0] callid\t\t\t\t// eindeutige ID des aktuellen Rufes\n// [1] date\t\t\t\t\t// Datum Uhrzeit der Meldung in der Form: yy-mm-tt hh:mm:ss\n// [2] calltype\t\t\t\t// CALL, RING, CONNECT, DISCONNECT \n// [3] callingNumber\t\t// die anrufende Nummer\n// [4] calledNumber\t\t\t// die angerufene Nummer\n// [5] connectedNumber\t\t// Nummer mit der die Verbindung zustande gekommen ist\n// [6] intNumber\t\t\t// interne Nebenstelle\n// [7] line\t\t\t\t\t// Leitung: POTS, SIP0, ...\n// [8] connect\t\t\t\t// verbunden: true/false\n// [9] direction\t\t\t// Richtung: \"gehend\", \"kommend\"\n// [10] duration\t\t\t// Dauer der Verbindung in Sekunden\n// [11] dateStart\t\t\t// Datum Start Verbindungsaufbau\n// [12] dateConnect\t\t\t// Datum Verbindung\n// [13] dateEnd\t\t\t\t// Datum aufgelegt\n// [14] rufdauer\t\t\t//\n\nMit einem DISCONNECT ist ein Ruf/Gespräch vorbei.\nDie DISCONECT Variablen enthalten alle notwendigen Informationen für das Gespräch,\nda diese mit den vorherigen Zuständen ergänzt wurden.\n\n\n","x":332.1588134765625,"y":154.3294439315796,"z":"64b98f40.9b467","wires":[]},{"id":"eb0052b6.14ffb","type":"function","name":"Telnet: parse alle Meldungen","func":"//Name: Parse FritzBox Telnet\n//\n//Requirements:\n//- must be able to reach tcp port 1012 on your FB\n//- activate call monitor on FB by dialing #96*5*\n\ncontext.buff = context.buff || \"\"; // wenn es context.buff nicht gibt, anlegen mit \"\"\ncontext.buff = context.buff + msg.payload; // \n\nmsg.payload = context.buff;\ncontext.buff = \"\";\n\nreturn msg;\n","outputs":1,"valid":true,"x":713.1668701171875,"y":855.8333129882812,"z":"64b98f40.9b467","wires":[["fd012eba.02fed","b00b1c6e.4ff4e"]]},{"id":"fd606c94.029f9","type":"inject","name":"10.05.15 20:06:58;CALL;1;11;021147110815;08925006881;POTS;","topic":"","payload":"10.05.15 20:06:58;CALL;1;11;08947110815;021125006881;POTS;","payloadType":"string","repeat":"","crontab":"","once":false,"x":330.0001220703125,"y":2101.8335371017456,"z":"64b98f40.9b467","wires":[["b5b0eaea.4a4f18"]]},{"id":"5fe6f75c.a01908","type":"inject","name":"10.05.15 20:07:00;CONNECT;1;11;08925006881;","topic":"","payload":"10.05.15 20:07:00;CONNECT;1;11;08925006881;","payloadType":"string","repeat":"","crontab":"","once":false,"x":274.0001220703125,"y":2143.8335371017456,"z":"64b98f40.9b467","wires":[["b5b0eaea.4a4f18"]]},{"id":"5e8971fb.a1769","type":"inject","name":"10.05.15 20:07:07;DISCONNECT;1;2;","topic":"","payload":"10.05.15 20:07:07;DISCONNECT;1;2;","payloadType":"string","repeat":"","crontab":"","once":false,"x":236.0001220703125,"y":2189.8335371017456,"z":"64b98f40.9b467","wires":[["b5b0eaea.4a4f18"]]},{"id":"2f407b7c.d0bf84","type":"comment","name":"gehendes Gespräch Küche mit Verbindung","info":"","x":230.0001220703125,"y":2059.8335371017456,"z":"64b98f40.9b467","wires":[]},{"id":"e782a628.187d58","type":"function","name":"Terminiert alle Variablen + msg.topic = msg.topic + \"callid.\" + msg.callid +\".\";","func":"msg.topic = msg.topic + \"callid.\" + msg.callid +\".\";\nreturn msg;","outputs":1,"valid":true,"x":1145.5001182556152,"y":2061.333580970764,"z":"64b98f40.9b467","wires":[["49ff3c61.b600c4","9517dd27.6ae82","6e3dc70e.91c238","353a017e.cac5fe","d940ecf8.26bf1","e824b28f.17db5","d33c3253.2cc3d","9903b530.66fc48","aee7b8ea.511848","7b5ade2f.84a52","cccaf996.333508","5cbb3bdb.a344c4","32b1499e.cd4eb6","47913392.b86ecc","74407069.8bbf9","270d333e.d8f2cc","c876d75f.378928"]]},{"id":"12dbec10.ed2414","type":"inject","name":"10.05.15 20:06:58;RING;0;01713211545;022143238456;SIP0;","topic":"","payload":"10.05.15 20:06:58;RING;0;01713211545;022143238456;SIP0;","payloadType":"string","repeat":"","crontab":"","once":false,"x":345.0001220703125,"y":2339.8335371017456,"z":"64b98f40.9b467","wires":[["b5b0eaea.4a4f18"]]},{"id":"3bcb304a.c434d","type":"comment","name":"kommendes Gespr. 0173 zur Sipgate 0201, Nebenstelle 10 geht dran","info":"","x":315.0001220703125,"y":2299.8335371017456,"z":"64b98f40.9b467","wires":[]},{"id":"386af384.c7950c","type":"ioBroker out","name":"[Pfad aud der Konfig].[callid].*","topic":"","ack":"true","autoCreate":"true","x":2230.500171661377,"y":2181.666742324829,"z":"64b98f40.9b467","wires":[]},{"id":"49ff3c61.b600c4","type":"function","name":"[0] callid","func":"msg.payload = msg.callid;\nmsg.topic = msg.topic + \"callid\";\n\nif (msg.payload != null) return msg;\n\n","outputs":1,"valid":true,"x":1631.166763305664,"y":1845.0001525878906,"z":"64b98f40.9b467","wires":[["87304828.78cfb8"]]},{"id":"9517dd27.6ae82","type":"function","name":"[1] date","func":"msg.payload = msg.date;\nmsg.topic = msg.topic + \"date\";\n\nif (msg.payload != null) return msg;\n","outputs":1,"valid":true,"x":1632.166763305664,"y":1879.0001525878906,"z":"64b98f40.9b467","wires":[["87304828.78cfb8"]]},{"id":"6e3dc70e.91c238","type":"function","name":"[2] calltype","func":"\n\nmsg.payload = msg.calltype;\nmsg.topic = msg.topic + \"calltype\";\n\nif (msg.payload != null) return msg;\n","outputs":1,"valid":true,"x":1639.166763305664,"y":1913.0001525878906,"z":"64b98f40.9b467","wires":[["87304828.78cfb8"]]},{"id":"353a017e.cac5fe","type":"function","name":"[3] callingNumber","func":"\n\nmsg.payload = msg.callingNumber;\nmsg.topic = msg.topic + \"callingNumber\";\n\nif (msg.payload != null) return msg;\n","outputs":1,"valid":true,"x":1660.166763305664,"y":1945.0001525878906,"z":"64b98f40.9b467","wires":[["87304828.78cfb8"]]},{"id":"d940ecf8.26bf1","type":"function","name":"[4] calledNumber","func":"\nmsg.payload = msg.calledNumber;\nmsg.topic = msg.topic + \"calledNumber\";\n\nif (msg.payload != null) return msg;\n","outputs":1,"valid":true,"x":1661.166763305664,"y":1977.0001525878906,"z":"64b98f40.9b467","wires":[["87304828.78cfb8"]]},{"id":"e824b28f.17db5","type":"function","name":"[5] connectedNumber","func":"msg.payload = msg.connectedNumber;\nmsg.topic = msg.topic + \"connectedNumber\";\n\nif (msg.payload != null) return msg;\n","outputs":1,"valid":true,"x":1671.166763305664,"y":2009.0001525878906,"z":"64b98f40.9b467","wires":[["87304828.78cfb8"]]},{"id":"d33c3253.2cc3d","type":"function","name":"[6] intNumber","func":"\n\nmsg.payload = msg.intNumber;\nmsg.topic = msg.topic + \"intNumber\";\n\nif (msg.payload != null) return msg;\n","outputs":1,"valid":true,"x":1645.166763305664,"y":2041.0001525878906,"z":"64b98f40.9b467","wires":[["87304828.78cfb8"]]},{"id":"6ba5b8c5.945a48","type":"comment","name":"### todo ###","info":"Fehler:\n\n- cdr wird nicht mehr geschrieben, obwohl msg im Debug rauskommt\n- Anruferliste verpasst löscht nicht, wenn mann context.global löscht\n\n\nPrio 1:\n- Zähler verpasste Anrufe\n- Konfig: soll der Zähler verpasste Anrufe Nachts gelöscht werden?\n- Liste aktive Ring (über ein Array mit RING ID) \n- letzte aktiver RING\n- Liste aktive Gespräche (über ein Array mit CONECTION ID)\n- Email, verpasster Anruf\n- Pushover verpasster Anruf\n- Rufe nach einstellbarer Zeit aufräumen\n- Wert +/- Zeitunterschied konfigurierbar -> Flag\n- aktuelle Gespräche mit den bisher bekannten Infos darstellen.\n- \n\nPrio 2:\n- Gesprächsdauer in Sekunden aller aktiven Calls\n- verpasste Anrufer mit Zähler, Anrufe gleicher Tag (Anrufer als ARRAY, Löschen per CRON)\n- Komfortliste: erreichte Rufnr in der verpassten Liste nachträglich kennzeichnen\n- ring und aktive Calls nach voreingestellter Zeit bereinigen\n- Anruferliste als zusätzliches Objekt anlegen & eigene JSON Webausgabe\n- Alert bei zu großer Abweichung der Meldungszeit von der Systemzeit -> Log, Nachricht, Variable\n- \n\nPrio 3:\n- diverse Webservices (Abfragen, Rückmeldungen, z.B. Anruferliste, aktiver Call ,...)\n- Eigene Webseite über Node-Red für den Flow\n- Anruferlisten: alle (OK), geh, kom, verpasst (OK)\n- CDR Kommasepariert, alle Werte\n- CDR Anruferliste ASCII\n- CDR Anruferliste HTML\n- Zähler Connect, getrennt nach gehenden und kommenden Verbindungen\n- Neue HTML Formatierung für die Listen... rechts- / linksbündig, Zeilenfarbe, Linie zwischen den Zeilen, Schriftart, ggf. Templates zur Auswahl\n- kanonisches Format -> Pushover, Email\n- Telefonbuch aus Fritzbox\n- Ortsvorwahlen, Länderkennzahlen\n- Telefonbuch Webanbindung\n- Anruferlisten einzeln löschbar machen\n- Umbau: Anruferlisten immer in beiden Formaten ausgeben (Text und html)\n- \n\nerledigt:\n==========================================\n- Eintrag Anruferliste bei Disconnect\n- CDRs als JSON\n- Aktiver RING j/n\n- Zähler: Anzahl aktiver RINGS\n- Anzeige der aktiven Gespräche (CONNECT)\n- Zähler: Anzahl aktiver Calls\n- Anruferliste verpasst als Liste\n- Anruferliste gesamt als Liste\n- Anruferlisten Länge konfigurierbar machen\n- Anruferliste html mit Überschriftspalte\n- !!! von msg.config auf global.context umbauen\n- Zähler: aktive Rufaufbau\n- String externe Rufnummern auf die eingestellte Länge kürzen\n- Berechnung der Rufdauer\n- Vergleich aktuelle Zeit System Timestamp, Zeit aus Fritzbox und (NTP Internet -> ntp nicht realisiert) - Liste verpasste Anrufe\n-\n","x":377.33333587646484,"y":189.33331775665283,"z":"64b98f40.9b467","wires":[]},{"id":"9903b530.66fc48","type":"function","name":"[7] line","func":"\n\nmsg.payload = msg.line;\nmsg.topic = msg.topic + \"line\";\n\nif (msg.payload != null) return msg;\n","outputs":1,"valid":true,"x":1629.166763305664,"y":2075.0001525878906,"z":"64b98f40.9b467","wires":[["87304828.78cfb8"]]},{"id":"aee7b8ea.511848","type":"function","name":"[8] connect","func":"\n\nmsg.payload = msg.connect;\nmsg.topic = msg.topic + \"connect\";\n\nif (msg.payload != null) return msg;\n","outputs":1,"valid":true,"x":1643.166763305664,"y":2107.0001525878906,"z":"64b98f40.9b467","wires":[["87304828.78cfb8"]]},{"id":"7b5ade2f.84a52","type":"function","name":"[9] direction","func":"\nmsg.payload = msg.direction;\nmsg.topic = msg.topic + \"direction\";\n\nreturn msg;\n","outputs":1,"valid":true,"x":1643.166763305664,"y":2139.0001525878906,"z":"64b98f40.9b467","wires":[["87304828.78cfb8"]]},{"id":"cccaf996.333508","type":"function","name":"[10] duration","func":"\n\nmsg.payload = msg.duration;\nmsg.topic = msg.topic + \"duration\";\n\nif (msg.payload != null) return msg;\n","outputs":1,"valid":true,"x":1645.166763305664,"y":2171.0001525878906,"z":"64b98f40.9b467","wires":[["87304828.78cfb8"]]},{"id":"5cbb3bdb.a344c4","type":"function","name":"[11] dateStart","func":"\n\nmsg.payload = msg.dateStart;\nmsg.topic = msg.topic + \"dateStart\";\n\nif (msg.payload != null) return msg;\n","outputs":1,"valid":true,"x":1646.8333892822266,"y":2201.0000915527344,"z":"64b98f40.9b467","wires":[["87304828.78cfb8"]]},{"id":"32b1499e.cd4eb6","type":"function","name":"[12] dateConnect","func":"\n\nmsg.payload = msg.dateConnect;\nmsg.topic = msg.topic + \"dateConnect\";\n\nif (msg.payload != null) return msg;\n","outputs":1,"valid":true,"x":1658.5001029968262,"y":2234.3334426879883,"z":"64b98f40.9b467","wires":[["87304828.78cfb8"]]},{"id":"47913392.b86ecc","type":"function","name":"[13] dateEnd","func":"\n\nmsg.payload = msg.dateEnd;\nmsg.topic = msg.topic + \"dateEnd\";\n\nif (msg.payload != null) return msg;\n","outputs":1,"valid":true,"x":1646.833396911621,"y":2267.666757583618,"z":"64b98f40.9b467","wires":[["87304828.78cfb8"]]},{"id":"74407069.8bbf9","type":"function","name":"[14] rufdauer","func":"\n\nmsg.payload = msg.rufdauer;\nmsg.topic = msg.topic + \"rufdauer\";\n\n\nif (msg.payload != null) return msg;\n","outputs":1,"valid":true,"x":1650.1666946411133,"y":2334.3333415985107,"z":"64b98f40.9b467","wires":[["87304828.78cfb8"]]},{"id":"87304828.78cfb8","type":"function","name":"terminiert alle Variablen","func":"\n\t\n// Variablennamen und -inhalt in ioBroker schreiben\nreturn msg;\n","outputs":1,"valid":true,"x":2334.8336143493652,"y":2069.666750907898,"z":"64b98f40.9b467","wires":[["bdcbbd6d.42344","f799849c.086678"]]},{"id":"569b57d1.a964a8","type":"debug","name":"","active":false,"console":"false","complete":"false","x":2466.5,"y":2183.000232696533,"z":"64b98f40.9b467","wires":[]},{"id":"bdcbbd6d.42344","type":"switch","name":"(1)(2) kein Inhalt/Änderung (3) neuer Inhalt","property":"payload","rules":[{"t":"eq","v":"undifined"},{"t":"null"},{"t":"else"}],"checkall":"true","outputs":3,"x":2266.499973297119,"y":2121.3335304260254,"z":"64b98f40.9b467","wires":[[],[],["569b57d1.a964a8","386af384.c7950c"]]},{"id":"270d333e.d8f2cc","type":"function","name":"[11] dateStart","func":"//var datum = msg.payload;\nvar datum = msg.date;\n//dd.mm.yy hh:mm:ss\n//01234567890123456\n\nvar jahr = \"20\" + datum.substring(6,8);\nvar monat = datum.substring(3,5);\nvar monatJS = parseInt(datum.substring(3,5))-1;\nvar tag = datum.substring(0,2);\nvar stunde = datum.substring(9,11);\nvar minute = datum.substring(12,14);\nvar sekunde = datum.substring(15,17);\n\n\n\n\n\n\nvar zeit = new Date(jahr,monatJS,tag,stunde,minute,sekunde);\nvar tst = Date.parse(zeit); // Zeit aus der Meldung in Epoche\nvar now = new Date(); \nnow = Date.parse(now);// aktuelle Zeit in Epoche\n\nmsg.payload = zeit + \" \" + tst + \" \" + now;\nmsg.topic = msg.topic + \"testDatum\";\n\n//msg.payload = jahr+monat+tag+stunde+minute+sekunde;\nreturn msg;","outputs":1,"valid":true,"x":2052.5001182556152,"y":2531.333254814148,"z":"64b98f40.9b467","wires":[["89cd4f49.7632b"]]},{"id":"89cd4f49.7632b","type":"debug","name":"","active":false,"console":"false","complete":"false","x":2330.1668586730957,"y":2517.6668395996094,"z":"64b98f40.9b467","wires":[]},{"id":"4ed4b1d9.b12b5","type":"ioBroker out","name":"[Pfad aus der Konfig].*","topic":"","ack":"true","autoCreate":"true","x":1159.6667938232422,"y":927.1665878295898,"z":"64b98f40.9b467","wires":[]},{"id":"fd012eba.02fed","type":"function","name":"Meldungen in Objekten umbauen & Topic=Call ID","func":"// es wird für jeden der vier calltype das Objekt mit allen 14 Werten zusammengebaut,\n// damit die Nachricht im Objekt zu jeder Zeit synchron ist\n// Werte, die aus vorherigen Nachrichten übernommen werden, werden aus\n// global.context.fbVars[] impoertiert (fbVars = fritzboxVariablen)\n\nmess \t= msg.payload; \t\t// die geparste Meldung aus dem tcp Stream als Ganzes\nslices \t= mess.split(\";\"); \t// speichert die Felder der Meldung in ein Array mit dem Namen \"slices\"\n\n// die Call ID wird als erstes ausgelesen, da diese für die eindeutige Zuordnung\n// der Werte zum richtigen Call benötigt wird (es kann mehrere Calls parallel geben)\nmsg.callid\t\t= slices[2]; // an dritter Stelle steht die CallID (Zurordnung zum aktuellen Ruf)\n\nvar callid\t = msg.callid; // für das Array global.context.fbVars.callid[callid]\n\n\ncontext.global.fbVars = context.global.fbVars || {}; // wenn es das Objekt context.global.fbVars noch nicht gibt, wird dieses hier leer angelegt\n// Umbau der Variablen in ein Array\ncontext.global.fbVars.callid = context.global.fbVars.callid || [];\ncontext.global.fbVars.callid[msg.callid] = context.global.fbVars.callid[msg.callid] || {};\n\n\nfunction fritboxZeitEpoche(datum) {\nvar jahr = \"20\" + datum.substring(6,8);\nvar monat = datum.substring(3,5);\nvar monatJS = parseInt(datum.substring(3,5))-1;\nvar tag = datum.substring(0,2);\nvar stunde = datum.substring(9,11);\nvar minute = datum.substring(12,14);\nvar sekunde = datum.substring(15,17);\n\nvar zeit = new Date(jahr,monatJS,tag,stunde,minute,sekunde);\nvar epoche = Date.parse(zeit) / 1000; // Zeit aus der Meldung in Epoche\n \nreturn epoche;\n} \n\n\n// [0]callid\ncontext.global.fbVars.callid[callid].callid = msg.callid;\n// [1]date\nmsg.date \t\t= slices[0]; // an erster Stelle steht immer das Datum in der Form: 10.05.15 20:06:58\ncontext.global.fbVars.callid[callid].date = msg.date;\n\n// [2]calltype\nmsg.calltype \t= slices[1]; // an zweiter Stelle steht der Ruftyp (CALL, RING, CONNECT, DISCONECT)\ncontext.global.fbVars.callid[callid].calltype = msg.calltype;\n\n\n\n// die restlichen Stellen der Message sind je nach calltype mit unterschiedlichlichen Variablen belegt. \n\n\n\n// ######## RING ######## (kommendes Gespräch = Ruf)\n\nif (msg.calltype == \"RING\") {\n\n// [3]callingNumber\n\tif (slices[3] === \"\") { // keine Rufnummer -> \"Nummer unterdrückt\"\n\t\tmsg.callingNumber = context.global.fbVars.config.rnr_unbekannt;\n\t\t} else {\n\t\tmsg.callingNumber = slices[3];\n\t\t}\n\tcontext.global.fbVars.callid[callid].callingNumber = msg.callingNumber;\n\n\t\n// [4]calledNumber\n\tmsg.calledNumber = slices[4];\n\tcontext.global.fbVars.callid[callid].calledNumber = msg.calledNumber;\n\n\n// [5]connectedNumber\n\tmsg.connectedNumber = \"\"; // im Zustand Call gibt es keine Connected, diese wird hier gelöscht\n\tcontext.global.fbVars.callid[callid].connectedNumber = msg.connectedNumber;\n\n\n// [6]intNumber\n\tmsg.intNumber = \"\";\n\tcontext.global.fbVars.callid[callid].intNumber = msg.intNumber;\n\n\n// [7]line\n\tmsg.line = slices[5];\n\tcontext.global.fbVars.callid[callid].line = msg.line;\n\n\n// [8]connect (Info anhand der Ruftyps selbst erstellt)\n\tmsg.connect = false;\n\tcontext.global.fbVars.callid[callid].connect = msg.connect;\n\n// [9]direction (Info anhand der Ruftyps selbst erstellt)\n\tmsg.direction = \"kommend\";\n\tcontext.global.fbVars.callid[callid].direction = msg.direction;\n\n\n// [10]duration\n\tmsg.duration = 0;\n\tcontext.global.fbVars.callid[callid].duration = msg.duration;\n\n\n// [11]dateStart\n\tmsg.dateStart = msg.date;\n\tcontext.global.fbVars.callid[callid].dateStart = msg.dateStart;\n\n\n// [12]dateConnect\n\tmsg.dateConnect = \"\";\n\tcontext.global.fbVars.callid[callid].dateConnect = msg.dateConnect;\n\n\n// [13]dateEnd\n\tmsg.dateEnd = \"\";\n\tcontext.global.fbVars.callid[callid].dateEnd = msg.dateEnd;\n\n\n// [14]rufdauer\n\tmsg.rufdauer = \"\";\n\tcontext.global.fbVars.callid[callid].rufdauer = msg.rufdauer;\n\n// [15]deltaZeitMeldungSystemSek\n var tst = fritboxZeitEpoche(msg.date);\n var now = new Date(); \n now = Date.parse(now) / 1000;// aktuelle Zeit in Epoche\n msg.deltaZeitMeldungSystemSek = tst - now;\n\tcontext.global.fbVars.callid[callid].deltaZeitMeldungSystemSek = msg.deltaZeitMeldungSystemSek;\n\t}\n\n\n\n\n\n// ######## CALL ######## (gehendes Gespräch)\n\nif (msg.calltype == \"CALL\") {\n\n// [3]callingNumber\n\tif (slices[4] === \"\") { // keine Rufnummer -> \"Nummer unterdrückt\"\n\t\tmsg.callingNumber = context.global.fbVars.config.rnr_unbekannt;\n\t\t} else {\n\t\tmsg.callingNumber = slices[4];\n\t\t}\n\tcontext.global.fbVars.callid[callid].callingNumber = msg.callingNumber;\n\n\n// [4]calledNumber\n\tmsg.calledNumber = slices[5];\n\tcontext.global.fbVars.callid[callid].calledNumber = msg.calledNumber;\n\n// [5]connectedNumber\n\tmsg.connectedNumber = \"\";\n\tcontext.global.fbVars.callid[callid].connectedNumber = msg.connectedNumber;\n\n// [6]intNumber\n\tmsg.intNumber = slices[3];\n\tcontext.global.fbVars.callid[callid].intNumber = msg.intNumber;\n\n// [7]line\n\tmsg.line = slices[6];\n\tcontext.global.fbVars.callid[callid].line = msg.line;\n\n\n// [8]connect (Info anhand der Ruftyps selbst erstellt)\n\tmsg.connect = false;\n\tcontext.global.fbVars.callid[callid].connect = msg.connect;\n\n// [9]direction (Info anhand der Ruftyps selbst erstellt)\n\tmsg.direction = \"gehend\";\t\n\tcontext.global.fbVars.callid[callid].direction = msg.direction;\n\n// [10]duration\n\tmsg.duration = 0;\n\tcontext.global.fbVars.callid[callid].duration = msg.duration;\n\n// [11]dateStart\n\tmsg.dateStart = msg.date;\n\tcontext.global.fbVars.callid[callid].dateStart = msg.dateStart;\n\n// [12]dateConnect\n\tmsg.dateConnect = \"\";\n\tcontext.global.fbVars.callid[callid].dateConnect = msg.dateConnect;\n\n// [13]dateEnd\n\tmsg.dateEnd = \"\";\n\tcontext.global.fbVars.callid[callid].dateEnd = msg.dateEnd;\n\n// [14]rufdauer\n\tmsg.rufdauer = \"\";\n\tcontext.global.fbVars.callid[callid].rufdauer = msg.rufdauer;\n// [15]deltaZeitMeldungSystemSek\n var tst = fritboxZeitEpoche(msg.date);\n var now = new Date(); \n now = Date.parse(now) / 1000;// aktuelle Zeit in Epoche\n msg.deltaZeitMeldungSystemSek = tst - now;\n\tcontext.global.fbVars.callid[callid].deltaZeitMeldungSystemSek = msg.deltaZeitMeldungSystemSek;\n\t}\n\n\n\n\n// ######## CONNECT ######## (verbundens Gespräch)\n\nif (msg.calltype == \"CONNECT\") {\n\n// [3]callingNumber\n\tmsg.callingNumber = context.global.fbVars.callid[callid].callingNumber;\n// [4]calledNumber\n\tmsg.calledNumber = context.global.fbVars.callid[callid].calledNumber;\n// [5]connectedNumber\n\tif (slices[4] === \"\") {\n\t\tmsg.connectedNumber = context.global.fbVars.config.rnr_unbekannt;\n\t\t} else {\n\t\tmsg.connectedNumber = slices[4];\n\t\t}\n\tcontext.global.fbVars.callid[callid].connectedNumber = msg.connectedNumber;\n// [6]intNumber\n\tmsg.intNumber = slices[3];\n\tcontext.global.fbVars.callid[callid].intNumber = msg.intNumber;\n// [7]line\n\tmsg.line = context.global.fbVars.callid[callid].line;\n// [8]connect (Info anhand der Ruftyps selbst erstellt)\n\tmsg.connect = true;\n\tcontext.global.fbVars.callid[callid].connect = msg.connect;\n// [9]direction (Info anhand der Ruftyps selbst erstellt)\n\tmsg.direction = context.global.fbVars.callid[callid].direction;\n// [10]duration\n\tmsg.duration = context.global.fbVars.callid[callid].duration;\n// [11]dateStart\n\tmsg.dateStart = context.global.fbVars.callid[callid].dateStart;\n// [12]dateConnect\n\tmsg.dateConnect = msg.date;\n\tcontext.global.fbVars.callid[callid].dateConnect = msg.dateConnect;\n// [13]dateEnd\n\tmsg.dateEnd = context.global.fbVars.callid[callid].dateEnd;\n// [14]rufdauer\n var zeitConnectEpoche = fritboxZeitEpoche(msg.date);\n var zeitStartEpoche = fritboxZeitEpoche(msg.dateStart);\n\tmsg.rufdauer = zeitConnectEpoche - zeitStartEpoche; \n\tcontext.global.fbVars.callid[callid].rufdauer = msg.rufdauer;\n// [15]deltaZeitMeldungSystemSek\n var tst = fritboxZeitEpoche(msg.date);\n var now = new Date(); \n now = Date.parse(now) / 1000;// aktuelle Zeit in Epoche\n msg.deltaZeitMeldungSystemSek = tst - now;\n\tcontext.global.fbVars.callid[callid].deltaZeitMeldungSystemSek = msg.deltaZeitMeldungSystemSek;\n\t}\n\n\n\n// ######## DISCONNECT ######## (beendetes Gespräch / Gesprächsversuch)\n\n// wenn der Flow während eines aktiven Gesprächs gestartet wird,\n// sind diverse Zustände nicht bekannt. Diese werden hier abgefangen.\n\nif (msg.calltype == \"DISCONNECT\") {\n// [3]callingNumber\n\tmsg.callingNumber = context.global.fbVars.callid[callid].callingNumber;\n\tif (msg.callingNumber == null) { msg.callingNumber = \"????????????\"; }\n// [4]calledNumber\n\tmsg.calledNumber = context.global.fbVars.callid[callid].calledNumber;\n\tif (msg.calledNumber == null) {\tmsg.callingNumber = \"????????????\";\t}\n// [5]connectedNumber\n\tmsg.connectedNumber = context.global.fbVars.callid[callid].connectedNumber;\n\tif (msg.connectedNumber == null) { msg.connectedNumber = \"????????????\"; }\n// [6]intNumber\n\tmsg.intNumber = context.global.fbVars.callid[callid].intNumber;\n\tif (msg.intNumber == null) { msg.intNumber = \"??\"; }\n// [7]line\n\tmsg.line = context.global.fbVars.callid[callid].line;\n\tif (msg.line == null) { msg.line = \"????\"; }\n// [8]connect (Info anhand der Ruftyps selbst erstellt)\n\tmsg.connect = context.global.fbVars.callid[callid].connect;\n\tif (msg.connect == null) { msg.connect = true }\t\t\t\t\t// undefinierter Zustand, wenn der Flow im aktiven Gespräch gestartet wird (Annahme: Gespräch, da wahrscheinlicher (dauert in der Regel länger als ein Rufzustand))\n// [9]direction (Info anhand der Ruftyps selbst erstellt)\n\tmsg.direction = context.global.fbVars.callid[callid].direction;\n\tif (msg.direction == null) { msg.direction = \"??????\" }\t\t\t// undefinierter Zustand (gehend oder kommend nicht bekannt, wenn der Flow im aktiven Gespräch gestartet wird)\n// [10]duration\n\tmsg.duration = slices[3];\n\tcontext.global.fbVars.callid[callid].duration = msg.duration;\n// [11]dateStart\n\tmsg.dateStart = context.global.fbVars.callid[callid].dateStart;\n\tif (msg.dateStart == null) { msg.dateStart = msg.date; }\n// [12]dateConnect\n\tmsg.dateConnect = context.global.fbVars.callid[callid].dateConnect;\n\tif (msg.dateConnect == null) { msg.dateConnect = msg.date; }\n// [13]dateEnd\n\tmsg.dateEnd = msg.date;\n\tcontext.global.fbVars.callid[callid].dateEnd = msg.dateEnd;\n// [14]rufdauer\n\tmsg.rufdauer = context.global.fbVars.callid[callid].rufdauer;\n\tif (msg.rufdauer == null) { msg.rufdauer = 0; }\n// [15]deltaZeitMeldungSystemSek\n var tst = fritboxZeitEpoche(msg.date);\n var now = new Date(); \n now = Date.parse(now) / 1000;// aktuelle Zeit in Epoche\n msg.deltaZeitMeldungSystemSek = tst - now;\n\t}\n\n\n\n\n// ###########################\n\n//Variablen Call ID\n// msg.topic = msg.topic + \"callid.\" + msg.callid +\".\";\n\nmsg.config = {};\nmsg.config.callid_anlegen = context.global.fbVars.config.callid_anlegen;\nmsg.config.cdr_to_disk = context.global.fbVars.config.cdr_to_disk;\n\nif (msg.callid) return msg; // wenn Callid != null, dann weiter","outputs":1,"valid":true,"x":846.0001831054688,"y":1304.5,"z":"64b98f40.9b467","wires":[["c6b6e5b8.394918","857f6000.7a80a","2de38359.d21c7c","e8902f7.f176fd","fe485bb3.01b7a8"]]},{"id":"121d2e9d.ede2d1","type":"inject","name":"","topic":"","payload":"12.05.15 19:09:51","payloadType":"string","repeat":"","crontab":"","once":false,"x":1715.1668434143066,"y":2524.3336811065674,"z":"64b98f40.9b467","wires":[["270d333e.d8f2cc"]]},{"id":"fc1188c1.03ee78","type":"function","name":"### KONFIGURATION ###","func":"context.global.fbVars = context.global.fbVars || {}; // wenn es das Objekt context.global.fbVars noch nicht gibt, wird dieses hier leer angelegt\n\ncontext.global.fbVars.config = {\n\n \ttopic_prefix: \"node-red.0.fritzbox.\",\t// Pfad unter dem die Daten in ioBroker gespeichert werden sollen\n\tcallid_anlegen:true,\t\t\t\t\t// (false/true, default: false) für jede Call ID die Werte in node-red.0. anlegen, weitere Verarbeitung in ioBroker möglich\n\tcdr_to_disk:true,\t\t\t\t\t\t// (false/true default:false) schreib CDRs (Call Detail Records auf Disk), gespeichert unter: /opt/iobroker/fritzbox-cdr.txt\n\n\n// rnr_unbekannt: \"rnr unbekannt\", \t\t// Text, wenn die Rufnummer unbekannt/unterdrückt ist (auf die Länge achten)\n rnr_unbekannt: \"### ? ###\",\t\t \t\t// Text, wenn die Rufnummer unbekannt/unterdrückt ist (auf die Länge achten)\n \n \tlänge_ext_rnr: 15,\t\t\t\t\t\t// (default: 15) Anzeige: max. Länge externe Rufnummern (der Rest wird abgeschnitten)\n \n // Formatierung der Anruferliste per html (Festbreitenschrift und Farbe)\n html:true,\t\t\t\t\t\t\t\t// (true/false, default:true) Anruferlisten in html formatieren\n fontsize:\"14px\",\t\t\t\t\t\t// (default:\"14px\") Schriftgröße\n \n\t// welche Daten sollen in den Anruferlisten angezeigt werden\n\t// alle Anruferlisten:\n anz_datum:true,\t\t\t\t\t\t\t// true: Spalte Datum im Format\t\tmm.dd.\t(Format kann im Node einfach geändert werden)\n anz_uhrzeit:true,\t\t\t\t\t\t// true: Spalte Uhrzeit im Format\thh:dmm\t(Format kann im Node einfach geändert werden)\n\n\t// nur in der Gesamtliste:\n\tanz_int_rnr:true,\t\t\t\t\t\t// true: Spalte für die interne Rufnummer beim verbundenen Gespräch\n\tanz_eigenes_amt:true,\t\t\t\t\t// true: Spalte für die eigenen verwendeten Amtsrufnummer\n\tanz_line:true,\t\t\t\t\t\t\t// true: Spalte für die Art des Amts (POTS, SIP0, usw.)\n\tanz_duration:true, // true: Spalte für die Dauer des Gespräches in mm:ss\n \n anz_anzahl_zeilen:10, // (default: 10) Anzahl Zeilen in den Anruferlisten\n\n anz_kopfzeile:true // (default: true) Kopfzeile für die Anruferliste ausgeben\n};\n\n\n\n\n\nmsg.topic = context.global.fbVars.config.topic_prefix;\n\nreturn msg;\n","outputs":1,"valid":true,"x":250.33328247070312,"y":324.66668701171875,"z":"64b98f40.9b467","wires":[["eb0052b6.14ffb"]]},{"id":"c6b6e5b8.394918","type":"switch","name":"(1) RING (2) CALL (3) CONNECT (4) DISCONNECT","property":"calltype","rules":[{"t":"eq","v":"RING"},{"t":"eq","v":"CALL"},{"t":"eq","v":"CONNECT"},{"t":"eq","v":"DISCONNECT"}],"checkall":"true","outputs":4,"x":1021.5237121582031,"y":1223.6430282592773,"z":"64b98f40.9b467","wires":[["e0a48df0.1f5b7","12d69775.ed2969"],["3fb9047b.c046fc"],["15e40c04.ea1bf4","e0057d0f.1ffa8","3fb9047b.c046fc"],["6b0f2598.94f0dc","b2710ffd.4d8ef","15e40c04.ea1bf4","e0057d0f.1ffa8","3fb9047b.c046fc"]]},{"id":"6b0f2598.94f0dc","type":"function","name":"DISCONNECT: Werte für Rufliste (1) alle, (2) verpasst","func":"// [0] callid\t\t\t\t// eindeutige ID des aktuellen Rufes\n// [1] date\t\t\t\t\t// Datum Uhrzeit der Meldung in der Form: yy-mm-tt hh:mm:ss\n// [2] calltype\t\t\t\t// CALL, RING, CONNECT, DISCONNECT \n// [3] callingNumber\t\t// die anrufende Nummer\n// [4] calledNumber\t\t\t// die angerufene Nummer\n// [5] connectedNumber\t\t// Nummer mit der die Verbindung zustande gekommen ist\n// [6] intNumber\t\t\t// interne Nebenstelle\n// [7] line\t\t\t\t\t// Leitung: POTS, SIP0, ...\n// [8] connect\t\t\t\t// verbunden: true/false\n// [9] direction\t\t\t// Richtung: \"gehend\", \"kommend\"\n// [10] duration\t\t\t// Dauer der Verbindung in Sekunden\n// [11] dateStart\t\t\t// Datum Start Verbindungsaufbau\n// [12] dateConnect\t\t\t// Datum Verbindung\n// [13] dateEnd\t\t\t\t// Datum aufgelegt\n// [14] rufdauer\t\t\t// \n\n\n\nfunction fill(n) {\n\tvar empty_chars = \"\";\n\tfor(var i = 0; i < n; ++i)\n\tempty_chars += \" \";\n\treturn(empty_chars);\n\t}\n\n\nfunction fill0(n) {\n\tvar empty_chars = \"\";\n\tfor(var i = 0; i < n; ++i)\n\tempty_chars += \"0\";\n\treturn(empty_chars);\n\t}\n\n\nvar anruferliste = \"\";\nvar anruferlisteKopf = \"\";\nvar verpasst =\"\";\nvar verpasstKopf =\"\";\n\nvar externeNummer = \"\";\nvar externeNummerKopf = \"ext. Rufnr.\";\nvar verbindungssymbol = \"\";\nvar eigenesAmt = \"\";\nvar eigenesAmtKopf = \"Eigenes Amt\";\nvar line = msg.line;\nvar lineKopf = \"Ltg.\";\nvar intNummer = msg.intNumber;\nvar intNummerKopf = \"Nbst\";\n\nvar duration = \"\";\nvar durationKopf = \"Dauer\"\n\nvar durationMin = Math.floor(parseInt(msg.duration) / 60);\nvar durationSek = parseInt(msg.duration) % 60;\n\n\n// css\nif (context.global.fbVars.config.html === true) {\n//\tvar cssstart = '';\n\tvar cssstart = '';\n\tvar cssend = \"\";\n\tvar cssba = \"\";\n\tvar cssbe = \"\";\n\tvar cssrea = '';\n\tvar cssgra = '';\n\t} else {\n\tvar cssstart = \"\";\n\tvar cssend = \"\";\n\tvar cssba = \"\";\n\tvar cssbe = \"\";\n\tvar cssrea = \"\";\n\tvar cssgra = \"\";\n\t}\n\t\n\n\tvar zeitstempel = msg.dateStart; // Zeit des RING\n\n\tvar jahr = zeitstempel.substring(6,8);\n\tvar monat = zeitstempel.substring(3,5);\n\tvar tag = zeitstempel.substring(0,2);\n\tvar stunde = zeitstempel.substring(9,11);\n\tvar minute = zeitstempel.substring(12,14);\n\tvar sekunde = zeitstempel.substring(15,17);\n\n\t//var uhrzeit = stunde + \":\" + minute + \":\"+ sekunde + \" \";\n\tvar uhrzeit = stunde + \":\" + minute + \" \";\n var uhrzeitKopf = \"Zeit  \";\n\n\t//var datum = tag + \".\" + monat + \".20\" + jahr + \" \";\n\t//var datum = tag + \".\" + monat + \".\" + jahr + \" \";\n\tvar datum = tag + \".\" + monat + \". \";\n var datumKopf = \"Tag    \";\n// duration = durationMin + \":\" + fill(2 - durationSek.length);\n\nduration = durationMin + \":\" + fill0(2- durationSek.toString().length) + durationSek;\nduration = fill(5 - duration.length) + duration;\n\n\n\n// Felder rausfiltern, die laut Konfig nicht angezeigt werden sollen\n\nif (context.global.fbVars.config.anz_datum === true) {\n\t} else {\n\tdatum = \"\";\n\tdatumKopf = \"\";\n\t}\n\nif (context.global.fbVars.config.anz_uhrzeit === true) {\n\t} else {\n\tuhrzeit = \"\";\n\tuhrzeitKopf = \"\";\n\t}\n\nif (context.global.fbVars.config.anz_duration === true) {\n\t} else {\n\tduration = \"\";\n\tdurationKopf = \"\";\n\t}\n\n\n\n\n// externe Rufnummer & Verbindungssymbol\nif (msg.direction == \"gehend\") {\n\t\teigenesAmt = msg.callingNumber;\n\tif (msg.connect === true) {\n\t\texterneNummer = msg.connectedNumber;\n\t\tverbindungssymbol = cssgra + \"<<- \" + cssend;\n\t\t} else {\n\t\texterneNummer = msg.calledNumber;\n\t\tverbindungssymbol = cssrea + \"X<- \" + cssend;\n\t\t}\n\t} else if (msg.direction == \"kommend\"){\n\t\teigenesAmt = msg.calledNumber;\n\tif (msg.connect === true) {\n\t\texterneNummer = msg.connectedNumber;\n\t\tverbindungssymbol = cssgra + \" ->>\" + cssend;\n\t\t} else {\n\t\texterneNummer = msg.callingNumber;\n\t\tverbindungssymbol = cssrea + \" ->X\" + cssend;\n\t\t}\n\t} else { // Flow startet im aktivem Gespräch: Richtung gehend oder kommend unbekannt\n\t\n\texterneNummer = msg.connectedNumber; \t// Flow startet in einem aktiven Call: Anrufernummer -> unbekannt, oder, wenn im Connect eingestiegen wurde: connectedNumber\n\tverbindungssymbol = \"???? \";\t \t// Flow startet in einem aktiven Call: Symbol \"????\", ohne Farbe\n\teigenesAmt = msg.callingNumber; \t\t// Flow startet in einem aktiven Call: eigenes Amt -> unbekannt\n\t}\n\n\n// sollte die externen Rufnummern insgesamt länger sein, werden diese auf die max. gewünschte Länge gekürzt\nexterneNummer = externeNummer.substring(0,context.global.fbVars.config.länge_ext_rnr);\nexterneNummerKopf = externeNummerKopf.substring(0,context.global.fbVars.config.länge_ext_rnr);\neigenesAmtKopf = eigenesAmtKopf.substring(0,context.global.fbVars.config.länge_ext_rnr);\n\n\n// Amtsrufnummern (externe und eigene) auf gewünschte Länge mit Leerzeichen auffüllen \nexterneNummer = externeNummer + fill(context.global.fbVars.config.länge_ext_rnr - externeNummer.length);\nexterneNummerKopf = externeNummerKopf + fill(context.global.fbVars.config.länge_ext_rnr - externeNummerKopf.length);\nintNummer = fill(5 - intNummer.length) + intNummer;\nintNummerKopf = fill(5 - intNummerKopf.length) + intNummerKopf;\neigenesAmt = eigenesAmt + fill(context.global.fbVars.config.länge_ext_rnr - eigenesAmt.length);\neigenesAmtKopf = eigenesAmtKopf + fill(context.global.fbVars.config.länge_ext_rnr - eigenesAmtKopf.length);\nline = line + fill(5 - intNummer.length)+ \" \";\nlineKopf = lineKopf + fill(5 - intNummer.length)+ \" \";\n\n\n\n// Felder rausfiltern, die laut Konfig nicht angezeigt werden sollen\n\t\nif (context.global.fbVars.config.anz_int_rnr === true) {\n\t} else {\n\tintNummer =\"\";\n\tintNummerKopf =\"\";\n\t}\n\nif (context.global.fbVars.config.anz_eigenes_amt === true) {\n\t} else {\n\teigenesAmt =\"\";\n\teigenesAmtKopf =\"\";\n\t}\n\nif (context.global.fbVars.config.anz_line === true) {\n\t} else {\n\tline =\"\";\n\tlineKopf = \"\";\n\t}\n\n\n\n// Ausgabe alle Arten von Anrufen\n// =================================\nanruferliste = cssstart + datum + uhrzeit + externeNummer + cssba + verbindungssymbol + cssbe \n\t\t\t + intNummer + \" \" + eigenesAmt + line + duration + cssend;\n\nanruferlisteKopf = cssstart + cssba + datumKopf + uhrzeitKopf + externeNummerKopf + \"g<>k\" \n\t\t\t + intNummerKopf + \" \" + eigenesAmtKopf + lineKopf + durationKopf + cssbe + cssend;\n\n\n// Ausgabe der verpassten kommenden Anrufe\n// =================================\nif (msg.direction == \"kommend\") {\n if (msg.connect == false) {\n\t verpasstKopf = cssstart + cssba + datumKopf + uhrzeitKopf + \" \" + externeNummerKopf + cssbe + cssend;\n\t verpasst = cssstart + datum + uhrzeit + \" \" + externeNummer + cssend;\n } else {\n\t verpasst = \"nichts\";\n\t }\n\t} else {\n verpasst = \"nichts\";\n }\n\n\n\nvar msg1 = {};\nvar msg2 = {};\n\nmsg1.topic = msg.topic + \"ruflisten.alleLetzterEintrag\";\nmsg2.topic = msg.topic + \"ruflisten.verpasstLetzterEintrag\";\n\nmsg1.payload = anruferliste;\nmsg2.payload = verpasst;\n\nmsg1.anruferlisteKopf = anruferlisteKopf;\nmsg2.verpasstKopf = verpasstKopf;\n\nreturn [msg1,msg2];\n","outputs":"2","valid":true,"x":1572.7620849609375,"y":1350.619276046753,"z":"64b98f40.9b467","wires":[["511d6cee.aee294","7432024.f8bcdfc","def44c2d.210bb"],["58b35777.a74ca8"]]},{"id":"511d6cee.aee294","type":"debug","name":"Eintrag Anruferliste gesamt","active":false,"console":"false","complete":"payload","x":1649.416275024414,"y":1438.833565711975,"z":"64b98f40.9b467","wires":[]},{"id":"e5eaa2d3.1a156","type":"inject","name":"10.05.15 20:07:00;CONNECT;0;10;01713211545;","topic":"","payload":"10.05.15 20:07:00;CONNECT;0;10;01713211545;","payloadType":"string","repeat":"","crontab":"","once":false,"x":306.33343505859375,"y":2385.1667890548706,"z":"64b98f40.9b467","wires":[["b5b0eaea.4a4f18"]]},{"id":"dcdcb5fd.232348","type":"inject","name":"10.05.15 20:07:07;DISCONNECT;0;42;","topic":"","payload":"10.05.15 20:07:07;DISCONNECT;0;42;","payloadType":"string","repeat":"","crontab":"","once":false,"x":266.3334197998047,"y":2426.833456993103,"z":"64b98f40.9b467","wires":[["b5b0eaea.4a4f18"]]},{"id":"4dc8509e.b237b","type":"debug","name":"Eintrag Anruferliste verpasst","active":false,"console":"false","complete":"payload","x":1652.4164123535156,"y":1471.5000712573528,"z":"64b98f40.9b467","wires":[]},{"id":"58b35777.a74ca8","type":"switch","name":"(1) verpasst (2) nichts verpasst","property":"payload","rules":[{"t":"neq","v":"nichts"},{"t":"else"}],"checkall":"false","outputs":2,"x":1653.118911743164,"y":1398.9525842666626,"z":"64b98f40.9b467","wires":[["4dc8509e.b237b","7432024.f8bcdfc","fed2f25d.012d1","137130f8.ec8ecf"],[]]},{"id":"2450fd49.dbaf02","type":"inject","name":"10.05.15 20:06:58;RING;0;;022143238456;SIP0;","topic":"","payload":"10.05.15 20:06:58;RING;0;;022143238456;SIP0;","payloadType":"string","repeat":"","crontab":"","once":false,"x":296.666748046875,"y":2514.0002851486206,"z":"64b98f40.9b467","wires":[["b5b0eaea.4a4f18"]]},{"id":"92c72447.6d38d8","type":"comment","name":"kommendes Gespr. Nummer unterdrückt zur Sipgate 0221","info":"","x":271.666748046875,"y":2479.0002851486206,"z":"64b98f40.9b467","wires":[]},{"id":"857f6000.7a80a","type":"switch","name":"Konfig: Call ID Variablen anlegen (true/false)","property":"config.callid_anlegen","rules":[{"t":"true"}],"checkall":"true","outputs":1,"x":1233.8332481384277,"y":2004.6668729782104,"z":"64b98f40.9b467","wires":[["e782a628.187d58"]]},{"id":"3ef37477.c10c8c","type":"comment","name":"Version 0.3.0 - Versionsinfos","info":"0.3.1\n- Call Generator für Demo und Test hinzugefügt\n\n0.3.0\n- Konfiguration von msg.config auf context.global.fbVars.config umgestellt\n- http://[eingeneIP]:1880/fritzbox/vars -> Ausgabe des JSON Objekts mit den aktuellen Einstellungen\n- \n\n0.2.0\n- Interne Variablen auf Array nach Call ID umgestellt\n- Solange RING aktiv: Variable RING = true (zur Anzeige in VIS)\n- Anruferlisten für gesamt und verpasst (Format Text oder html, konfigurierbar)\n \n\n0.1.0\n- Werte für Anruferliste gesamt und verpasst sind konfigurierbar und werden ausgegeben\n (Formatierung wahlweise in HTML oder Text // Spalten in der Konfiguration auswählbar)\n- die wichtigsten Parameter können unter KONFIGURATION eingestellt werden\n- Variablen in ioBroker können für alle Call IDs angelegt werden\n Default: es werden keine Variablen angelegt (siehe KONFIGURATION)\n- CDRs to disk (konfigurierbar)\n\n ","x":191.33331298828125,"y":191.3333330154419,"z":"64b98f40.9b467","wires":[]},{"id":"a324eaf6.5cdb18","type":"debug","name":"","active":true,"console":"false","complete":"false","x":1115.3334350585938,"y":996.5,"z":"64b98f40.9b467","wires":[]},{"id":"2c90098.fd36ff6","type":"comment","name":"--- Abhängig von der Konfiguration: Default: false -> es werden keine Variablen für die Call IDs in ioBroker angelegt ---","info":"","x":1485.166763305664,"y":1806.0001497268677,"z":"64b98f40.9b467","wires":[]},{"id":"68ac9b14.975364","type":"function","name":"Meldung aufräumen -> CDR JSON","func":"var callid = msg.callid;\n\nmsg = {};\nmsg.topic = \"cdrJSON\";\n\nmsg = context.global.fbVars.callid[callid]; // nur die aktuelle Call ID als JSON ausgeben\n\nreturn msg;","outputs":1,"valid":true,"x":2638.333251953125,"y":1138.5,"z":"64b98f40.9b467","wires":[["b55ecf0.f4aa13","105a12a2.efa5ed","395285ea.c6ad7a"]]},{"id":"b55ecf0.f4aa13","type":"debug","name":"msg -> CDR (call detail Record) JSON","active":false,"console":"false","complete":"true","x":2260.333297729492,"y":1173.4999861717224,"z":"64b98f40.9b467","wires":[]},{"id":"395285ea.c6ad7a","type":"file","name":"","filename":"/opt/iobroker/fritzbox-cdr.txt","appendNewline":true,"overwriteFile":"false","x":2651.666748046875,"y":1185.166748046875,"z":"64b98f40.9b467","wires":[]},{"id":"105a12a2.efa5ed","type":"debug","name":"","active":false,"console":"false","complete":"true","x":2685.0000737508135,"y":1078.4999901453652,"z":"64b98f40.9b467","wires":[]},{"id":"b2710ffd.4d8ef","type":"switch","name":"Konfiguration: CDRs auf Disk schreiben (j/n)","property":"config.cdr_to_disk","rules":[{"t":"true"}],"checkall":"true","outputs":1,"x":2275.0000076293945,"y":1136.8333101272583,"z":"64b98f40.9b467","wires":[["68ac9b14.975364","20d4d674.df2b2a"]]},{"id":"970de948.68f218","type":"file","name":"","filename":"/opt/iobroker/fritzbox-cdr.txt","appendNewline":true,"overwriteFile":"delete","x":1446,"y":170.5,"z":"64b98f40.9b467","wires":[]},{"id":"a6ad378c.5952c8","type":"inject","name":"CDR Datei löschen","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":1203.666748046875,"y":170.66668701171875,"z":"64b98f40.9b467","wires":[["970de948.68f218"]]},{"id":"15e40c04.ea1bf4","type":"function","name":"RING & CONNECT & DISCONNECT: noch ein RING aktiv?","func":"//Output:\n// (1) -> Ring aktiv true/false\n// (2) -> Anzahl der aktiven Rufe\n\n\nvar anzahlring = 0;\nvar callid = msg.callid;\n \n \n // context.global.fbVars.callid.length; = Anzahl der Gespeicherten Callid Objekte -1\n\nfor (var i = 0; i < context.global.fbVars.callid.length; i++){ \n\tif (context.global.fbVars.callid[i] != null) {\t\t\t// Wenn eins der ersten Objekte = null ist überspringen (z.B. der Flow ist bei aktiven Call gestartet)\n\tif (context.global.fbVars.callid[i].calltype === \"RING\"){ anzahlring++; }\n\t}\n}\n \nif (anzahlring > 0) {\n\tmsg.payload = true;\n\t} else {\n\tmsg.payload = false;\n\t}\n\n\nmsg1 = {};\nmsg2 = {};\n\nmsg1.payload = msg.payload;\nmsg2.payload = anzahlring;\n\n\nmsg1.topic = msg.topic + \"ring\"; // Variablenname\nmsg2.topic = msg.topic + \"anzahlRingAktiv\"; // Variablenname\n\nreturn [msg1,msg2];\n","outputs":"2","valid":true,"x":1647.5237426757812,"y":1262.618890762329,"z":"64b98f40.9b467","wires":[["7432024.f8bcdfc"],["7432024.f8bcdfc"]]},{"id":"e8af3951.1750c8","type":"ioBroker out","name":"[Pfad aud der Konfig] + Variablenname","topic":"","ack":"true","autoCreate":"true","x":2206.666748046875,"y":854.3333129882812,"z":"64b98f40.9b467","wires":[]},{"id":"2de38359.d21c7c","type":"debug","name":"","active":false,"console":"false","complete":"payload","x":744.3810043334961,"y":1358.619044303894,"z":"64b98f40.9b467","wires":[]},{"id":"e8902f7.f176fd","type":"debug","name":"","active":false,"console":"false","complete":"true","x":744.3810043334961,"y":1394.619044303894,"z":"64b98f40.9b467","wires":[]},{"id":"de45645b.21ba98","type":"function","name":"context.global.fbVars löschen","func":"context.global.fbVars = {};\n\nmsg.payload = context.global.fbVars;\n\nreturn msg;","outputs":1,"valid":true,"x":1454.66650390625,"y":257.33331298828125,"z":"64b98f40.9b467","wires":[["e752d8bb.18ad28"]]},{"id":"e752d8bb.18ad28","type":"debug","name":"","active":true,"console":"false","complete":"payload","x":1658.66650390625,"y":255.33331298828125,"z":"64b98f40.9b467","wires":[]},{"id":"f799849c.086678","type":"debug","name":"","active":false,"console":"false","complete":"context","x":2562.166748046875,"y":2067.83349609375,"z":"64b98f40.9b467","wires":[]},{"id":"7dcb6112.8234a","type":"inject","name":"Löscht die globalen Variablen","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":1212.66650390625,"y":259.33331298828125,"z":"64b98f40.9b467","wires":[["de45645b.21ba98"]]},{"id":"d884a2a9.277b6","type":"comment","name":"DEBUG","info":"DEBUG Infos, später entfernen:\n\n\nin der Funktion \"Meldungen in Objekte...\" zum Schluss:\nmsg.context = context.global.fbVars;\nUnd die dazugehörigen DEBUG Nodes\n\n\n","x":538,"y":192,"z":"64b98f40.9b467","wires":[]},{"id":"20d4d674.df2b2a","type":"debug","name":"","active":false,"console":"false","complete":"true","x":2686.000045776367,"y":1044.9999861717224,"z":"64b98f40.9b467","wires":[]},{"id":"fa6fdc15.05902","type":"comment","name":"Schreibt alle Variablen (Alle Zustände), wenn gewünscht (Konfig) unter callid[callid]","info":"","x":2369.4999961853027,"y":2028.500002861023,"z":"64b98f40.9b467","wires":[]},{"id":"7432024.f8bcdfc","type":"function","name":"terminiert alle Variablen","func":"\nreturn msg;","outputs":1,"valid":true,"x":2161.3334197998047,"y":903.6666831970215,"z":"64b98f40.9b467","wires":[["e8af3951.1750c8","a5541097.5aabf"]]},{"id":"b5b0eaea.4a4f18","type":"function","name":"Testmeldungen","func":"\nreturn msg;","outputs":1,"valid":true,"x":230.50000762939453,"y":1900.0000748634338,"z":"64b98f40.9b467","wires":[["fc1188c1.03ee78"]]},{"id":"d64e0cb2.29b1f","type":"inject","name":"10.05.15 20:07:00;CONNECT;0;10;;","topic":"","payload":"10.05.15 20:07:00;CONNECT;0;10;;","payloadType":"string","repeat":"","crontab":"","once":false,"x":260.5,"y":2554.0000410079956,"z":"64b98f40.9b467","wires":[["b5b0eaea.4a4f18"]]},{"id":"75ffb7a0.8a0048","type":"inject","name":"10.05.15 20:07:07;DISCONNECT;0;42;","topic":"","payload":"10.05.15 20:07:07;DISCONNECT;0;42;","payloadType":"string","repeat":"","crontab":"","once":false,"x":264.5,"y":2592.0000410079956,"z":"64b98f40.9b467","wires":[["b5b0eaea.4a4f18"]]},{"id":"a88757c9.5778a8","type":"inject","name":"10.05.15 20:06:58;RING;1;01713211545;022143238456;SIP0;","topic":"","payload":"10.05.15 20:06:58;RING;1;01713211545;022143238456;SIP0;","payloadType":"string","repeat":"","crontab":"","once":false,"x":848.5,"y":2342.0000410079956,"z":"64b98f40.9b467","wires":[["b5b0eaea.4a4f18"]]},{"id":"74787906.8b8788","type":"comment","name":"kommendes Gespr. 0173 zur Sipgate 0201, Nebenstelle 10 geht dran","info":"","x":818.5,"y":2302.0000410079956,"z":"64b98f40.9b467","wires":[]},{"id":"9ed34fb.f612cb","type":"inject","name":"10.05.15 20:07:00;CONNECT;1;10;01713211545;","topic":"","payload":"10.05.15 20:07:00;CONNECT;1;10;01713211545;","payloadType":"string","repeat":"","crontab":"","once":false,"x":809.8333129882812,"y":2387.3332929611206,"z":"64b98f40.9b467","wires":[["b5b0eaea.4a4f18"]]},{"id":"31e12f38.ce1ed","type":"inject","name":"10.05.15 20:07:07;DISCONNECT;1;42;","topic":"","payload":"10.05.15 20:07:07;DISCONNECT;1;42;","payloadType":"string","repeat":"","crontab":"","once":false,"x":769.8332977294922,"y":2428.999960899353,"z":"64b98f40.9b467","wires":[["b5b0eaea.4a4f18"]]},{"id":"e0057d0f.1ffa8","type":"function","name":"CONNECT & DISCONNECT, Anzahl aktiver Verbindungen","func":"//Output:\n// (1) -> Anzahl aktiver Verbindungen\n\nvar anzahlconnect = 0;\n\n // context.global.fbVars.callid.length; = Anzahl der Gespeicherten Callid Objekte -1\n\nfor (var i = 0; i < context.global.fbVars.callid.length; i++){ \n\tif (context.global.fbVars.callid[i] != null) {\t\t\t// Wenn eins der ersten Objekte = null ist überspringen (z.B. der Flow ist bei aktiven Call gestartet)\n\tif (context.global.fbVars.callid[i].calltype === \"CONNECT\"){ anzahlconnect++; }\n\t}\n}\n \n\nmsg.payload = anzahlconnect;\nmsg.topic = msg.topic + \"anzahlConnectAktiv\"; // Variablenname\n\nreturn msg;\n","outputs":"1","valid":true,"x":1667.1428146362305,"y":1162.8569645881653,"z":"64b98f40.9b467","wires":[["7432024.f8bcdfc"]]},{"id":"a5541097.5aabf","type":"debug","name":"","active":false,"console":"false","complete":"false","x":2355.714286804199,"y":905.2380542755127,"z":"64b98f40.9b467","wires":[]},{"id":"3fb9047b.c046fc","type":"function","name":"CALL & CONNECT & DISCONNECT, Anzahl aktiver gehenden Rufaufbauten (CALL)","func":"//Output:\n// (1) -> Anzahl aktiver gehenden Rufaufbauversuche (CALL)\n\nvar anzahlcall = 0;\n\n // context.global.fbVars.callid.length; = Anzahl der Gespeicherten Callid Objekte -1\n\nfor (var i = 0; i < context.global.fbVars.callid.length; i++){ \n\tif (context.global.fbVars.callid[i] != null) {\t\t\t// Wenn eins der ersten Objekte = null ist überspringen (z.B. der Flow ist bei aktiven Call gestartet)\n\tif (context.global.fbVars.callid[i].calltype === \"CALL\"){ anzahlcall++; }\n\t}\n}\n \n\nmsg.payload = anzahlcall;\nmsg.topic = msg.topic + \"anzahlRufaufbauGehendAktiv\"; // Variablenname\n\nreturn msg;\n","outputs":"1","valid":true,"x":1638.5714569091797,"y":1117.142786026001,"z":"64b98f40.9b467","wires":[["7432024.f8bcdfc"]]},{"id":"def44c2d.210bb","type":"function","name":"Anruferliste gesamt als Liste","func":"\n\n// var events = [];\ncontext.global.fbVars.anruferlisteGesamt = context.global.fbVars.anruferlisteGesamt || [];\n\nfunction getEventsList() {\n var text = '';\n for (var i = 0; i < context.global.fbVars.anruferlisteGesamt.length; i++) {\n text += (text ? '
\\n' : '') + context.global.fbVars.anruferlisteGesamt[i];\n }\n return text;\n} \n\nif (context.global.fbVars.config.anz_kopfzeile === true) {\n context.global.fbVars.anruferlisteGesamt.shift(); // erste Element im Array löschen (Kopfzeile)\n context.global.fbVars.anruferlisteGesamt.unshift(msg.anruferlisteKopf, msg.payload); // (Kopfzeile und aktueller Eintrag an Stelle 1 und 2 hinzufügen)\n } else {\n context.global.fbVars.anruferlisteGesamt.unshift(msg.payload);\n }\n\n// if (context.global.fbVars.anruferlisteGesamt.length > context.global.fbVars.config.anz_anzahl_zeilen) context.global.fbVars.anruferlisteGesamt.pop();\n if (context.global.fbVars.anruferlisteGesamt.length > context.global.fbVars.config.anz_anzahl_zeilen) {\n context.global.fbVars.anruferlisteGesamt.length = context.global.fbVars.config.anz_anzahl_zeilen;\n }\n msg.payload = getEventsList();\n\nmsg.topic = context.global.fbVars.config.topic_prefix + \"ruflisten.gesamtListe\";\n\nreturn msg;\n","outputs":1,"valid":true,"x":2021.6666564941406,"y":1345.8333940505981,"z":"64b98f40.9b467","wires":[["4f8e909.fb0717","7432024.f8bcdfc"]]},{"id":"4f8e909.fb0717","type":"debug","name":"Anruferliste gesamt","active":false,"console":"false","complete":"payload","x":2251.66658782959,"y":1340.8333930969238,"z":"64b98f40.9b467","wires":[]},{"id":"fed2f25d.012d1","type":"function","name":"Anruferliste verpasst als Liste","func":"// var events = [];\ncontext.global.fbVars.anruferlisteVerpasst = context.global.fbVars.anruferlisteVerpasst || [];\n\n\n// Liste mit Anzahl Zeilen: context.global.fbVars.config.anz_anzahl_zeilen\nfunction getEventsList() {\n var text = '';\n for (var i = 0; i < context.global.fbVars.anruferlisteVerpasst.length; i++) {\n text += (text ? '
\\n' : '') + context.global.fbVars.anruferlisteVerpasst[i];\n }\n return text;\n} \n\n\n// context.global.fbVars.anruferlisteVerpasst.unshift(msg.payload);\n// if (context.global.fbVars.anruferlisteVerpasst.length > context.global.fbVars.config.anz_anzahl_zeilen) context.global.fbVars.anruferlisteVerpasst.pop();\n// msg.payload = getEventsList();\n\nif (context.global.fbVars.config.anz_kopfzeile === true) {\n context.global.fbVars.anruferlisteVerpasst.shift(); // erste Element im Array löschen (Kopfzeile)\n context.global.fbVars.anruferlisteVerpasst.unshift(msg.verpasstKopf, msg.payload); // (Kopfzeile und aktueller Eintrag an Stelle 1 und 2 hinzufügen)\n } else {\n context.global.fbVars.anruferlisteVerpasst.unshift(msg.payload);\n }\n\n// if (context.global.fbVars.anruferlisteVerpasst.length > context.global.fbVars.config.anz_anzahl_zeilen) context.global.fbVars.anruferlisteVerpasst.pop();\n if (context.global.fbVars.anruferlisteVerpasst.length > context.global.fbVars.config.anz_anzahl_zeilen) {\n context.global.fbVars.anruferlisteVerpasst.length = context.global.fbVars.config.anz_anzahl_zeilen;\n }\n msg.payload = getEventsList();\n\n\n\nmsg.topic = context.global.fbVars.config.topic_prefix + \"ruflisten.verpasstListe\";\n\nreturn msg;\n","outputs":1,"valid":true,"x":2017.499984741211,"y":1397.5000486373901,"z":"64b98f40.9b467","wires":[["14c9cde0.eb3632","7432024.f8bcdfc"]]},{"id":"14c9cde0.eb3632","type":"debug","name":"Anruferliste verpasst","active":false,"console":"false","complete":"payload","x":2253.7500190734863,"y":1398.750069618225,"z":"64b98f40.9b467","wires":[]},{"id":"e0a48df0.1f5b7","type":"function","name":"RING, aktueller letzter aktiver Anruf, alle aktiven Anrufe.","func":"//Output:\n// (1) -> \"ringAktuellLetzter\"; // letzte reinkommende Rufnummer, die derzeit \"schellt\" (RING)\n// (2) -> \"ringListeAktive\"; // Liste der aktiv Anrufenden (Zustand: RING)\n\n\n// muss überarbeitet werden!!!\n\nvar anzahlring = 0;\nvar callid = msg.callid;\nvar ringAktuellLetzter = msg.callingNumber; \nvar ringListeAktive = \"\";\n\n\nvar zeitstempel = msg.dateStart; // Zeit des RING\n\nvar jahr = zeitstempel.substring(6,8);\nvar monat = zeitstempel.substring(3,5);\nvar tag = zeitstempel.substring(0,2);\nvar stunde = zeitstempel.substring(9,11);\nvar minute = zeitstempel.substring(12,14);\nvar sekunde = zeitstempel.substring(15,17);\n\n//var uhrzeit = stunde + \":\" + minute + \":\"+ sekunde + \" \";\nvar uhrzeit = stunde + \":\" + minute + \" \";\n\n//var datum = tag + \".\" + monat + \".20\" + jahr + \" \";\n//var datum = tag + \".\" + monat + \".\" + jahr + \" \";\nvar datum = tag + \".\" + monat + \". \";\n\n// so werden die aktuelle Rufe angezeigt (kann bei Bedarf erweitert werden, z.B. um die angerufene Amtsrufnummer)\nvar ringAktuellerAnruf = uhrzeit + \" \" + msg.line + \" \" + msg.callingNumber; \n\n\n// zählt die aktuelle Anzahl aktiver Rufe (RING) -> anzahlRING\nfor (var i = 0; i < context.global.fbVars.callid.length; i++){ \n\tif (context.global.fbVars.callid[i] != null) {\t\t\t// Wenn eins der ersten Objekte = null ist überspringen (z.B. der Flow ist bei aktiven Call gestartet)\n\tif (context.global.fbVars.callid[i].calltype === \"RING\"){ anzahlring++; }\n\t}\n}\n \n \n\n// Liste aktiver RINGs\ncontext.global.fbVars.ringListeAktive = context.global.fbVars.ringListeAktive || [];\n\nfunction getEventsList() {\n var text = '';\n for (var i = 0; i < context.global.fbVars.ringListeAktive.length; i++) {\n text += (text ? '
\\n' : '') + context.global.fbVars.ringListeAktive[i];\n }\n return text;\n} \n\n context.global.fbVars.ringListeAktive.unshift(ringAktuellerAnruf); // unshift -> aktuellster Anruf oben\n if (context.global.fbVars.ringListeAktive.length > anzahlring) context.global.fbVars.ringListeAktive.pop();\n ringListeAktive = getEventsList(); // schreibt die aktuelle Liste aktiver RINGs in die Variable \n\n\n\n\n\nmsg1 = {};\nmsg2 = {};\n\nmsg1.payload = ringAktuellLetzter;\nmsg2.payload = ringListeAktive;\n\nmsg1.topic = msg.topic + \"ringAktuellLetzter\"; // letzte reinkommende Rufnummer, die derzeit \"schellt\" (RING)\nmsg2.topic = msg.topic + \"ringListeAktive\"; // Liste der aktiv Anrufenden (Zustand: RING)\n\nreturn [msg1,msg2];\n","outputs":"2","valid":true,"x":1598.66650390625,"y":901.3333129882812,"z":"64b98f40.9b467","wires":[["7432024.f8bcdfc","721fa78c.8de058"],["7432024.f8bcdfc","c11fc87d.3ee038"]]},{"id":"721fa78c.8de058","type":"debug","name":"","active":false,"console":"false","complete":"false","x":1773.6666285196939,"y":827.9999938011168,"z":"64b98f40.9b467","wires":[]},{"id":"c11fc87d.3ee038","type":"debug","name":"","active":false,"console":"false","complete":"false","x":1776.9999084472656,"y":861.3333058357239,"z":"64b98f40.9b467","wires":[]},{"id":"94b7e9c8.6b4818","type":"http in","name":"","url":"/fritzbox/vars","method":"get","x":1004.6668167114258,"y":514.9999809265137,"z":"64b98f40.9b467","wires":[["e6104458.19efb8"]]},{"id":"25c3d420.da3c2c","type":"http response","name":"http://[EIGENE-IP]:1880/fritzbox/vars","x":1564.333251953125,"y":513.3333129882812,"z":"64b98f40.9b467","wires":[]},{"id":"e6104458.19efb8","type":"function","name":"Ausgabe JSON context.global.fbVars","func":"msg.payload = context.global.fbVars = context.global.fbVars;\nreturn msg;","outputs":1,"valid":true,"x":1251.333391825358,"y":513.3333129882812,"z":"64b98f40.9b467","wires":[["25c3d420.da3c2c"]]},{"id":"7aa08ab9.855f74","type":"http in","name":"","url":"/fritzbox","method":"get","x":998.0000915527344,"y":561.6666440963745,"z":"64b98f40.9b467","wires":[["e6104458.19efb8"]]},{"id":"b00b1c6e.4ff4e","type":"function","name":"*.meldungAusDerFritzBox","func":"\nmsg.topic = msg.topic + \"meldungAusDerFritzBox\"; // Variablenpfad (aus der Konfigurationsfunktion) + \"meldung\"\n\nreturn msg;","outputs":1,"valid":true,"x":1114.9999618530273,"y":961.6666841506958,"z":"64b98f40.9b467","wires":[["4ed4b1d9.b12b5","a324eaf6.5cdb18"]]},{"id":"12d69775.ed2969","type":"function","name":"RING 1:1 durchreichen","func":"// Anzahl aktiver Rufe (RING) & Ring aktiv\n// wird von der gleichen Routne, wie bei CONNECT & DISCONNECT bearbeitet\n\nreturn msg;","outputs":1,"valid":true,"x":1537.6189155578613,"y":1227.6188640594482,"z":"64b98f40.9b467","wires":[["15e40c04.ea1bf4"]]},{"id":"c876d75f.378928","type":"function","name":"[15] deltaZeitMeldungSystemSek","func":"\nmsg.payload = msg.deltaZeitMeldungSystemSek;\n\nmsg.topic = msg.topic + \"deltaZeitMeldungSystemSek\";\n\n\n\nif (msg.payload != null) return msg;\n","outputs":1,"valid":true,"x":1651.4999961853027,"y":2368.500002861023,"z":"64b98f40.9b467","wires":[["87304828.78cfb8"]]},{"id":"22f8fd95.dd0702","type":"comment","name":"!!!! BAUSTELLE !!!!","info":"","x":1558,"y":860,"z":"64b98f40.9b467","wires":[]},{"id":"8ab1bddb.754e4","type":"ioBroker out","name":"[Pfad aus der Konfig].*","topic":"","ack":"true","autoCreate":"true","x":1268.5714111328125,"y":1405.71435546875,"z":"64b98f40.9b467","wires":[]},{"id":"1c70588a.e38fa7","type":"debug","name":"","active":false,"console":"false","complete":"false","x":1224.238052368164,"y":1475.0477676391602,"z":"64b98f40.9b467","wires":[]},{"id":"fe485bb3.01b7a8","type":"function","name":"*.deltaZeitMeldungSystemSek","func":"\nmsg.payload = msg.deltaZeitMeldungSystemSek;\n\nmsg.topic = msg.topic + \"deltaZeitMeldungSystemSek\";\n\n\n\nif (msg.payload != null) return msg;\n","outputs":1,"valid":true,"x":1223.9045791625977,"y":1440.214451789856,"z":"64b98f40.9b467","wires":[["8ab1bddb.754e4","1c70588a.e38fa7"]]},{"id":"fac27e5d.053d8","type":"inject","name":"Call Generator, 50 zufällige Calls starten","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":208.28570556640625,"y":512.357177734375,"z":"64b98f40.9b467","wires":[["bf6b4dcf.4094b"]]},{"id":"115057df.eeafa8","type":"function","name":"Random Callparameter","func":"var vorwahlen = [\"0201\",\"0211\",\"030\",\"089\",\"040\"];\nvar eigeneRufnummern = [\"021147110815\",\"02118115643\",\"02118115643\"];\nvar eigeneLines = [\"POTS\",\"SIP0\",\"SIP1\"];\n\nfunction fill(n) {\n\tvar empty_chars = \"\";\n\tfor(var i = 0; i < n; ++i)\n\tempty_chars += \"0\";\n\treturn(empty_chars);\n\t}\n\n//Zufahllszahlen zwischen min und max\nfunction rand(min, max) {\n\treturn Math.floor(Math.random() * (max - min + 1)) + min;\n}\n\n//Rufnummer ohne Vorwahl genereieren, Länge zwischen 6 und 8 Ziffern\nfunction rufnummer () {\n var länge = rand (6,8);\n var rufnummer = \"\";\n rufnummer = rufnummer + rand(1,9);\n for (var i = 0; i <= länge; i++)\n rufnummer = rufnummer + rand(0,9);\n return rufnummer;\n}\n\n\nfunction datum() {\n var now = new Date();\n var tag = now.getDate();\n var monat = now.getMonth()+1;\n var jahr = now.getYear();\n var stunde = now.getHours(); \n var minute = now.getMinutes(); \n var sekunde = now.getSeconds(); \n stunde = stunde.toString(); \n tag = tag.toString();\n monat = monat.toString();\n jahr = jahr.toString();\n minute = minute.toString();\n sekunde = sekunde.toString();\n jahr = jahr.substr(1,2);\n tag = fill(2 - tag.length) + tag;\n monat = fill(2 - monat.length) + monat;\n stunde = fill(2 - stunde.length) + stunde;\n minute = fill(2 - minute.length) + minute;\n sekunde = fill(2 - sekunde.length) + sekunde;\n\n \n var datum = tag + \".\" + monat + \".\" + jahr + \" \" + stunde + \":\" + minute +\":\" + sekunde;\n return datum;\n }\n\n\nvar eigeneNummer = rand(0,2);\n\nmsg.intNumber = rand(11,13);\nmsg.date = datum();\nmsg.eigeneNummer = eigeneRufnummern[eigeneNummer];\nmsg.line = eigeneLines[eigeneNummer];\n\nif (rand(1,10) < 7) {\n msg.connect = true; \n } else {\n msg.connect = false;\n}\n\nif (rand(1,10) < 6) {\n msg.direction = \"kommend\"; \n } else {\n msg.direction = \"gehend\";\n}\n\n\nif (rand(1,10) < 9) {\n var rufnummer = rufnummer(); // zufällige Rufnummer ohne Vorwahl\n var dieseVorwahl = rand(0,vorwahlen.length-1); // \n msg.externeNummer = vorwahlen[dieseVorwahl] + rufnummer;\n } else {\n if (msg.direction == \"kommend\") {\n var rufnummer = \"\";\n msg.externeNummer = \"\";\n }\n }\n\n\n\n var callid = 99;\n\n\tfor(var i = 0; i < context.global.callidfrei.length; ++i) {\n\tif (context.global.callidfrei[i] === true) {\n\t context.global.callidfrei[i] = false;\n\t callid = i;\n\t break;\n\t }\n }\n\nmsg.callid = callid;\n\nif (callid == 99) {\n msg.direction = \"error\";\n}\nmsg.connectedNumber = msg.externeNummer;\n\n\nreturn msg;\n\n","outputs":1,"valid":true,"x":525.2857208251953,"y":3025.143110394478,"z":"64b98f40.9b467","wires":[["80cec74c.7f3138","7ebf247c.8140dc"]]},{"id":"80cec74c.7f3138","type":"switch","name":"(1) gehend (2) kommend (3) error","property":"direction","rules":[{"t":"eq","v":"gehend"},{"t":"eq","v":"kommend"},{"t":"else"}],"checkall":"true","outputs":3,"x":789.0000152587891,"y":3026.000043988228,"z":"64b98f40.9b467","wires":[["e3989190.1c677"],["64b3c50b.9b4c3c"],["d3e0b3b4.2c1f5"]]},{"id":"e3989190.1c677","type":"function","name":"CALL","func":"// msg.externeNummer\n// msg.connectedNumber\n// msg.intNumber\n// msg.date\n// msg.eigeneNummer\n// msg.line\n// msg.connect\n// msg.direction\n// msg.callid\n\n\n\nmsg.payload = msg.date + \";CALL;\" + msg.callid + \";\" + msg.intNumber + \";\"\n + msg.eigeneNummer + \";\" + msg.externeNummer + \";\" + msg.line + \";\";\n\nreturn msg;\n","outputs":1,"valid":true,"x":1039.000015258789,"y":3002.000043988228,"z":"64b98f40.9b467","wires":[["879076cc.786f88","4b30d9c0.b4cf28","57a3f0a1.a85c1"]]},{"id":"7ebf247c.8140dc","type":"debug","name":"","active":false,"console":"false","complete":"true","x":553.0000152587891,"y":2986.000043988228,"z":"64b98f40.9b467","wires":[]},{"id":"eeaf08f9.1150f8","type":"debug","name":"","active":true,"console":"false","complete":"payload","x":839.0000152587891,"y":3092.000043988228,"z":"64b98f40.9b467","wires":[]},{"id":"110bf9f9.eef406","type":"debug","name":"","active":false,"console":"false","complete":"payload","x":1376.0000076293945,"y":2822.000039577484,"z":"64b98f40.9b467","wires":[]},{"id":"64b3c50b.9b4c3c","type":"function","name":"RING","func":"// msg.externeNummer\n// msg.connectedNumber\n// msg.intNumber\n// msg.date\n// msg.eigeneNummer\n// msg.line\n// msg.connect\n// msg.direction\n// msg.callid\n\nfunction fill(n) {\n\tvar empty_chars = \"\";\n\tfor(var i = 0; i < n; ++i)\n\tempty_chars += \"0\";\n\treturn(empty_chars);\n\t}\n\n\nmsg.payload = msg.date + \";RING;\" + msg.callid + \";\" + msg.externeNummer + \";\"\n + msg.eigeneNummer + \";\" + msg.line + \";\";\n\nreturn msg;\n","outputs":1,"valid":true,"x":1038.4286041259766,"y":3040.285688519478,"z":"64b98f40.9b467","wires":[["879076cc.786f88","4b30d9c0.b4cf28","57a3f0a1.a85c1"]]},{"id":"3b9a8e85.c46572","type":"switch","name":"(1) Connect (2) kein Connect (3) error","property":"connect","rules":[{"t":"true"},{"t":"false"},{"t":"else"}],"checkall":"true","outputs":3,"x":1433.000015258789,"y":3020.000043988228,"z":"64b98f40.9b467","wires":[["5aa54539.a55abc"],["d4bd1bec.2b42e8"],["d3e0b3b4.2c1f5"]]},{"id":"d3e0b3b4.2c1f5","type":"function","name":"error","func":"node.error(\"Fehler im Call Generator\");\nmsg.payload = \"Fehler im Call Generator\"\n\nreturn msg;","outputs":1,"valid":true,"x":705.0000152587891,"y":3090.000043988228,"z":"64b98f40.9b467","wires":[["eeaf08f9.1150f8"]]},{"id":"5aa54539.a55abc","type":"function","name":"CONNECT","func":"// msg.externeNummer\n// msg.connectedNumber\n// msg.intNumber\n// msg.date\n// msg.eigeneNummer\n// msg.line\n// msg.connect\n// msg.direction\n// msg.callid\n\nfunction fill(n) {\n\tvar empty_chars = \"\";\n\tfor(var i = 0; i < n; ++i)\n\tempty_chars += \"0\";\n\treturn(empty_chars);\n\t}\n\nfunction datum() {\n var now = new Date();\n var tag = now.getDate();\n var monat = now.getMonth()+1;\n var jahr = now.getYear();\n var stunde = now.getHours(); \n var minute = now.getMinutes(); \n var sekunde = now.getSeconds(); \n stunde = stunde.toString(); \n tag = tag.toString();\n monat = monat.toString();\n jahr = jahr.toString();\n minute = minute.toString();\n sekunde = sekunde.toString();\n jahr = jahr.substr(1,2);\n tag = fill(2 - tag.length) + tag;\n monat = fill(2 - monat.length) + monat;\n stunde = fill(2 - stunde.length) + stunde;\n minute = fill(2 - minute.length) + minute;\n sekunde = fill(2 - sekunde.length) + sekunde;\n\n \n var datum = tag + \".\" + monat + \".\" + jahr + \" \" + stunde + \":\" + minute +\":\" + sekunde;\n return datum;\n } \nmsg.date = datum();\n\n\nmsg.payload = msg.date + \";CONNECT;\" + msg.callid + \";\" + msg.intNumber + \";\" + msg.externeNummer + \";\";\n\nreturn msg;\n","outputs":1,"valid":true,"x":1663.000015258789,"y":2998.000043988228,"z":"64b98f40.9b467","wires":[["879076cc.786f88","48e2bdb9.b71d44","4e17ad0e.b1e854"]]},{"id":"4b30d9c0.b4cf28","type":"delay","name":"","pauseType":"random","timeout":"6","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"2","randomLast":"6","randomUnits":"seconds","drop":false,"x":1201.000015258789,"y":3018.000043988228,"z":"64b98f40.9b467","wires":[["3b9a8e85.c46572"]]},{"id":"879076cc.786f88","type":"function","name":"emulierte Fritzbox Message","func":"var payload = msg.payload;\nmsg = {};\n\nmsg.payload = payload;\n\nreturn msg;","outputs":1,"valid":true,"x":1416.500015258789,"y":2863.0000410079956,"z":"64b98f40.9b467","wires":[["110bf9f9.eef406","b5b0eaea.4a4f18"]]},{"id":"d4bd1bec.2b42e8","type":"function","name":"DISCONNECT","func":"// msg.externeNummer\n// msg.connectedNumber\n// msg.intNumber\n// msg.date\n// msg.eigeneNummer\n// msg.line\n// msg.connect\n// msg.direction\n// msg.callid\n\nfunction fill(n) {\n\tvar empty_chars = \"\";\n\tfor(var i = 0; i < n; ++i)\n\tempty_chars += \"0\";\n\treturn(empty_chars);\n\t}\n\nfunction datum() {\n var now = new Date();\n var tag = now.getDate();\n var monat = now.getMonth()+1;\n var jahr = now.getYear();\n var stunde = now.getHours(); \n var minute = now.getMinutes(); \n var sekunde = now.getSeconds(); \n stunde = stunde.toString(); \n tag = tag.toString();\n monat = monat.toString();\n jahr = jahr.toString();\n minute = minute.toString();\n sekunde = sekunde.toString();\n jahr = jahr.substr(1,2);\n tag = fill(2 - tag.length) + tag;\n monat = fill(2 - monat.length) + monat;\n stunde = fill(2 - stunde.length) + stunde;\n minute = fill(2 - minute.length) + minute;\n sekunde = fill(2 - sekunde.length) + sekunde;\n\n \n var datum = tag + \".\" + monat + \".\" + jahr + \" \" + stunde + \":\" + minute +\":\" + sekunde;\n return datum;\n }\n \n \nmsg.date = datum();\n\n\n\n//Zufahllszahlen zwischen min und max\nfunction rand(min, max) {\n\treturn Math.floor(Math.random() * (max - min + 1)) + min;\n}\n\nvar callid = msg.callid;\ncontext.global.callidfrei[callid] = true;\n\n\nif (msg.connect === true) {\n msg.duration = rand(10,40); // Dauer des Gespräches nicht ausgerechnet (faul). Zufall\n } else {\n msg.duration = \"0\";\n}\n\nmsg.payload = msg.date + \";DISCONNECT;\" + msg.callid + \";\" + msg.duration + \";\";\n\nreturn msg;\n","outputs":1,"valid":true,"x":2001.000015258789,"y":3018.000043988228,"z":"64b98f40.9b467","wires":[["879076cc.786f88","effe627b.1001a","77435b35.88bca4"]]},{"id":"48e2bdb9.b71d44","type":"delay","name":"","pauseType":"random","timeout":"5","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"5","randomLast":"12","randomUnits":"seconds","drop":false,"x":1827.000015258789,"y":2998.000043988228,"z":"64b98f40.9b467","wires":[["d4bd1bec.2b42e8"]]},{"id":"57a3f0a1.a85c1","type":"debug","name":"","active":false,"console":"false","complete":"true","x":1036.0000076293945,"y":2956.5000429153442,"z":"64b98f40.9b467","wires":[]},{"id":"4e17ad0e.b1e854","type":"debug","name":"","active":false,"console":"false","complete":"true","x":1666.0000190734863,"y":2958.000042438507,"z":"64b98f40.9b467","wires":[]},{"id":"effe627b.1001a","type":"debug","name":"","active":false,"console":"false","complete":"true","x":2003.0000228881836,"y":2974.000043094158,"z":"64b98f40.9b467","wires":[]},{"id":"13a51ea9.ec5ae1","type":"function","name":"Schleife","func":"context.global.testcount = context.global.testcount -1;\n\nif (context.global.testcount > 0) {\n return msg;\n} else {\n return null; \n}\n","outputs":1,"valid":true,"x":1830.0000190734863,"y":3150.0000467300415,"z":"64b98f40.9b467","wires":[["115057df.eeafa8"]]},{"id":"bf6b4dcf.4094b","type":"function","name":"init","func":"context.global.callidfrei = [true,true,true,true,true,true,true,true,true,true,true,true];\ncontext.global.testcount = 50; // Schleifendurchgänge\n\nreturn msg;","outputs":1,"valid":true,"x":334.99999618530273,"y":3022.5000443458557,"z":"64b98f40.9b467","wires":[["115057df.eeafa8"]]},{"id":"a99bcaa9.566438","type":"comment","name":"###### Call Generator - simuliert zufällige Telefongespräche ######","info":"","x":400.0000305175781,"y":2842.50004196167,"z":"64b98f40.9b467","wires":[]},{"id":"77435b35.88bca4","type":"delay","name":"","pauseType":"random","timeout":"5","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"4","randomLast":"10","randomUnits":"seconds","drop":false,"x":1677.4999999999995,"y":3154.999999999999,"z":"64b98f40.9b467","wires":[["13a51ea9.ec5ae1"]]},{"id":"bf73ab0f.408c58","type":"inject","name":"nach Start zusätzliche parallele Calls starten","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":260.50001525878906,"y":556.5,"z":"64b98f40.9b467","wires":[["115057df.eeafa8"]]},{"id":"d729eba8.28d618","type":"catch","name":"","x":1208,"y":68,"z":"64b98f40.9b467","wires":[["e48d9b52.1b7268"]]},{"id":"e48d9b52.1b7268","type":"debug","name":"","active":true,"console":"false","complete":"true","x":1374,"y":68,"z":"64b98f40.9b467","wires":[]},{"id":"fdc75991.0238a8","type":"comment","name":"Aktuelle Werte über http als JSON ausgeben","info":"","x":1084.0000483194985,"y":464,"z":"64b98f40.9b467","wires":[]},{"id":"b462a417.4b9d58","type":"comment","name":"Für DEBUG: löscht die angelegten Variablen: context.global. !!! NICHT WÄHREND DER LAUFZEIT VERWENDEN !!!","info":"","x":1444,"y":224,"z":"64b98f40.9b467","wires":[]},{"id":"93ed6ff5.6c129","type":"pushover","title":"","name":"","priority":0,"x":816,"y":332,"z":"64b98f40.9b467","wires":[]},{"id":"8f76180d.7089e8","type":"e-mail","server":"smtp.gmail.com","port":"465","name":"","dname":"","x":808.0000000000001,"y":370.00000000000006,"z":"64b98f40.9b467","wires":[]},{"id":"11666c7d.ee9994","type":"template","name":"","field":"payload","format":"handlebars","template":"This is the payload: {{payload}} !","x":674,"y":334,"z":"64b98f40.9b467","wires":[["93ed6ff5.6c129"]]},{"id":"854cdcd6.7ab32","type":"template","name":"","field":"payload","format":"handlebars","template":"This is the payload: {{payload}} !","x":672,"y":374,"z":"64b98f40.9b467","wires":[["8f76180d.7089e8"]]},{"id":"137130f8.ec8ecf","type":"function","name":"","func":"\nreturn msg;","outputs":1,"valid":true,"x":674,"y":418,"z":"64b98f40.9b467","wires":[["11666c7d.ee9994","854cdcd6.7ab32"]]},{"id":"653a124b.9ac5ec","type":"comment","name":"Baustelle - Ausgabe muss auf Text geändert werden","info":"","x":772,"y":298,"z":"64b98f40.9b467","wires":[]}]