Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Skripten des E-Control Spritpreisrechners

    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

    Skripten des E-Control Spritpreisrechners

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

      @lastyle
      Nein, das veröffentlichen überlasse ich den Designprofis in diesem Forum. Meine Views stammen großteils noch aus Zeiten der legendären "ccu.io".
      66e38d4b-0e13-4d0d-bfd7-58872394924f-grafik.png
      Pass bitte bei den Datenpunkten auf, die habe ich nach meinen Gegebenheiten gecodet.
      mxa

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

        kann mann denn die zahlen beliebig wählen?
        //Aral=1, eni=2, Shell=3,
        hab nähmlich 2 verschiedene Tankstellen die aber die selbe Bild nummer haben?
        zb.: bp=6 und die discont tankstelle in der nähe hat auch du nr. 6, wie kann ich dass ändern?

        Negalein 2 Replies Last reply Reply Quote 0
        • Negalein
          Negalein Global Moderator @Reese1 last edited by

          @Reese1 sagte in Skripten des E-Control Spritpreisrechners:

          kann mann denn die zahlen beliebig wählen?
          //Aral=1, eni=2, Shell=3,
          hab nähmlich 2 verschiedene Tankstellen die aber die selbe Bild nummer haben?
          zb.: bp=6 und die discont tankstelle in der nähe hat auch du nr. 6, wie kann ich dass ändern?

          Ja, geht.
          und Bilder dann richtig benennen.

          Zeig mal dein Script.

          1 Reply Last reply Reply Quote 0
          • R
            Reese1 last edited by Negalein

            hier dass script, nur 16 und 17 laufen nicht.

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //  "Spritpreise_AT v.0.5"                                                                                                              //
            //  e-control Spritpreise                                                                                                               //    
            //  ursprüngl. Script von steinejo_io vom                                                                                               //
            //                                                                                                                                      //
            //  Zwingend erforderlich sind der Parser Adapter und die URL aus der API. Links und Hilfe zum Erstellemn findet ihr im Folgenden Lnk:  //
            //  https://forum.iobroker.net/topic/20314/skripten-des-e-control-spritpreisrechners                                                    //
            //  Das manuelle Anlegen von Daenpunkten ist nicht mehr notwendig. erledigt das Script beim ersten Aufruf.                              //
            //  Auf das "E" Zeichen habe ich verzichtet, da es in VIS genz einfach an der jeweils gewünschten Stelle produzierbar ist.              //
            //                                                                                                                                      //
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            
            on({id: "parser.0.Spritpreisrechner"/*Spritpreisrechner*/, change: 'any'}, function(obj)
            
            {
            log("Start Spritvergleich");
            
               var gasStation = JSON.parse(obj.state.val);
            
               if (gasStation.length === 0) return;
            
               //Aral=1, eni=2, Shell=3, OMV=4, avanti=5, bp=6, JET=7, Turmöl=8, Lagerhaus=9, AVIA=10, A1=11, Diskont=12, IQ=13, Heppner & Oberndorfer Bedienungstankstelle=14, Genol - Lagerhaus=15, Land lebt auf Suben Gmbh=16, SB-Tankstelle Zauner=17,
            
               var arrMarke = ['Aral', 'eni', 'Shell', 'OMV', 'avanti', 'bp', 'JET', 'Turmöl', 'Lagerhaus', 'AVIA', 'A1', 'Diskont', 'IQ', 'Heppner & Oberndorfer Bedienungstankstelle', 'Genol - Lagerhaus', 'Land lebt auf Suben Gmbh', 'SB-Tankstelle Zauner' ];
            
               var i = 0;
            
               for (var i = 1; i <= 5; i++) {
            
                   // console.log(i);
                   // console.log("javascript.0.Sprit_AT.name_"+i);
            
                   createState("javascript.0.Sprit_AT.Treffer_"+i+".Name_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                   createState("javascript.0.Sprit_AT.Treffer_"+i+".Preis_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                   createState("javascript.0.Sprit_AT.Treffer_"+i+".PreisP_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
               	createState("javascript.0.Sprit_AT.Treffer_"+i+".Strasse_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                   createState("javascript.0.Sprit_AT.Treffer_"+i+".PLZ_Ort_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                   createState("javascript.0.Sprit_AT.Treffer_"+i+".Logo_"+i, {type: "number", name: "Logo "+i, read: true, write: true});
               	createState("javascript.0.Sprit_AT.Treffer_"+i+".Latitude_"+i, {type: "number", name: "Latitude "+i, read: true, write: true});
               	createState("javascript.0.Sprit_AT.Treffer_"+i+".Longitude_"+i, {type: "number", name: "Longitude "+i, read: true, write: true});
               	createState("javascript.0.Sprit_AT.Treffer_"+i+".offen_"+i, {type: "boolean", name: "offen "+i, read: true, write: true});
            
               }
            
               var index = 0;
            
               //for (index = 0; index < gasStation.length; ++index) {
               for (index = 0; index <= 4; ++index) {
            
               var arrname = gasStation[index].name.split(' ');
               	if (arrname.length > 0) {
               			var markenname = arrname[0];
               		}
               		else
               		{
               			var markenname = gasStation[index].name;
               		}
               	var station = gasStation[index].name;
               setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Name_"+(index+1), gasStation[index].name);
               setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Preis_"+(index+1), (gasStation[index].prices[0].amount).toString().replace(".",","));
               setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".PreisP_"+(index+1), (gasStation[index].prices[0].amount).toString().replace(".","."));
               setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Strasse_"+(index+1), (gasStation[index].location.address));
               setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".PLZ_Ort_"+(index+1), (gasStation[index].location.postalCode) + " " + (gasStation[index].location.city));
               setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Latitude_"+(index+1), (gasStation[index].location.latitude));
               setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Longitude_"+(index+1), (gasStation[index].location.longitude));
               setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".offen_"+(index+1), (gasStation[index].open));
            
               // Aral=1, eni=2, Shell=3, OMV=4, avanti=5, bp=6, JET=7, Turmöl=8, Lagerhaus=9, AVIA=10, A1=11, Diskont=12, IQ=13, Heppner & Oberndorfer Bedienungstankstelle=14, Genol - Lagerhaus=15, Land lebt auf Suben Gmbh=16, SB-Tankstelle Zauner=17, 
            
               var markennameklein=markenname.toLowerCase();
               var x= 0;
               for (x=0; x < arrMarke.length; x++) {
               	var arrMklein=arrMarke[x].toLowerCase();
               	//console.log("x=" + x + "/ Markennameklein =" + markennameklein + "/ Array =" + arrMklein);
               	if (arrMklein == markennameklein) {
               		setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Logo_"+(index+1), (x+1));
               	}
               }
               }
            log("Ende Spritvergleich");
            });
            
            Negalein 1 Reply Last reply Reply Quote 0
            • Negalein
              Negalein Global Moderator @Reese1 last edited by

              @Reese1 sagte in Skripten des E-Control Spritpreisrechners:

              bp=6 und die discont tankstelle in der nähe hat auch du nr. 6

              wie kommst du auf Nr. 6 bei der Discont?

              Welche möchtest du im Script, bzw. welche scheinen bei dir bei der Abfrage auf?

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

                ich möchte die SB Tankstelle Zauner zb mit nummer 17, und die Tankstelle land lebt auf mit nummer 16, aber auch nach ändern im script wird bei der ersten tankstelle bild nr 6 abgerufen,

                1 Reply Last reply Reply Quote 0
                • Negalein
                  Negalein Global Moderator @Reese1 last edited by

                  @Reese1 sagte in Skripten des E-Control Spritpreisrechners:

                  nur 16 und 17 laufen nicht.

                  wenn die funktionieren sollen, müsstest du in meiner Nachbarschaft sein 😉

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

                    ja genau so ist es auch, 😀

                    Negalein 1 Reply Last reply Reply Quote 0
                    • Negalein
                      Negalein Global Moderator @Reese1 last edited by

                      @Reese1 sagte in Skripten des E-Control Spritpreisrechners:

                      ja genau so ist es auch

                      Cool, von wo genau? Gerne auch als PN.

                      Schreib hier mal, welche Tankstellen du möchtest und schick auch die Bilder mit.

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

                        folgende bilder habe ich:
                        hofer, avanti, bp, jet, aral, lagerhaus
                        fehlen tun mir
                        land lebt auf suben, tankstelle zauner

                        Negalein 1 Reply Last reply Reply Quote 0
                        • Negalein
                          Negalein Global Moderator @Reese1 last edited by

                          @Reese1 sagte in Skripten des E-Control Spritpreisrechners:

                          folgende bilder habe ich:
                          hofer, avanti, bp, jet, aral, lagerhaus
                          fehlen tun mir
                          land lebt auf suben, tankstelle zauner

                          Ok, warte kurz

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

                            wo ist der button für pn?? bin wohl blind 😎

                            Negalein 1 Reply Last reply Reply Quote 0
                            • Negalein
                              Negalein Global Moderator @Reese1 last edited by

                              @Reese1 sagte in Skripten des E-Control Spritpreisrechners:

                              wo ist der button für pn?? bin wohl blind

                              auf mein Profilbild klicken
                              rechts dann die 3 Punkte
                              Beginne einen neuen Chat mit

                              1 Reply Last reply Reply Quote 0
                              • Negalein
                                Negalein Global Moderator last edited by

                                @Reese1

                                Hier mal die Bilder! BP ist 2x, da es oft bpund oft BPgeschrieben wird.


                                9.png 8.png 7.png 6.png 5.png 4.png 3.png 2.png 1.png

                                Hier das Script

                                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                //  "Spritpreise_AT v.0.5"                                                                                                              //
                                //  e-control Spritpreise                                                                                                               //    
                                //  ursprüngl. Script von steinejo_io vom                                                                                               //
                                //                                                                                                                                      //
                                //  Zwingend erforderlich sind der Parser Adapter und die URL aus der API. Links und Hilfe zum Erstellemn findet ihr im Folgenden Lnk:  //
                                //  https://forum.iobroker.net/topic/20314/skripten-des-e-control-spritpreisrechners                                                    //
                                //  Das manuelle Anlegen von Daenpunkten ist nicht mehr notwendig. erledigt das Script beim ersten Aufruf.                              //
                                //  Auf das "E" Zeichen habe ich verzichtet, da es in VIS genz einfach an der jeweils gewünschten Stelle produzierbar ist.              //
                                //                                                                                                                                      //
                                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                 
                                on({id: "parser.0.Spritpreisrechner"/*Spritpreisrechner*/, change: 'any'}, function(obj)
                                {
                                log("Start Spritvergleich");
                                 
                                var gasStation = JSON.parse(obj.state.val);
                                if (!Array.isArray(gasStation) || gasStation.length === 0) return;
                                gasStation = gasStation.filter(g => g.prices.length > 0);
                                if (gasStation.length === 0) return;
                                    //Aral=1, avanti=2, bp=3, JET=4, Lagerhaus=5, Diskont=6, SB-Tankstelle=7, Land=8, BP=9
                                    var arrMarke = ['Aral', 'avanti', 'bp', 'JET', 'Lagerhaus', 'Diskont', 'SB-Tankstelle', 'Land', 'BP'];
                                	var i = 0;
                                    for (var i = 1; i <= 5; i++) {
                                        // console.log(i);
                                        // console.log("javascript.0.Sprit_AT.name_"+i);
                                        createState("javascript.0.Sprit_AT.Treffer_"+i+".Name_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                                        createState("javascript.0.Sprit_AT.Treffer_"+i+".Preis_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                                        createState("javascript.0.Sprit_AT.Treffer_"+i+".PreisP_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                                		createState("javascript.0.Sprit_AT.Treffer_"+i+".Strasse_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                                        createState("javascript.0.Sprit_AT.Treffer_"+i+".PLZ_Ort_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                                        createState("javascript.0.Sprit_AT.Treffer_"+i+".Logo_"+i, {type: "number", name: "Logo "+i, read: true, write: true});
                                		createState("javascript.0.Sprit_AT.Treffer_"+i+".Latitude_"+i, {type: "number", name: "Latitude "+i, read: true, write: true});
                                		createState("javascript.0.Sprit_AT.Treffer_"+i+".Longitude_"+i, {type: "number", name: "Longitude "+i, read: true, write: true});
                                		createState("javascript.0.Sprit_AT.Treffer_"+i+".offen_"+i, {type: "boolean", name: "offen "+i, read: true, write: true});
                                	}
                                	
                                 
                                    var index = 0;
                                    //for (index = 0; index < gasStation.length; ++index) {
                                    for (index = 0; index <= 4; ++index) {
                                	if (gasStation[index].prices.length < 1) continue;
                                	var arrname = gasStation[index].name.split(' ');
                                		if (arrname.length > 0) {
                                				var markenname = arrname[0];
                                			}
                                			else
                                			{
                                				var markenname = gasStation[index].name;
                                			}
                                		var station = gasStation[index].name;
                                    setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Name_"+(index+1), gasStation[index].name);
                                    setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Preis_"+(index+1), (gasStation[index].prices[0].amount).toString().replace(".",","));
                                    setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".PreisP_"+(index+1), (gasStation[index].prices[0].amount).toString().replace(".","."));
                                	setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Strasse_"+(index+1), (gasStation[index].location.address));
                                    setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".PLZ_Ort_"+(index+1), (gasStation[index].location.postalCode) + " " + (gasStation[index].location.city));
                                    setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Latitude_"+(index+1), (gasStation[index].location.latitude));
                                	setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Longitude_"+(index+1), (gasStation[index].location.longitude));
                                	setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".offen_"+(index+1), (gasStation[index].open));
                                	
                                	//Aral=1, eni=2, Shell=3, OMV=4, avanti=5, bp=6, JET=7, Turmöl=8, Lagerhaus=9, AVIA=10, A1=11, Diskont=12, IQ=13
                                	
                                	var markennameklein=markenname.toLowerCase();
                                	var x= 0;
                                	for (x=0; x < arrMarke.length; x++) {
                                		var arrMklein=arrMarke[x].toLowerCase();
                                		//console.log("x=" + x + "/ Markennameklein =" + markennameklein + "/ Array =" + arrMklein);
                                		if (arrMklein == markennameklein) {
                                			setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Logo_"+(index+1), (x+1));
                                		}
                                	}
                                	
                                	}
                                 
                                log("Ende Spritvergleich");
                                });
                                

                                Probier es mal. Müsste passen.

                                maximal1981 1 Reply Last reply Reply Quote 0
                                • R
                                  Reese1 last edited by

                                  super Vielen Dank, teste ich gleich, 🙂

                                  1 Reply Last reply Reply Quote 0
                                  • maximal1981
                                    maximal1981 @Negalein last edited by

                                    @Negalein said in Skripten des E-Control Spritpreisrechners:

                                    @Reese1

                                    Hier mal die Bilder! BP ist 2x, da es oft bpund oft BPgeschrieben wird.


                                    9.png 8.png 7.png 6.png 5.png 4.png 3.png 2.png 1.png

                                    Hier das Script

                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                    //  "Spritpreise_AT v.0.5"                                                                                                              //
                                    //  e-control Spritpreise                                                                                                               //    
                                    //  ursprüngl. Script von steinejo_io vom                                                                                               //
                                    //                                                                                                                                      //
                                    //  Zwingend erforderlich sind der Parser Adapter und die URL aus der API. Links und Hilfe zum Erstellemn findet ihr im Folgenden Lnk:  //
                                    //  https://forum.iobroker.net/topic/20314/skripten-des-e-control-spritpreisrechners                                                    //
                                    //  Das manuelle Anlegen von Daenpunkten ist nicht mehr notwendig. erledigt das Script beim ersten Aufruf.                              //
                                    //  Auf das "E" Zeichen habe ich verzichtet, da es in VIS genz einfach an der jeweils gewünschten Stelle produzierbar ist.              //
                                    //                                                                                                                                      //
                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                     
                                    on({id: "parser.0.Spritpreisrechner"/*Spritpreisrechner*/, change: 'any'}, function(obj)
                                    {
                                    log("Start Spritvergleich");
                                     
                                    var gasStation = JSON.parse(obj.state.val);
                                    if (!Array.isArray(gasStation) || gasStation.length === 0) return;
                                    gasStation = gasStation.filter(g => g.prices.length > 0);
                                    if (gasStation.length === 0) return;
                                        //Aral=1, avanti=2, bp=3, JET=4, Lagerhaus=5, Diskont=6, SB-Tankstelle=7, Land=8, BP=9
                                        var arrMarke = ['Aral', 'avanti', 'bp', 'JET', 'Lagerhaus', 'Diskont', 'SB-Tankstelle', 'Land', 'BP'];
                                    	var i = 0;
                                        for (var i = 1; i <= 5; i++) {
                                            // console.log(i);
                                            // console.log("javascript.0.Sprit_AT.name_"+i);
                                            createState("javascript.0.Sprit_AT.Treffer_"+i+".Name_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                                            createState("javascript.0.Sprit_AT.Treffer_"+i+".Preis_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                                            createState("javascript.0.Sprit_AT.Treffer_"+i+".PreisP_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                                    		createState("javascript.0.Sprit_AT.Treffer_"+i+".Strasse_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                                            createState("javascript.0.Sprit_AT.Treffer_"+i+".PLZ_Ort_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                                            createState("javascript.0.Sprit_AT.Treffer_"+i+".Logo_"+i, {type: "number", name: "Logo "+i, read: true, write: true});
                                    		createState("javascript.0.Sprit_AT.Treffer_"+i+".Latitude_"+i, {type: "number", name: "Latitude "+i, read: true, write: true});
                                    		createState("javascript.0.Sprit_AT.Treffer_"+i+".Longitude_"+i, {type: "number", name: "Longitude "+i, read: true, write: true});
                                    		createState("javascript.0.Sprit_AT.Treffer_"+i+".offen_"+i, {type: "boolean", name: "offen "+i, read: true, write: true});
                                    	}
                                    	
                                     
                                        var index = 0;
                                        //for (index = 0; index < gasStation.length; ++index) {
                                        for (index = 0; index <= 4; ++index) {
                                    	if (gasStation[index].prices.length < 1) continue;
                                    	var arrname = gasStation[index].name.split(' ');
                                    		if (arrname.length > 0) {
                                    				var markenname = arrname[0];
                                    			}
                                    			else
                                    			{
                                    				var markenname = gasStation[index].name;
                                    			}
                                    		var station = gasStation[index].name;
                                        setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Name_"+(index+1), gasStation[index].name);
                                        setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Preis_"+(index+1), (gasStation[index].prices[0].amount).toString().replace(".",","));
                                        setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".PreisP_"+(index+1), (gasStation[index].prices[0].amount).toString().replace(".","."));
                                    	setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Strasse_"+(index+1), (gasStation[index].location.address));
                                        setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".PLZ_Ort_"+(index+1), (gasStation[index].location.postalCode) + " " + (gasStation[index].location.city));
                                        setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Latitude_"+(index+1), (gasStation[index].location.latitude));
                                    	setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Longitude_"+(index+1), (gasStation[index].location.longitude));
                                    	setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".offen_"+(index+1), (gasStation[index].open));
                                    	
                                    	//Aral=1, eni=2, Shell=3, OMV=4, avanti=5, bp=6, JET=7, Turmöl=8, Lagerhaus=9, AVIA=10, A1=11, Diskont=12, IQ=13
                                    	
                                    	var markennameklein=markenname.toLowerCase();
                                    	var x= 0;
                                    	for (x=0; x < arrMarke.length; x++) {
                                    		var arrMklein=arrMarke[x].toLowerCase();
                                    		//console.log("x=" + x + "/ Markennameklein =" + markennameklein + "/ Array =" + arrMklein);
                                    		if (arrMklein == markennameklein) {
                                    			setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Logo_"+(index+1), (x+1));
                                    		}
                                    	}
                                    	
                                    	}
                                     
                                    log("Ende Spritvergleich");
                                    });
                                    

                                    Probier es mal. Müsste passen.

                                    hab mal dein Script ausprobiert, leider bekomme ich nur laut aktuellem Preisstand nur beim 1. Treffer für das Logo einen Wert retour. Liegt vermutlich daran, dass es hier ein paar unbekannte Anbieter gibt. kann man das vll vernünftig einbinden?
                                    ich hab leider keine Ahnung wie ich das realisieren kann.
                                    Denke aber es würde etlichen helfen, wenn du dein Script um gewisse Tankstellen erweiterst, oder es vernünftig erklärst.

                                    tempsnip.png

                                    Negalein 1 Reply Last reply Reply Quote 0
                                    • Negalein
                                      Negalein Global Moderator @maximal1981 last edited by

                                      @maximal1981 sagte in Skripten des E-Control Spritpreisrechners:

                                      Denke aber es würde etlichen helfen, wenn du dein Script um gewisse Tankstellen erweiterst, oder es vernünftig erklärst.

                                      Vorweg, das Script ist nicht von mir.
                                      Ist ursprünglich von @steinejo_io erstellt worden. Dann von @metaxa und @klaus88 erweitert worden.

                                      Zu deinem Problem.

                                      Was kommt bei dir, wenn du die JSON im Browser aufrufst?

                                      Wie sehen deine Logos aus?

                                      Was hast du am Script angepasst?

                                      maximal1981 1 Reply Last reply Reply Quote 0
                                      • maximal1981
                                        maximal1981 @Negalein last edited by

                                        @Negalein said in Skripten des E-Control Spritpreisrechners:

                                        Wie sehen deine Logos aus?

                                        Was hast du am Script angepasst?

                                        Logos hab ich noch keine. Bin aktuell nur am Admin-Interface unterwegs.

                                        mein Script sieht aktuell so aus:

                                        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                        //  "Spritpreise_AT v.0.5"                                                                                                              //
                                        //  e-control Spritpreise                                                                                                               //    
                                        //  ursprüngl. Script von steinejo_io vom                                                                                               //
                                        //                                                                                                                                      //
                                        //  Zwingend erforderlich sind der Parser Adapter und die URL aus der API. Links und Hilfe zum Erstellemn findet ihr im Folgenden Lnk:  //
                                        //  https://forum.iobroker.net/topic/20314/skripten-des-e-control-spritpreisrechners                                                    //
                                        //  Das manuelle Anlegen von Daenpunkten ist nicht mehr notwendig. erledigt das Script beim ersten Aufruf.                              //
                                        //  Auf das "E" Zeichen habe ich verzichtet, da es in VIS genz einfach an der jeweils gewünschten Stelle produzierbar ist.              //
                                        //                                                                                                                                      //
                                        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                         
                                        on({id: "parser.0.Spritpreisrechner"/*Spritpreisrechner*/, change: 'any'}, function(obj)
                                        {
                                        log("Start Spritvergleich");
                                         
                                        var gasStation = JSON.parse(obj.state.val);
                                        if (!Array.isArray(gasStation) || gasStation.length === 0) return;
                                        gasStation = gasStation.filter(g => g.prices.length > 0);
                                        if (gasStation.length === 0) return;
                                            //Aral=1, avanti=2, bp=3, JET=4, Lagerhaus=5, Diskont=6, SB-Tankstelle=7, Land=8, BP=9
                                            var arrMarke = ['Aral', 'avanti', 'bp', 'JET', 'Lagerhaus', 'Diskont', 'SB-Tankstelle', 'Land', 'BP', 'JOBA'];
                                        	var i = 0;
                                            for (var i = 1; i <= 5; i++) {
                                                // console.log(i);
                                                // console.log("javascript.0.Sprit_AT.name_"+i);
                                                createState("javascript.0.Sprit_AT.Treffer_"+i+".Name_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                                                createState("javascript.0.Sprit_AT.Treffer_"+i+".Preis_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                                                createState("javascript.0.Sprit_AT.Treffer_"+i+".PreisP_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                                        		createState("javascript.0.Sprit_AT.Treffer_"+i+".Strasse_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                                                createState("javascript.0.Sprit_AT.Treffer_"+i+".PLZ_Ort_"+i, {type: "string", name: "Platz "+i, read: true, write: true});
                                                createState("javascript.0.Sprit_AT.Treffer_"+i+".Logo_"+i, {type: "number", name: "Logo "+i, read: true, write: true});
                                        		createState("javascript.0.Sprit_AT.Treffer_"+i+".Latitude_"+i, {type: "number", name: "Latitude "+i, read: true, write: true});
                                        		createState("javascript.0.Sprit_AT.Treffer_"+i+".Longitude_"+i, {type: "number", name: "Longitude "+i, read: true, write: true});
                                        		createState("javascript.0.Sprit_AT.Treffer_"+i+".offen_"+i, {type: "boolean", name: "offen "+i, read: true, write: true});
                                        	}
                                        	
                                         
                                            var index = 0;
                                            //for (index = 0; index < gasStation.length; ++index) {
                                            for (index = 0; index <= 4; ++index) {
                                        	if (gasStation[index].prices.length < 1) continue;
                                        	var arrname = gasStation[index].name.split(' ');
                                        		if (arrname.length > 0) {
                                        				var markenname = arrname[0];
                                        			}
                                        			else
                                        			{
                                        				var markenname = gasStation[index].name;
                                        			}
                                        		var station = gasStation[index].name;
                                            setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Name_"+(index+1), gasStation[index].name);
                                            setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Preis_"+(index+1), (gasStation[index].prices[0].amount).toString().replace(".",","));
                                            setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".PreisP_"+(index+1), (gasStation[index].prices[0].amount).toString().replace(".","."));
                                        	setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Strasse_"+(index+1), (gasStation[index].location.address));
                                            setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".PLZ_Ort_"+(index+1), (gasStation[index].location.postalCode) + " " + (gasStation[index].location.city));
                                            setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Latitude_"+(index+1), (gasStation[index].location.latitude));
                                        	setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Longitude_"+(index+1), (gasStation[index].location.longitude));
                                        	setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".offen_"+(index+1), (gasStation[index].open));
                                        	
                                        	//Aral=1, eni=2, Shell=3, OMV=4, avanti=5, bp=6, JET=7, Turmöl=8, Lagerhaus=9, AVIA=10, A1=11, Diskont=12, IQ=13
                                        	
                                        	var markennameklein=markenname.toLowerCase();
                                        	var x= 0;
                                        	for (x=0; x < arrMarke.length; x++) {
                                        		var arrMklein=arrMarke[x].toLowerCase();
                                        		//console.log("x=" + x + "/ Markennameklein =" + markennameklein + "/ Array =" + arrMklein);
                                        		if (arrMklein == markennameklein) {
                                        			setState("javascript.0.Sprit_AT.Treffer_"+(index+1)+".Logo_"+(index+1), (x+1));
                                        		}
                                        	}
                                        	
                                        	}
                                         
                                        log("Ende Spritvergleich");
                                        });
                                        

                                        was ich mich nur bis dato Frage, warum hat keiner einen Adapter daraus gebaut, sondern "parst" das ganze?
                                        Im Endeffekt macht der Adapter eh das selbe, aber man kann leichter mehrere Instanzen erzeugen, aber bin auf eure Antworten diesbezüglich gespannt.

                                        Negalein 1 Reply Last reply Reply Quote 0
                                        • Negalein
                                          Negalein Global Moderator @maximal1981 last edited by

                                          @maximal1981 sagte in Skripten des E-Control Spritpreisrechners:

                                          was ich mich nur bis dato Frage, warum hat keiner einen Adapter daraus gebaut, sondern "parst" das ganze?

                                          schätze Österreich ist einfach zu klein dafür.

                                          Fangen wir der Reihe nach an.
                                          Logos machen wir ganz am Schluss.

                                          Schick mir mal die Ausgabe vom API-Link im Browser.
                                          https://api.e-control.at/sprit/1.0/search/gas-stations/by-address?latitude=XX.XXXXXX&longitude=XX.XXXXXX&fuelType=DIE&includeClosed=false

                                          latitude XX.XXXXXX & longitude XX.XXXXXX durch deine bevorzugten Koordinaten ersetzen.

                                          Längen und Breitengrad zB auf https://www.latlong.net/

                                          maximal1981 1 Reply Last reply Reply Quote 0
                                          • maximal1981
                                            maximal1981 @Negalein last edited by

                                            @Negalein said in Skripten des E-Control Spritpreisrechners:

                                            Schick mir mal die Ausgabe vom API-Link im Browser.

                                            das ist ja kein Problem, den hab ich schon im Parser:

                                            [{"id":33596,"name":"AVIA ","location":{"address":"Keltenstraße 2","postalCode":"3100","city":"St. Pölten-Ratzersdorf","latitude":48.2279934,"longitude":15.6768304},"contact":{"telephone":"43274224668","fax":"43274224677","mail":"avia@marchhart.com","website":"http://www.peugeot-marchhart.at"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"05:00","to":"22:00"},{"day":"DI","label":"Dienstag","order":2,"from":"05:00","to":"22:00"},{"day":"MI","label":"Mittwoch","order":3,"from":"05:00","to":"22:00"},{"day":"DO","label":"Donnerstag","order":4,"from":"05:00","to":"22:00"},{"day":"FR","label":"Freitag","order":5,"from":"05:00","to":"22:00"},{"day":"SA","label":"Samstag","order":6,"from":"06:00","to":"22:00"},{"day":"SO","label":"Sonntag","order":7,"from":"07:00","to":"21:00"},{"day":"FE","label":"Feiertag","order":8,"from":"07:00","to":"21:00"}],"offerInformation":{"service":false,"selfService":true,"unattended":false},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true,"others":"AVIAmat-Tankkarte"},"paymentArrangements":{"cooperative":false,"clubCard":false},"otherServiceOffers":"Portalwaschanlage, SB-Waschbox, SB-Sauger, LKW-tauglich, LKW-Hochleistungssäule, CNG/Erdgas, AdBlue, Shop, Bistro, Kundentelefon, Vignettenverkauf, Internet-Terminal","position":1,"open":true,"distance":4.388640888551343,"prices":[{"fuelType":"SUP","amount":1.072,"label":"Super 95"}]},{"id":109233,"name":"JOBA-Diskont Tanken","location":{"address":"Hauptstrasse 48","postalCode":"3140","city":"Pottenbrunn","latitude":48.234907,"longitude":15.6905083},"contact":{"telephone":"43274242522","fax":"43274242516","mail":"tankstelle.bichler@aon.at"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"06:00","to":"21:00"},{"day":"DI","label":"Dienstag","order":2,"from":"06:00","to":"21:00"},{"day":"MI","label":"Mittwoch","order":3,"from":"06:00","to":"21:00"},{"day":"DO","label":"Donnerstag","order":4,"from":"06:00","to":"21:00"},{"day":"FR","label":"Freitag","order":5,"from":"06:00","to":"21:00"},{"day":"SA","label":"Samstag","order":6,"from":"07:00","to":"20:00"},{"day":"SO","label":"Sonntag","order":7,"from":"07:00","to":"20:00"},{"day":"FE","label":"Feiertag","order":8,"from":"07:00","to":"20:00"}],"offerInformation":{"service":false,"selfService":true,"unattended":false},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true},"paymentArrangements":{"cooperative":false,"clubCard":false},"otherServiceOffers":"Tankstelle,Gasthaus,,Lotto,Blumengeschäft,Postpartner,Shop,Werkstätte,Zimmer.\r\nWir betanken auch gerne(falls gewünscht)Ihr Fahrzeug!","position":2,"open":true,"distance":4.590168849388595,"prices":[{"fuelType":"SUP","amount":1.073,"label":"Super 95"}]},{"id":33627,"name":"AVIA mit Bedienung","location":{"postalCode":"3071","city":"Fahrafeld 15","latitude":48.146059,"longitude":15.749009},"contact":{"telephone":"4327445619","fax":"4327445619","mail":"office@eigl.at"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"07:00","to":"18:00"},{"day":"DI","label":"Dienstag","order":2,"from":"07:00","to":"18:00"},{"day":"MI","label":"Mittwoch","order":3,"from":"07:00","to":"18:00"},{"day":"DO","label":"Donnerstag","order":4,"from":"07:00","to":"18:00"},{"day":"FR","label":"Freitag","order":5,"from":"07:00","to":"18:00"},{"day":"SA","label":"Samstag","order":6,"from":"07:00","to":"13:00"},{"day":"SO","label":"Sonntag","order":7,"from":"07:00","to":"20:00"},{"day":"FE","label":"Feiertag","order":8,"from":"07:00","to":"20:00"}],"offerInformation":{"service":true,"selfService":false,"unattended":false},"paymentMethods":{"cash":true,"debitCard":false,"creditCard":false},"paymentArrangements":{"cooperative":false,"clubCard":false},"otherServiceOffers":"Kaufhaus","position":3,"open":false,"distance":6.225483712914487,"prices":[{"fuelType":"SUP","amount":1.079,"label":"Super 95"}]},{"id":6219,"name":"Genol - Raiffeisenlagerhaus St. Pölten","location":{"address":"Obere Hauptstrasse 41","postalCode":"3071","city":"Böheimkirchen","latitude":48.198248,"longitude":15.753644},"contact":{"telephone":"4327432224","fax":"432743222475","mail":"energie@stpoelten.rlh.at","website":"http://www.lagerhaus-stpoelten.at"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"00:00","to":"24:00"},{"day":"DI","label":"Dienstag","order":2,"from":"00:00","to":"24:00"},{"day":"MI","label":"Mittwoch","order":3,"from":"00:00","to":"24:00"},{"day":"DO","label":"Donnerstag","order":4,"from":"00:00","to":"24:00"},{"day":"FR","label":"Freitag","order":5,"from":"00:00","to":"24:00"},{"day":"SA","label":"Samstag","order":6,"from":"00:00","to":"24:00"},{"day":"SO","label":"Sonntag","order":7,"from":"00:00","to":"24:00"},{"day":"FE","label":"Feiertag","order":8,"from":"00:00","to":"24:00"}],"offerInformation":{"service":false,"selfService":false,"unattended":true},"paymentMethods":{"cash":false,"debitCard":true,"creditCard":true,"others":"Kundenkarte"},"paymentArrangements":{"cooperative":false,"clubCard":false},"otherServiceOffers":"Kundenkarte holen und Geld sparen.\r\nTanken Sie von 00.00 bis 24.00 Uhr mit Bankomat, Kreditkarte und Kundenkarte.","position":4,"open":true,"distance":3.114868916867809,"prices":[{"fuelType":"SUP","amount":1.084,"label":"Super 95"}]},{"id":1354797,"name":"avanti - Sankt Pölten Wiener Straße 92","location":{"address":"Wiener Strasse 92","postalCode":"3100","city":"Sankt Poelten","latitude":48.20673,"longitude":15.64125},"contact":{"telephone":"800202055","fax":"800","website":"www.omv.com"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"06:00","to":"22:00"},{"day":"DI","label":"Dienstag","order":2,"from":"06:00","to":"22:00"},{"day":"MI","label":"Mittwoch","order":3,"from":"06:00","to":"22:00"},{"day":"DO","label":"Donnerstag","order":4,"from":"06:00","to":"22:00"},{"day":"FR","label":"Freitag","order":5,"from":"06:00","to":"22:00"},{"day":"SA","label":"Samstag","order":6,"from":"06:00","to":"22:00"},{"day":"SO","label":"Sonntag","order":7,"from":"07:00","to":"21:00"},{"day":"FE","label":"Feiertag","order":8,"from":"07:00","to":"21:00"}],"offerInformation":{"service":false,"selfService":true,"unattended":true},"paymentMethods":{"cash":false,"debitCard":true,"creditCard":true,"others":"OMV STATIONSKARTE, DKV, MASTERCARD, MAESTRO, ROUTEX, DINERS, VISA"},"paymentArrangements":{"cooperative":false,"clubCard":false},"position":5,"open":true,"distance":5.363257419264544,"prices":[{"fuelType":"SUP","amount":1.084,"label":"Super 95"}]},{"id":4089,"name":"Tankstopp","location":{"address":"Hauptstraße 8","postalCode":"3143","city":"Pyhra","latitude":48.1590154,"longitude":15.6848005},"contact":{"telephone":"43274583083","fax":"43274583084","mail":"office@tankstopp.at","website":"http://www.tankstopp.at"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"06:00","to":"22:00"},{"day":"DI","label":"Dienstag","order":2,"from":"06:00","to":"22:00"},{"day":"MI","label":"Mittwoch","order":3,"from":"06:00","to":"22:00"},{"day":"DO","label":"Donnerstag","order":4,"from":"06:00","to":"22:00"},{"day":"FR","label":"Freitag","order":5,"from":"06:00","to":"22:00"},{"day":"SA","label":"Samstag","order":6,"from":"06:00","to":"22:00"},{"day":"SO","label":"Sonntag","order":7,"from":"07:00","to":"19:00"},{"day":"FE","label":"Feiertag","order":8,"from":"07:00","to":"19:00"}],"offerInformation":{"service":false,"selfService":true,"unattended":false},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true,"others":"Tankkarte"},"paymentArrangements":{"cooperative":false,"clubCard":false},"otherServiceOffers":"Stammkundenkartenrabatt 1Cent/Liter","position":6,"open":true,"distance":4.595653008197485,"prices":[]},{"id":247881,"name":"eni","location":{"address":"Wiener Strasse 66","postalCode":"3100","city":"St. Pölten","latitude":48.203264,"longitude":15.637852},"contact":{"telephone":"02742258633","fax":"027422586334"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"05:00","to":"23:00"},{"day":"DI","label":"Dienstag","order":2,"from":"05:00","to":"23:00"},{"day":"MI","label":"Mittwoch","order":3,"from":"05:00","to":"23:00"},{"day":"DO","label":"Donnerstag","order":4,"from":"05:00","to":"23:00"},{"day":"FR","label":"Freitag","order":5,"from":"05:00","to":"23:00"},{"day":"SA","label":"Samstag","order":6,"from":"05:00","to":"23:00"},{"day":"SO","label":"Sonntag","order":7,"from":"05:00","to":"23:00"},{"day":"FE","label":"Feiertag","order":8,"from":"05:00","to":"23:00"}],"offerInformation":{"service":false,"selfService":true,"unattended":false},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true,"others":"AMEX,Maestro,Diners Club,DKV,GUTS,LOGP,MasterCard,Routex,UTA,VISA"},"paymentArrangements":{"cooperative":false,"clubCard":false},"position":7,"open":true,"distance":5.541807776579032,"prices":[]},{"id":35664,"name":"BP","location":{"address":"Hainfelderstr. ","postalCode":"3071","city":"Boeheimkirchen","latitude":48.194014,"longitude":15.765381},"contact":{"telephone":"4327433265","fax":"432743231220","mail":"tremmel.transporte@aon.at"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"06:00","to":"20:30"},{"day":"DI","label":"Dienstag","order":2,"from":"06:00","to":"20:30"},{"day":"MI","label":"Mittwoch","order":3,"from":"06:00","to":"20:30"},{"day":"DO","label":"Donnerstag","order":4,"from":"06:00","to":"20:30"},{"day":"FR","label":"Freitag","order":5,"from":"06:00","to":"20:30"},{"day":"SA","label":"Samstag","order":6,"from":"06:00","to":"20:30"},{"day":"SO","label":"Sonntag","order":7,"from":"07:00","to":"20:30"},{"day":"FE","label":"Feiertag","order":8,"from":"07:00","to":"20:30"}],"offerInformation":{"service":false,"selfService":true,"unattended":false},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true,"others":"Routex"},"paymentArrangements":{"cooperative":false,"clubCard":false},"otherServiceOffers":"Autowash, SB-Wash","position":8,"open":false,"distance":3.984712299523193,"prices":[]},{"id":35766,"name":"BP","location":{"address":"Niederoesterreichring 20 ","postalCode":"3100","city":"St. Poelten","latitude":48.1979429,"longitude":15.6397468},"contact":{"telephone":"432742230033","mail":"R52571@bprosi.at"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"05:00","to":"24:00"},{"day":"DI","label":"Dienstag","order":2,"from":"05:00","to":"24:00"},{"day":"MI","label":"Mittwoch","order":3,"from":"05:00","to":"24:00"},{"day":"DO","label":"Donnerstag","order":4,"from":"05:00","to":"24:00"},{"day":"FR","label":"Freitag","order":5,"from":"05:00","to":"24:00"},{"day":"SA","label":"Samstag","order":6,"from":"05:00","to":"24:00"},{"day":"SO","label":"Sonntag","order":7,"from":"05:00","to":"24:00"},{"day":"FE","label":"Feiertag","order":8,"from":"05:00","to":"24:00"}],"offerInformation":{"service":false,"selfService":true,"unattended":false},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true,"others":"Routex"},"paymentArrangements":{"cooperative":false,"clubCard":false},"otherServiceOffers":"Waschstrasse, Wild Bean Cafe, Staubsauger","position":9,"open":true,"distance":5.348706403529263,"prices":[]},{"id":248033,"name":"eni","location":{"address":"S 33","postalCode":"3100","city":"St. Pölten","latitude":48.19600961,"longitude":15.66120386},"contact":{"telephone":"02742230070","fax":"0274223007021"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"04:00","to":"23:00"},{"day":"DI","label":"Dienstag","order":2,"from":"04:00","to":"22:00"},{"day":"MI","label":"Mittwoch","order":3,"from":"04:00","to":"23:00"},{"day":"DO","label":"Donnerstag","order":4,"from":"04:00","to":"23:00"},{"day":"FR","label":"Freitag","order":5,"from":"04:00","to":"23:00"},{"day":"SA","label":"Samstag","order":6,"from":"04:00","to":"23:00"},{"day":"SO","label":"Sonntag","order":7,"from":"04:00","to":"23:00"},{"day":"FE","label":"Feiertag","order":8,"from":"04:00","to":"23:00"}],"offerInformation":{"service":false,"selfService":true,"unattended":false},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true,"others":"AMEX,Maestro,Diners Club,DKV,GUTS,LOGP,MasterCard,Routex,UTA,VISA"},"paymentArrangements":{"cooperative":false,"clubCard":false},"position":10,"open":true,"distance":3.7530527119611987,"prices":[]}]
                                            

                                            Aber nochmals zum Adapter, das scheint nicht so schwer zu sein, bzw. vll könnte ich wenn auftreiben, der darüber gerne ein TuT machen würde und somit v0.1 erstellen könnte.

                                            Den Rest können ja dann die schlauen Köpfe hier übernehmen.

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            626
                                            Online

                                            31.9k
                                            Users

                                            80.1k
                                            Topics

                                            1.3m
                                            Posts

                                            javascript monitoring
                                            21
                                            292
                                            33349
                                            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