Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. (Echte) Stau-Erkennung mit Bing

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    (Echte) Stau-Erkennung mit Bing

    This topic has been deleted. Only users with topic management privileges can see it.
    • sissiwup
      sissiwup last edited by

      Ok,

      es gibt auch noch:

      {
              way: "wayPoint.1='Horsterfeld 1,31542 Bad Nenndorf'&" +
                   "viaWayPoint.2='Mindener Straße 4, 30890 Nordgoltern'&" +
                   "viaWayPoint.3='Landwehrkreisel / Frankfurter Allee, 30459 Hannover'&" +
                   "wayPoint.4='Laatzener Str. 1,30539 Hannover'",
              threshold: 5,
              name: 'Home2OfficeLandstr'
          },
      

      falls man ihn zwingen möchte eine Route zu nehmen.

      1 Reply Last reply Reply Quote 0
      • S
        Sven2013 last edited by

        Hallo, ich finde deine Idden gut mit der festgelegten Route. Ich würd Sie gerne Übernehmen.

        Ich habe den Ersten Code als "Flow" Importiert und meinen Bin API und die define Routes geändert.

        Aber was muss ich mit den Beiden Anderen Code Schnipseln machen?

        Bitte um Kurzen Schubs in die richtige Richtung.

        Gruß Sven

        @sissiwup:

        Hallo,

        habe mal ein bischen weitergedacht:
        filename="Bildschirmfoto 2015-08-22 um 01.46.13.png" index="0">~~

        *Fehler führen nicht zum Löschen der Datenpunkte

        *Eingabe der Straßennamen/Adressen in Klartext

        *Zwischenpunkte/Wegpunkte möglich

        *Debugausgaben sinnvoll erweitert

        [{"id":"a88491cd.577b7","type":"http request","name":"askBing","method":"GET","ret":"obj","url":"","x":436,"y":2346.9999389648438,"z":"58484835.a7b7b8","wires":[["4b2858cc.b4d7a8","d70d8ba3.28f278","fb724855.048db8"]]},{"id":"990145d0.66feb8","type":"function","name":"extractData","func":"/*\nreturns:\n1\. travelDurationTraffic in min\n2\. travelDuration in min\n3\. traveDelay in min\n4\. trafficJam boolean\n5\. trafficCongestion string\n6\. travelDistance in km\n7\. msg object (for debugging and return to the loop)\n*/\nvar travelDurationTraffic = Math.ceil(msg.payload.resourceSets[0].resources[0].travelDurationTraffic / 60);\nvar travelDuration = Math.ceil(msg.payload.resourceSets[0].resources[0].travelDuration / 60);\n\nvar shortname = msg.name+\":\"+msg.payload.resourceSets[0].resources[0].routeLegs[0].description+\"/\"+msg.payload.resourceSets[0].resources[0].travelDistance+\" km\";\n\nvar msgTraffic = [\n    {\n        topic: msg.topic_prefix + \".name\",\n        payload: msg.name\n    },\n    {\n        topic: msg.topic_prefix + \".travelDurationTraffic\",\n        payload: travelDurationTraffic\n    },\n    {    \n        topic: msg.topic_prefix + \".travelDuration\",\n        payload: travelDuration\n    },\n    {    \n        topic: msg.topic_prefix + \".travelDelay\",\n        payload: travelDurationTraffic - travelDuration\n    },\n    {    \n        topic: msg.topic_prefix + \".trafficJam\",\n        payload: (travelDurationTraffic - travelDuration >= msg.threshold)\n    },\n    {    \n        topic: msg.topic_prefix + \".trafficCongestion\",\n        payload: msg.payload.resourceSets[0].resources[0].trafficCongestion\n    },\n    {    \n        topic: msg.topic_prefix + \".travelDistance\",\n        payload: msg.payload.resourceSets[0].resources[0].travelDistance\n    },\n    {    \n        topic: msg.topic_prefix + \".travelDescription\",\n        payload: msg.payload.resourceSets[0].resources[0].routeLegs[0].description\n    }\n];\n\nreturn [shortname,msgTraffic,msg.payload.resourceSets[0].resources[0].routeLegs,msg];","outputs":"4","noerr":0,"x":273.5555419921875,"y":2642.1110229492188,"z":"58484835.a7b7b8","wires":[["6f13fc3f.90ec04"],["c25038ad.3dafc8","639eeea6.9c611"],["4cb75b47.b348a4"],["154f9236.eab06e"]]},{"id":"32caf48f.cd350c","type":"inject","name":"Trigger","topic":"","payload":"","payloadType":"date","repeat":"600","crontab":"","once":false,"x":157.88883209228516,"y":2091.0000133514404,"z":"58484835.a7b7b8","wires":[["9bc04bf1.643fb8"]]},{"id":"38e4e608.c71b1a","type":"function","name":"defineRoutes","func":"/*\nDefine routes:\nfrom: starting address, encode spaces with %20\nto: destination address, encode spaces with %20\nthreshold: in minutes, if duration with traffic is larger than threshold, set trafficJam to true\nname: name :-)\n*/\n\nmsg.routes = [\n    {\n        way: \".1='Horsterfeld 1,31542 Bad Nenndorf'&\" +\n             \".2='Laatzener Str. 1,30539 Hannover'\",\n        threshold: 5,\n        name: 'Home2Office'\n    },\n    {\n        way: \".1='Horsterfeld 1,31542 Bad Nenndorf'&\" +\n             \"via.2='Mindener Straße 4, 30890 Nordgoltern'&\" +\n             \"via.3='Landwehrkreisel / Frankfurter Allee, 30459 Hannover'&\" +\n             \".4='Laatzener Str. 1,30539 Hannover'\",\n        threshold: 5,\n        name: 'Home2OfficeLandstr'\n    },\n    {\n      way: \".1='Horsterfeld 1,31542 Bad Nenndorf'&\" +\n             \"via.2='Autobahnkreuz Hannover-Buchholz, 30659 Hannover'&\" +\n             \".3='Laatzener Str. 1,30539 Hannover'\",\n        threshold: 5,\n        name: 'Home2OfficeA2'\n    },\n    {\n        way: \".1='Laatzener Str. 1,30539 Hannover'&\" +\n             \"via.2='Landwehrkreisel / Frankfurter Allee, 30459 Hannover'&\" +\n             \"via.3='Mindener Straße 4, 30890 Nordgoltern'&\" +\n             \".4='Horsterfeld 1,31542 Bad Nenndorf'\",\n        threshold: 5,\n        name: 'Office2HomeLandstr'\n    },\n    {\n        way: \".1='Laatzener Str. 1,30539 Hannover'&\" +\n             \".2='Horsterfeld 1,31542 Bad Nenndorf'\",\n        threshold: 5,\n        name: 'Office2Home'\n    },\n       {\n        way: \".1='Laatzener Str. 1,30539 Hannover'&\" +\n             \"via.2='A37, 30655 Gross Buchholz'&\" +\n             \".3='Horsterfeld 1,31542 Bad Nenndorf'\",\n        threshold: 5,\n        name: 'Office2HomeA2'\n    }\n];\n\nreturn msg;","outputs":1,"noerr":0,"x":494.88897705078125,"y":2091.000015258789,"z":"58484835.a7b7b8","wires":[["b095a02e.4f6a6"]]},{"id":"bf34f55f.40cb08","type":"function","name":"prepareIteration","func":"// msg.method = \"GET\";\nmsg.url = encodeURI(\"http://dev.virtualearth.net/REST/v1/Routes?\" + msg.payload.way + \"&optimize=timeWithTraffic&key=\" + msg.config.bing_key);\nmsg.topic_prefix = msg.config.topic_prefix + msg.payload.name;\nmsg.name = msg.payload.name; \nmsg.threshold = msg.payload.threshold;\nreturn msg;","outputs":1,"noerr":0,"x":274.22222900390625,"y":2347.5554809570312,"z":"58484835.a7b7b8","wires":[["a88491cd.577b7","4fcf3346.b030cc"]]},{"id":"9bc04bf1.643fb8","type":"function","name":"setConfig","func":"msg.config = {\n    bing_key: \"AAABBBCCC\",\n    topic_prefix: \"node-red.0.traffic.\"\n};\nreturn msg;","outputs":1,"noerr":0,"x":320.11106872558594,"y":2091.5555572509766,"z":"58484835.a7b7b8","wires":[["38e4e608.c71b1a","1310a9a2.ecef56"]]},{"id":"b095a02e.4f6a6","type":"function","name":"loopRoutes","func":"context.routes = context.routes || msg.routes;\n\n// iterate through all the routes\nif (context.routes.length > 0) {\n    msg.payload = context.routes.shift();\n    return [null, msg];\n}\n\n// Reset routes-context, otherwise we immediately stop in the next run\ncontext.routes = false;\n// we are done with the loop\nreturn [msg, null];","outputs":"2","noerr":0,"x":184.6666259765625,"y":2285.22216796875,"z":"58484835.a7b7b8","wires":[[],["bf34f55f.40cb08"]]},{"id":"1310a9a2.ecef56","type":"debug","name":"","active":false,"console":"false","complete":"true","x":704.6666259765625,"y":2211.22216796875,"z":"58484835.a7b7b8","wires":[]},{"id":"c25038ad.3dafc8","type":"ioBroker out","name":"toIoBroker","topic":"","ack":"true","autoCreate":"true","x":639.6666259765625,"y":2546.22216796875,"z":"58484835.a7b7b8","wires":[]},{"id":"639eeea6.9c611","type":"debug","name":"Variablen","active":true,"console":"false","complete":"payload","x":699.6666259765625,"y":2485.22216796875,"z":"58484835.a7b7b8","wires":[]},{"id":"3759620e.c8a69e","type":"catch","name":"","x":692.6666259765625,"y":2093.2222290039062,"z":"58484835.a7b7b8","wires":[["1310a9a2.ecef56"]]},{"id":"39a69e5d.c65962","type":"comment","name":"Define your config and routes here.           ","info":"Define your config and routes here.","x":398.6666259765625,"y":2054.2222290039062,"z":"58484835.a7b7b8","wires":[]},{"id":"4fcf3346.b030cc","type":"debug","name":"WEB","active":false,"console":"false","complete":"url","x":687,"y":2259,"z":"58484835.a7b7b8","wires":[]},{"id":"4b2858cc.b4d7a8","type":"debug","name":"Answer","active":false,"console":"false","complete":"true","x":697,"y":2313,"z":"58484835.a7b7b8","wires":[]},{"id":"4cb75b47.b348a4","type":"debug","name":"Legs","active":false,"console":"false","complete":"true","x":630,"y":2610.9999389648438,"z":"58484835.a7b7b8","wires":[]},{"id":"154f9236.eab06e","type":"delay","name":"Pause","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":349,"y":2519,"z":"58484835.a7b7b8","wires":[["b095a02e.4f6a6"]]},{"id":"d70d8ba3.28f278","type":"switch","name":"Error?","property":"payload.statusCode","rules":[{"t":"neq","v":"200"},{"t":"else"}],"checkall":"true","outputs":2,"x":157,"y":2517,"z":"58484835.a7b7b8","wires":[["154f9236.eab06e"],["990145d0.66feb8"]]},{"id":"fb724855.048db8","type":"debug","name":"StatusCode","active":false,"console":"false","complete":"payload.statusCode","x":676,"y":2357,"z":"58484835.a7b7b8","wires":[]},{"id":"7225c9a2.8dda38","type":"catch","name":"","x":136,"y":2731,"z":"58484835.a7b7b8","wires":[["990145d0.66feb8"]]},{"id":"6f13fc3f.90ec04","type":"debug","name":"Route","active":true,"console":"false","complete":"true","x":697,"y":2439,"z":"58484835.a7b7b8","wires":[]}]
        

        extractData:

        /*
        returns:
        1\. travelDurationTraffic in min
        2\. travelDuration in min
        3\. traveDelay in min
        4\. trafficJam boolean
        5\. trafficCongestion string
        6\. travelDistance in km
        7\. msg object (for debugging and return to the loop)
        */
        var travelDurationTraffic = Math.ceil(msg.payload.resourceSets[0].resources[0].travelDurationTraffic / 60);
        var travelDuration = Math.ceil(msg.payload.resourceSets[0].resources[0].travelDuration / 60);
        
        var shortname = msg.name+":"+msg.payload.resourceSets[0].resources[0].routeLegs[0].description+"/"+msg.payload.resourceSets[0].resources[0].travelDistance+" km";
        
        var msgTraffic = [
            {
                topic: msg.topic_prefix + ".name",
                payload: msg.name
            },
            {
                topic: msg.topic_prefix + ".travelDurationTraffic",
                payload: travelDurationTraffic
            },
            {    
                topic: msg.topic_prefix + ".travelDuration",
                payload: travelDuration
            },
            {    
                topic: msg.topic_prefix + ".travelDelay",
                payload: travelDurationTraffic - travelDuration
            },
            {    
                topic: msg.topic_prefix + ".trafficJam",
                payload: (travelDurationTraffic - travelDuration >= msg.threshold)
            },
            {    
                topic: msg.topic_prefix + ".trafficCongestion",
                payload: msg.payload.resourceSets[0].resources[0].trafficCongestion
            },
            {    
                topic: msg.topic_prefix + ".travelDistance",
                payload: msg.payload.resourceSets[0].resources[0].travelDistance
            },
            {    
                topic: msg.topic_prefix + ".travelDescription",
                payload: msg.payload.resourceSets[0].resources[0].routeLegs[0].description
            }
        ];
        
        return [shortname,msgTraffic,msg.payload.resourceSets[0].resources[0].routeLegs,msg];
        

        prepareIteration:

        // msg.method = "GET";
        msg.url = encodeURI("http://dev.virtualearth.net/REST/v1/Routes?" + msg.payload.way + "&optimize=timeWithTraffic&key=" + msg.config.bing_key);
        msg.topic_prefix = msg.config.topic_prefix + msg.payload.name;
        msg.name = msg.payload.name; 
        msg.threshold = msg.payload.threshold;
        return msg;
        ```` ` 
        1 Reply Last reply Reply Quote 0
        • S
          Sven2013 last edited by

          Im Momant kommt zu dem Fred oben noch folgender Log Fehler.

          Vielleicht kann damit jemand etwas anfangen.

          Gruß Sven
          576_log.png

          1 Reply Last reply Reply Quote 0
          • F
            Fitti last edited by

            @Sven2013:

            Aber was muss ich mit den Beiden Anderen Code Schnipseln machen?

            Bitte um Kurzen Schubs in die richtige Richtung.

            Gruß Sven `

            Hallo Sven,

            Du hast ja drei Code-"Boxen" zitiert.

            Wenn ich mich recht erinnere, benötigst Du erst einmal nur die oberste Code-Box. Diesen Code kopierst Du Dir in die Zwischenablage. In Node-Red kannst Du dann diesen kompletten Code importieren, aber du benötigst einen neuen flow. Sonst wird auf den alten flow die neuen Sachen rauf kopiert.

            Dann solltest Du erst einmal schauen, ob alles läuft. Diese Fehlermeldung zeigt an, dass anscheinend noch etwas nicht richtig läuft, z. B. eine Variable noch nicht existiert o. ä.

            Du musst ja bei jeder Änderung oben rechts auf den "Deploy" Button klicken. Dieser sollte dann von rot zu grau wechseln.

            Den Bing-Key hast Du?

            Passe bitte mit Sonderzeichen und Umlaute auf - vermeide diese.

            Im Node defineRoutes legst Du ja Deinen Weg fest. z. B. so:

            msg.routes = [
                {
                    way: "wayPoint.1='Hauptstr.1,12345 Berlin'&" +
                         "viaWayPoint.2='Neben Str.,23456 AndererOrt'&" +
                         "wayPoint.3='Endstr.2,34567 Endstadt'",
                    threshold: 5,
                    name: 'Arbeitsweg_Landstr'
            

            In iobroker müsste dann, wenn alles läuft, im Reiter OBJEKTE unter Node-red.0 /traffic/Arbeitsweg_Landstr auftauchen. der name: in den Routen landet also auch als Objekt in den Objekten auf.

            Bei mir hat es immer mind. 30 Minuten gedauert, bis endlich mal Bing funktionierte. Sonst hatte ich einen Error 4002 oder 503 oder was weiß ich. Hier einfach mal warten. Aber das Objekt mit dem Namen wurde angelegt - wenn auch stark verzögert. ein paar Minuten bis 15 Minuten.

            Ich nehme an, das Deine Fehlermeldung auf einen schlecht gewählten Namen zurückgeht.

            Teste erst mal das.

            Viel Glück,

            Fitti

            1 Reply Last reply Reply Quote 0
            • T
              thiel last edited by

              Hey,

              läuft echt super die Lösung. 🙂 Gibt es auch die Möglichkeit die Voraussichtliche Ankunftszeit mit einzubinden?

              Danke euch

              1 Reply Last reply Reply Quote 0
              • OstfrieseUnterwegs
                OstfrieseUnterwegs last edited by

                Hallo, ich bin noch ziemlich neu in dem ganzen iobroker Thema (und allem was dazugehört)

                Bei der Stauabfrage bekomme ich folgende Fehlermeldung

                [function:extractData] TypeError: Cannot assign to read only property '_msgid' of Home2Office:A59, Münchener Straße/14.065 km
                

                Ein Reboot vom Pi hat nichts gebracht

                Kann mir da jemand helfen?

                1 Reply Last reply Reply Quote 0
                • Segway
                  Segway last edited by

                  @siedi:

                  In "defineRoutes" definiert Ihr dann beliebig viele Routen. `

                  Hallo,

                  habe gemäß Anleitung dieses Widget installiert und erflgreich am laufen. Klappt super einfach herrlich!

                  Nun meine Frage(n):

                  1. Muss ich bei From / To die Adresse OHNE Leerzeichen hinschreiben oder mit %20 auffüllen ?

                  2. Wenn ich in BING meine Route eingebe bekomme ich drei mögliche Alternativen. Ich möchte nun alle drei mir anzeigen lassen (von mir aus in drei Widgets) damit ich weiss welche Route ich zur Arbeit nehmen werde. Geht das ? (ich habe ja nur Start und Zielpunkt eingegeben!)

                  Update –> werde mal mein "altes" node-red geschnipsel löschen und das "neue" node-red mit 'via' einbinden

                  1 Reply Last reply Reply Quote 0
                  • Segway
                    Segway last edited by

                    So hat jetzt geklappt mit 'via' –> klappt alles wunderbar

                    1 Reply Last reply Reply Quote 0
                    • F
                      Fitti last edited by

                      Seit einer unbekannten Weile erhalte ich immer den Fehler:

                      node-red-0 2016-06-20 16:00:01.517 warn 20 Jun 16:00:01 - [warn] [function:extractData] Message exceeded maximum number of catches

                      node-red-0 2016-06-20 16:00:01.515 error 20 Jun 16:00:01 - [error] [function:extractData] TypeError: Cannot assign to read only property '_msgid' of Schule_Heim_A10:L30, E30/14.96 km

                      Da ich nur Ansatzweise verstehe, wieso das alles funktioniert, kann mir jemand bitte einen Tipp geben, wo oder wie ich den Fehler eingrenzen bzw. lösen kann?

                      Beim Debuggen in node scheint der Fehler in der Funktion extractData zu sein. Ich erhalte KEINE Ausgabe, wenn ich nur die Variablen Debugge (einschalte)!.

                      Die erzeugte URL mit copy und paste in Webbrowser gibt mir eine große Liste mit Werten zurück.

                      Den einen Fehler mit _msgid konnte ich auf die Zeile

                      var shortname = msg.name+":"+msg.payload.resourceSets[0].resources[0].routeLegs[0].description+"/"+msg.payload.resourceSets[0].resources[0].travelDistance+" km";
                      

                      eingrenzen. Aber keine Idee warum.

                      Beim Suchen fand ich den Hinweis, dass wohl die Variable (oder was das auch immer ist) _msgid per Default nur lesend ist und mittels writable: true schreibend gemacht werden soll.

                      Aber wo steckt nur diese _msgid?

                      Danke im Voraus,

                      Fitti.

                      1 Reply Last reply Reply Quote 0
                      • F
                        Fitti last edited by

                        Bin etwas weiter.

                        Mit http://forum.iobroker.org/viewtopic.php?f=32&t=713&start=20&sid=8d03c3f10a9eb22f203839a8cea79723&sid=8d03c3f10a9eb22f203839a8cea79723#p10122 geht es nicht mehr, auch nicht wenn ich alles neu mache. Es passierte ja auffalnd nach einer ioBroker Neuinstallation mit aktuellem node usw.

                        Wenn ich den http://forum.iobroker.org/viewtopic.php?f=32&t=713&sid=8d03c3f10a9eb22f203839a8cea79723&sid=8d03c3f10a9eb22f203839a8cea79723#p4999, dann geht es.

                        1 Reply Last reply Reply Quote 0
                        • H
                          Hangloose20 last edited by

                          Hallo zusammen.

                          bin neu hier gerade in den Genuss eines RP mit Iobroker gekommen.

                          Ich würde nun gerne eine Fahrzeitenberechnung haben ( HometoWork ). Mit Widget das mir die Fahrzeit ausgibt oder mir alternative Routen vorschlägt :shock:

                          Ich habe mir das hier alles soweit durchgelesen, verstehe aber leider nicht wirklich viel. Gibt es eine Anleitung für Anfänger ? Denke, es wäre besser, wenn ich Schritt für Schritt mich durch eine

                          Anleitung kämpfen kann.

                          Freue mich auf Eure Antworten.

                          Gruss Tobias

                          1 Reply Last reply Reply Quote 0
                          • R
                            root_ last edited by

                            Nach langer Zeit mal wieder was hier 😉

                            Ich hab den Flow von sissiwupps angepasst das es wieder funzt. Nun gibts nur ein kleines Problem mit der Übergabe der Daten an ioBroker. Das Problem muss aber schon immer bei dem flow bestanden haben da ich an der Stelle nichts geändert hab.

                            Fehlermeldung im log: [error] [function:extractData] Function tried to send a message of type string

                            Function extraData:

                            /*
                            returns:
                            1\. travelDurationTraffic in min
                            2\. travelDuration in min
                            3\. traveDelay in min
                            4\. trafficJam boolean
                            5\. trafficCongestion string
                            6\. travelDistance in km
                            7\. msg object (for debugging and return to the loop)
                            */
                            var travelDurationTraffic = Math.ceil(msg.payload.resourceSets[0].resources[0].travelDurationTraffic / 60);
                            var travelDuration = Math.ceil(msg.payload.resourceSets[0].resources[0].travelDuration / 60);
                            
                            var shortname = msg.name+":"+msg.payload.resourceSets[0].resources[0].routeLegs[0].description+"/"+msg.payload.resourceSets[0].resources[0].travelDistance+" km";
                            
                            var msgTraffic = [
                                {
                                    topic: msg.topic_prefix + ".name",
                                    payload: msg.name
                                },
                                {
                                    topic: msg.topic_prefix + ".travelDurationTraffic",
                                    payload: travelDurationTraffic
                                },
                                {    
                                    topic: msg.topic_prefix + ".travelDuration",
                                    payload: travelDuration
                                },
                                {    
                                    topic: msg.topic_prefix + ".travelDelay",
                                    payload: travelDurationTraffic - travelDuration
                                },
                                {    
                                    topic: msg.topic_prefix + ".trafficJam",
                                    payload: (travelDurationTraffic - travelDuration >= msg.threshold)
                                },
                                {    
                                    topic: msg.topic_prefix + ".trafficCongestion",
                                    payload: msg.payload.resourceSets[0].resources[0].trafficCongestion
                                },
                                {    
                                    topic: msg.topic_prefix + ".travelDistance",
                                    payload: msg.payload.resourceSets[0].resources[0].travelDistance
                                },
                                {    
                                    topic: msg.topic_prefix + ".travelDescription",
                                    payload: msg.payload.resourceSets[0].resources[0].routeLegs[0].description
                                }
                            ];
                            
                            return [shortname,msgTraffic,msg.payload.resourceSets[0].resources[0].routeLegs,msg];
                            

                            Was wird da falsch übergeben? Meine skills reichen da leider noch nicht aus aber ich lerne gerne 🙂

                            Saboti 1 Reply Last reply Reply Quote 0
                            • thexbrain
                              thexbrain last edited by

                              @Fitti:

                              Okay und Danke. Aber da fehlt ja noch eine Menge, oder?

                              Was habe ich gemacht:

                              1.) Mit Meiner MS ID eingelogt, mir eine Route ausgewählt, einen Bing Key erstellt (dazu musste ich diese Route erstellen).

                              1a.) Mir die Routenstartpunkt und und Endpunkt kopiert.

                              2.) Node-Red installiert

                              3.) Den FLOW-Code http://www.iobroker.net/?page_id=57&lang=de kopiert.

                              4.) In Node-RED auf "Import Clipboard" gegeangen und den kopierten Text eingefügt.

                              Darauf hin erhielt ich eine Grafik wie oben mit den ganzen Nodes.

                              4a.) Im Menu Workspace/Rename ausgewählt und den Ganzem den Namen "BingMaps" gegeben. Im Reiter dieses Programmes (oder wie man das nennt) steht nun auch der Name BingMaps.

                              5.) Dann im Node setConfig NUR meinen bing_key eingefügt.

                              6.) Nun im Node defineRoutes…

                              Im Beriech msg.routes

                              bei from: Die kopierten Texte meiner Bing-StartRoute reinkopiert.

                              ebenso bei to:

                              Den Namen noch angepasst: Home2Schule

                              Das Ganze, nur mit From und To getauscht, im nächsten Block {} gemacht, aber hier den Namen Schule2Home verwendet.

                              Nun frage ich mich, ob ich das irgendwie speichern muss, da beim Schließen des Browsers eine Warnmeldung kommt. Habe noch nie Node verwendet. Bei .vis muss man ja auch nichts speichern.

                              7.) In .vis habe ich dann gemäß deiner Info zuvor das Widget importiert. Ich habe einen "Rahmen" in der Anzeige

                              8.) Nun lässt es sich vermuten, dass bei der Inhalt ID: ich mit der Auswahl meinen Node sehen müsste. Aber ich finde diesen nirgends. Liegt das am fehlenden Speichern in Punkt 6?

                              Achso: Gemäß http://www.iobroker.net/?page_id=166&lang=de ist bei mir KEIN eigener Node- Reiter in der Admin-Oberfläche! Ich kann aber bei den Instanzen auf Node-Red klicken und es öffnet sich ein eigener Browser-Tab.

                              Gruß,

                              Fitti `

                              Ich möchte das auch gerne umsetzten aber irgendwie blicke ich da nicht durch.

                              Im bing habe ich mich eingeloggt und zwei keys erstellt.

                              Was müsste man dort auswählen ?

                              Basic?

                              Laut der Anleitung müsste die Route erstellt werden und dann den key aber irgendwie finde ich es nicht.

                              Danke schonmal und schöne Weihnachtstage wünsche ich euch allen.
                              4720_bing_key.jpg

                              1 Reply Last reply Reply Quote 0
                              • A
                                aw1980 last edited by

                                wollte gerade den Nodered Flow importieren, aber irgendwie bleibt der Import Button Rot hinterlegt.

                                Muss ich irgendwelche Module noch zusätzlich installieren bei Nodered? Das importieren anderer Flows funktioniert problemlos.

                                Saboti 1 Reply Last reply Reply Quote 0
                                • Saboti
                                  Saboti @aw1980 last edited by

                                  @aw1980 Das Problem hatte ich auch. Das JSON passt nicht.
                                  Ich wollte den geposteten Flow von Sven2013 nehmen.

                                  Kopiere den Code und mach eine validierung z.B. über folgende Webseite: https://jsonlint.com/
                                  Er meckert dann "func": an. Einfach alles dahinter gegen "" austauschen. Danach den JSON kopieren und importieren. Der Button sollte jetzt rot werden.
                                  Danach einfach in Node-Red die Funktion bearbeiten und den extra geposteten Text von Sven2013 einfügen.

                                  So klappte auch bei mir der Import.

                                  Gruß Ssboti

                                  1 Reply Last reply Reply Quote 0
                                  • Saboti
                                    Saboti @root_ last edited by

                                    @root_ ich hab den gleichen Fehler, hast Du da was rausgefunden woran das liegt?
                                    Gruß Saboti

                                    1 Reply Last reply Reply Quote 0
                                    • R
                                      root_ last edited by

                                      Hab meinen Flow umgebaut und übergebe nicht mehr seriell.

                                      1 Reply Last reply Reply Quote 0
                                      • sigi234
                                        sigi234 Forum Testing Most Active last edited by

                                        Hallo, kann wer den funktionierenden Flow reinstellen?

                                        Saboti 1 Reply Last reply Reply Quote 1
                                        • Saboti
                                          Saboti @sigi234 last edited by Saboti

                                          @sigi234 anbei wie es nun bei mir läuft.
                                          hab den extractData von MegrCurry mit dem Addon von rurh70 genommen. Hat zwar kein Debug aber funktioniert damit:

                                          /*
                                          
                                          returns:
                                          
                                          1\. travelDurationTraffic in min
                                          
                                          2\. travelDuration in min
                                          
                                          3\. traveDelay in min
                                          
                                          4\. trafficJam boolean
                                          
                                          5\. trafficCongestion string
                                          
                                          6\. travelDistance in km
                                          
                                          7\. msg object (for debugging and return to the loop)
                                          
                                          */
                                          
                                          var travelDurationTraffic = Math.ceil(msg.payload.resourceSets[0].resources[0].travelDurationTraffic / 60);
                                          
                                          var travelDuration = Math.ceil(msg.payload.resourceSets[0].resources[0].travelDuration / 60);
                                          
                                           
                                          
                                          var msgTraffic = [
                                          
                                              {
                                          
                                                  topic: msg.topic_prefix + ".name",
                                          
                                                  payload: msg.name
                                          
                                              },
                                          
                                              {
                                          
                                                  topic: msg.topic_prefix + ".travelDurationTraffic",
                                          
                                                  payload: travelDurationTraffic
                                          
                                              },
                                          
                                              {    
                                          
                                                  topic: msg.topic_prefix + ".travelDuration",
                                          
                                                  payload: travelDuration
                                          
                                              },
                                          
                                              {    
                                          
                                                  topic: msg.topic_prefix + ".travelDelay",
                                          
                                                  payload: travelDurationTraffic - travelDuration
                                          
                                              },
                                          
                                              {    
                                          
                                                  topic: msg.topic_prefix + ".trafficJam",
                                          
                                                  payload: (travelDurationTraffic - travelDuration >= msg.threshold)
                                          
                                              },
                                          
                                              {    
                                          
                                                  topic: msg.topic_prefix + ".trafficCongestion",
                                          
                                                  payload: msg.payload.resourceSets[0].resources[0].trafficCongestion
                                          
                                              },
                                          
                                              {    
                                          
                                                  topic: msg.topic_prefix + ".travelDistance",
                                          
                                                  payload: msg.payload.resourceSets[0].resources[0].travelDistance
                                          
                                              },
                                              
                                              {    
                                          
                                                  topic: msg.topic_prefix + ".travelDescription",
                                          
                                                  payload: msg.payload.resourceSets[0].resources[0].routeLegs[0].description
                                          
                                              }
                                          
                                          ];
                                          
                                          return [msgTraffic,msg];
                                          

                                          Und hier nochmal der komplette Flow:

                                          [
                                              {
                                                  "id": "f38be5c5.594708",
                                                  "type": "tab",
                                                  "label": "BingMaps Traffic",
                                                  "disabled": false,
                                                  "info": ""
                                              },
                                              {
                                                  "id": "ec0cc8e4.d21bf8",
                                                  "type": "http request",
                                                  "z": "f38be5c5.594708",
                                                  "name": "askBing",
                                                  "method": "GET",
                                                  "ret": "obj",
                                                  "url": "",
                                                  "x": 460,
                                                  "y": 400,
                                                  "wires": [
                                                      [
                                                          "65099a04.fa68e4",
                                                          "bf572708.026bb8",
                                                          "671cf5a3.93243c"
                                                      ]
                                                  ]
                                              },
                                              {
                                                  "id": "457c032a.c977cc",
                                                  "type": "inject",
                                                  "z": "f38be5c5.594708",
                                                  "name": "Trigger",
                                                  "topic": "",
                                                  "payload": "",
                                                  "payloadType": "date",
                                                  "repeat": "600",
                                                  "crontab": "",
                                                  "once": false,
                                                  "x": 181.88883209228516,
                                                  "y": 144.00007438659668,
                                                  "wires": [
                                                      [
                                                          "f8b6cb8e.148ff8"
                                                      ]
                                                  ]
                                              },
                                              {
                                                  "id": "f56d10d3.1a8c6",
                                                  "type": "function",
                                                  "z": "f38be5c5.594708",
                                                  "name": "defineRoutes",
                                                  "func": "/*\nDefine routes:\nfrom: starting address, encode spaces with %20\nto: destination address, encode spaces with %20\nthreshold: in minutes, if duration with traffic is larger than threshold, set trafficJam to true\nname: name :-)\n*/\n\nmsg.routes = [\n    {\n        way: \"wayPoint.1='xxxxxxxxx'&\" +\n             \"viaWayPoint.2='xxxxxxxxxx'&\" +\n             \"viaWayPoint.3='xxxxxxxxxxx'&\" +\n             \"wayPoint.4='xxxxxxxxxxxxx'\",\n        threshold: 5,\n        name: 'Home2Office'\n    },\n    {\n        way: \"wayPoint.1='xxxxxxxx'&\" +\n             \"viaWayPoint.2='xxxxxxxxxx'&\" +\n             \"viaWayPoint.3='xxxxxxxxxxx'&\" +\n             \"wayPoint.4='xxxxxxxxxx'\",\n        threshold: 5,\n        name: 'Office2Home'\n    }\n];\n\nreturn msg;",
                                                  "outputs": 1,
                                                  "noerr": 0,
                                                  "x": 518.8889770507812,
                                                  "y": 144.0000762939453,
                                                  "wires": [
                                                      [
                                                          "ed4644fd.7f8808"
                                                      ]
                                                  ]
                                              },
                                              {
                                                  "id": "47798bfa.dc51e4",
                                                  "type": "function",
                                                  "z": "f38be5c5.594708",
                                                  "name": "prepareIteration",
                                                  "func": "// msg.method = \"GET\";\n\nmsg.url = encodeURI(\"http://dev.virtualearth.net/REST/v1/Routes?\" + msg.payload.way + \"&optimize=timeWithTraffic&key=\" + msg.config.bing_key);\n\nmsg.topic_prefix = msg.config.topic_prefix + msg.payload.name;\n\nmsg.name = msg.payload.name; \n\nmsg.threshold = msg.payload.threshold;\n\nreturn msg;",
                                                  "outputs": 1,
                                                  "noerr": 0,
                                                  "x": 298.22222900390625,
                                                  "y": 400.5555419921875,
                                                  "wires": [
                                                      [
                                                          "ec0cc8e4.d21bf8",
                                                          "4bb3a641.55bbd8"
                                                      ]
                                                  ]
                                              },
                                              {
                                                  "id": "f8b6cb8e.148ff8",
                                                  "type": "function",
                                                  "z": "f38be5c5.594708",
                                                  "name": "setConfig",
                                                  "func": "msg.config = {\n    bing_key: \"xxxxxxxxxxx\",\n    topic_prefix: \"node-red.0.traffic.\"\n};\nreturn msg;",
                                                  "outputs": 1,
                                                  "noerr": 0,
                                                  "x": 344.11106872558594,
                                                  "y": 144.5556182861328,
                                                  "wires": [
                                                      [
                                                          "f56d10d3.1a8c6",
                                                          "bbfabcd1.22792"
                                                      ]
                                                  ]
                                              },
                                              {
                                                  "id": "ed4644fd.7f8808",
                                                  "type": "function",
                                                  "z": "f38be5c5.594708",
                                                  "name": "loopRoutes",
                                                  "func": "context.routes = context.routes || msg.routes;\n\n// iterate through all the routes\nif (context.routes.length > 0) {\n    msg.payload = context.routes.shift();\n    return [null, msg];\n}\n\n// Reset routes-context, otherwise we immediately stop in the next run\ncontext.routes = false;\n// we are done with the loop\nreturn [msg, null];",
                                                  "outputs": "2",
                                                  "noerr": 0,
                                                  "x": 208.6666259765625,
                                                  "y": 338.22222900390625,
                                                  "wires": [
                                                      [],
                                                      [
                                                          "47798bfa.dc51e4"
                                                      ]
                                                  ]
                                              },
                                              {
                                                  "id": "bbfabcd1.22792",
                                                  "type": "debug",
                                                  "z": "f38be5c5.594708",
                                                  "name": "",
                                                  "active": false,
                                                  "tosidebar": true,
                                                  "console": false,
                                                  "complete": "true",
                                                  "x": 728.6666259765625,
                                                  "y": 264.22222900390625,
                                                  "wires": []
                                              },
                                              {
                                                  "id": "51df14db.22edcc",
                                                  "type": "ioBroker out",
                                                  "z": "f38be5c5.594708",
                                                  "name": "toIoBroker",
                                                  "topic": "",
                                                  "ack": "true",
                                                  "autoCreate": "true",
                                                  "x": 663.6666259765625,
                                                  "y": 599.2222290039062,
                                                  "wires": []
                                              },
                                              {
                                                  "id": "ae4bbdde.5e5c6",
                                                  "type": "catch",
                                                  "z": "f38be5c5.594708",
                                                  "name": "",
                                                  "scope": null,
                                                  "x": 740,
                                                  "y": 140,
                                                  "wires": [
                                                      [
                                                          "bbfabcd1.22792"
                                                      ]
                                                  ]
                                              },
                                              {
                                                  "id": "c6a64342.37eab",
                                                  "type": "comment",
                                                  "z": "f38be5c5.594708",
                                                  "name": "Define your config and routes here.           ",
                                                  "info": "Define your config and routes here.",
                                                  "x": 422.6666259765625,
                                                  "y": 107.2222900390625,
                                                  "wires": []
                                              },
                                              {
                                                  "id": "4bb3a641.55bbd8",
                                                  "type": "debug",
                                                  "z": "f38be5c5.594708",
                                                  "name": "WEB",
                                                  "active": false,
                                                  "tosidebar": true,
                                                  "console": false,
                                                  "complete": "url",
                                                  "x": 711,
                                                  "y": 312.00006103515625,
                                                  "wires": []
                                              },
                                              {
                                                  "id": "65099a04.fa68e4",
                                                  "type": "debug",
                                                  "z": "f38be5c5.594708",
                                                  "name": "Answer",
                                                  "active": false,
                                                  "tosidebar": true,
                                                  "console": false,
                                                  "complete": "true",
                                                  "x": 721,
                                                  "y": 366.00006103515625,
                                                  "wires": []
                                              },
                                              {
                                                  "id": "dc7542ef.84429",
                                                  "type": "delay",
                                                  "z": "f38be5c5.594708",
                                                  "name": "Pause",
                                                  "pauseType": "delay",
                                                  "timeout": "3",
                                                  "timeoutUnits": "seconds",
                                                  "rate": "1",
                                                  "rateUnits": "second",
                                                  "randomFirst": "1",
                                                  "randomLast": "5",
                                                  "randomUnits": "seconds",
                                                  "drop": false,
                                                  "x": 370,
                                                  "y": 540,
                                                  "wires": [
                                                      [
                                                          "ed4644fd.7f8808"
                                                      ]
                                                  ]
                                              },
                                              {
                                                  "id": "bf572708.026bb8",
                                                  "type": "switch",
                                                  "z": "f38be5c5.594708",
                                                  "name": "Error?",
                                                  "property": "payload.statusCode",
                                                  "rules": [
                                                      {
                                                          "t": "neq",
                                                          "v": "200"
                                                      },
                                                      {
                                                          "t": "else"
                                                      }
                                                  ],
                                                  "checkall": "true",
                                                  "outputs": 2,
                                                  "x": 181,
                                                  "y": 570.0000610351562,
                                                  "wires": [
                                                      [
                                                          "dc7542ef.84429"
                                                      ],
                                                      [
                                                          "59391f0e.ac165"
                                                      ]
                                                  ]
                                              },
                                              {
                                                  "id": "671cf5a3.93243c",
                                                  "type": "debug",
                                                  "z": "f38be5c5.594708",
                                                  "name": "StatusCode",
                                                  "active": false,
                                                  "tosidebar": true,
                                                  "console": false,
                                                  "complete": "payload.statusCode",
                                                  "x": 700,
                                                  "y": 410.00006103515625,
                                                  "wires": []
                                              },
                                              {
                                                  "id": "4ca548a6.1616f8",
                                                  "type": "catch",
                                                  "z": "f38be5c5.594708",
                                                  "name": "",
                                                  "scope": null,
                                                  "x": 160,
                                                  "y": 784.0000610351562,
                                                  "wires": [
                                                      [
                                                          "59391f0e.ac165"
                                                      ]
                                                  ]
                                              },
                                              {
                                                  "id": "e2c4beb7.0393",
                                                  "type": "comment",
                                                  "z": "f38be5c5.594708",
                                                  "name": "defineRoutes Backup",
                                                  "info": "/*\nDefine routes:\nfrom: starting address, encode spaces with %20\nto: destination address, encode spaces with %20\nthreshold: in minutes, if duration with traffic is larger than threshold, set trafficJam to true\nname: name :-)\n*/\n\nmsg.routes = [\n    {\n        way: \".1='xxxxxxxx'&\" +\n             \".2='xxxxxxx'\",\n        threshold: 5,\n        name: 'Home2Office'\n    },\n    {\n        way: \".1='Horsterfeld 1,31542 Bad Nenndorf'&\" +\n             \"via.2='Mindener Straße 4, 30890 Nordgoltern'&\" +\n             \"via.3='Landwehrkreisel / Frankfurter Allee, 30459 Hannover'&\" +\n             \".4='Laatzener Str. 1,30539 Hannover'\",\n        threshold: 5,\n        name: 'Home2OfficeLandstr'\n    },\n    {\n      way: \".1='Horsterfeld 1,31542 Bad Nenndorf'&\" +\n             \"via.2='Autobahnkreuz Hannover-Buchholz, 30659 Hannover'&\" +\n             \".3='Laatzener Str. 1,30539 Hannover'\",\n        threshold: 5,\n        name: 'Home2OfficeA2'\n    },\n    {\n        way: \".1='Laatzener Str. 1,30539 Hannover'&\" +\n             \"via.2='Landwehrkreisel / Frankfurter Allee, 30459 Hannover'&\" +\n             \"via.3='Mindener Straße 4, 30890 Nordgoltern'&\" +\n             \".4='Horsterfeld 1,31542 Bad Nenndorf'\",\n        threshold: 5,\n        name: 'Office2HomeLandstr'\n    },\n    {\n        way: \".1='Laatzener Str. 1,30539 Hannover'&\" +\n             \".2='Horsterfeld 1,31542 Bad Nenndorf'\",\n        threshold: 5,\n        name: 'Office2Home'\n    },\n       {\n        way: \".1='Laatzener Str. 1,30539 Hannover'&\" +\n             \"via.2='A37, 30655 Gross Buchholz'&\" +\n             \".3='Horsterfeld 1,31542 Bad Nenndorf'\",\n        threshold: 5,\n        name: 'Office2HomeA2'\n    }\n];\n\nreturn msg;",
                                                  "x": 460,
                                                  "y": 60,
                                                  "wires": []
                                              },
                                              {
                                                  "id": "59391f0e.ac165",
                                                  "type": "function",
                                                  "z": "f38be5c5.594708",
                                                  "name": "extractData",
                                                  "func": "/*\n\nreturns:\n\n1\\. travelDurationTraffic in min\n\n2\\. travelDuration in min\n\n3\\. traveDelay in min\n\n4\\. trafficJam boolean\n\n5\\. trafficCongestion string\n\n6\\. travelDistance in km\n\n7\\. msg object (for debugging and return to the loop)\n\n*/\n\nvar travelDurationTraffic = Math.ceil(msg.payload.resourceSets[0].resources[0].travelDurationTraffic / 60);\n\nvar travelDuration = Math.ceil(msg.payload.resourceSets[0].resources[0].travelDuration / 60);\n\n \n\nvar msgTraffic = [\n\n    {\n\n        topic: msg.topic_prefix + \".name\",\n\n        payload: msg.name\n\n    },\n\n    {\n\n        topic: msg.topic_prefix + \".travelDurationTraffic\",\n\n        payload: travelDurationTraffic\n\n    },\n\n    {    \n\n        topic: msg.topic_prefix + \".travelDuration\",\n\n        payload: travelDuration\n\n    },\n\n    {    \n\n        topic: msg.topic_prefix + \".travelDelay\",\n\n        payload: travelDurationTraffic - travelDuration\n\n    },\n\n    {    \n\n        topic: msg.topic_prefix + \".trafficJam\",\n\n        payload: (travelDurationTraffic - travelDuration >= msg.threshold)\n\n    },\n\n    {    \n\n        topic: msg.topic_prefix + \".trafficCongestion\",\n\n        payload: msg.payload.resourceSets[0].resources[0].trafficCongestion\n\n    },\n\n    {    \n\n        topic: msg.topic_prefix + \".travelDistance\",\n\n        payload: msg.payload.resourceSets[0].resources[0].travelDistance\n\n    },\n    \n    {    \n\n        topic: msg.topic_prefix + \".travelDescription\",\n\n        payload: msg.payload.resourceSets[0].resources[0].routeLegs[0].description\n\n    }\n\n];\n\nreturn [msgTraffic,msg];\n\n ",
                                                  "outputs": 2,
                                                  "noerr": 0,
                                                  "x": 330,
                                                  "y": 680,
                                                  "wires": [
                                                      [
                                                          "51df14db.22edcc"
                                                      ],
                                                      [
                                                          "dc7542ef.84429"
                                                      ]
                                                  ]
                                              }
                                          ]
                                          
                                          1 Reply Last reply Reply Quote 1
                                          • R
                                            root_ last edited by

                                            Ich habe neuerdings ein tolles Phänomen. Ich habe 2 Routen bei denen seit ca einer Woche teilweise minus Werte bei der Route statt minimal 0. Die werte werden aber abgefragt und es wird auch Stau angezeigt.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            471
                                            Online

                                            31.7k
                                            Users

                                            79.9k
                                            Topics

                                            1.3m
                                            Posts

                                            22
                                            57
                                            16687
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo