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

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Skripten des E-Control Spritpreisrechners

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

      @klaus88

      Mit den Logos will es nicht ganz klappen.

      So ist mein 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 (gasStation.length === 0) return;
         //Aral=1, eni=2, Shell=3, OMV=4, avanti=5, bp=6, JET=7, Turmöl=8, Genol=9, AVIA=10, A1=11, DISKONT=12, IQ=13
         var arrMarke = ['Aral', 'eni', 'Shell', 'OMV', 'avanti', 'bp', 'JET', 'Turmöl', 'Lagerhaus Genol', 'AVIA', 'A1', 'Diskont', 'IQ'];
         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 Genol=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");
      });
      

      So kommen die Daten rein:


      objects - ioBroker (9).png

      Logo müsste eigentlich 9 sein, wird aber 6 eingetragen.


      Edit vis (5).png

      Hab ich im Script einen Fehler?

      sigi234 K 2 Replies Last reply Reply Quote 0
      • sigi234
        sigi234 Forum Testing Most Active @Negalein last edited by sigi234

        @Negalein sagte in Skripten des E-Control Spritpreisrechners:

        @klaus88

        Mit den Logos will es nicht ganz klappen.

        Kannst du die Logos bitte mal reinstellen, finde sie nicht mehr.

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

          @sigi234 sagte in Skripten des E-Control Spritpreisrechners:

          Kannst du die Logos bitte mal reinstellen, finde sie nicht mehr.

          13.png 12.png 11.png 10.png 9.png 8.png 7.png 6.png 5.png 4.png 3.png 2.png 1.png

          1 Reply Last reply Reply Quote 1
          • K
            klaus88 @Negalein last edited by

            Hab ich im Script einen Fehler?

            Hallo!
            Oje du hast einen Fehler in meinem Script gefunden, den ich nicht habe: Lagerhaus Genol hat ein Leerzeichen --> dadurch erkennt er nur Lagerhaus. Bitte probier mal, dass du im Array nicht "Lagerhaus Genol" schreibst sonder nur "Lagerhaus".
            Vielleicht geht es dann!

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

              @klaus88 sagte in Skripten des E-Control Spritpreisrechners:

              Bitte probier mal, dass du im Array nicht "Lagerhaus Genol" schreibst sonder nur "Lagerhaus".

              bleibt leider beim Fehler

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

                @klaus88

                So schaut aktuell das Script aus:

                '*/5 * * * *'
                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                //  "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
                   var arrMarke = ['Aral', 'eni', 'Shell', 'OMV', 'avanti', 'bp', 'JET', 'Turmöl', 'Lagerhaus', 'AVIA', 'A1', 'Diskont', 'IQ'];
                   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
                   
                   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");
                });
                

                Und so die Ausgabe vom Api-Link:

                [{"id":227,"name":"avanti - Sankt Florian/Inn Bundesstraße 129","location":{"address":"Bundesstrasse 129","postalCode":"4780","city":"Sankt Florian/Inn","latitude":48.43865,"longitude":13.44392},"contact":{"telephone":"800202055","fax":"800","website":"www.omv.com"},"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":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":1,"open":true,"distance":2.1930579551820806,"prices":[{"fuelType":"DIE","amount":1.177,"label":"Diesel"}]},{"id":43946,"name":"SB-Tankstelle Zauner","location":{"address":"Ludwig-Paglstr. 1","postalCode":"4780","city":"Schärding","latitude":48.447209,"longitude":13.439305},"contact":{"website":"http://www.auto-zauner.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":true,"unattended":true},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":false},"paymentArrangements":{"cooperative":false,"clubCard":false},"position":2,"open":true,"distance":1.1861150291611577,"prices":[{"fuelType":"DIE","amount":1.18,"label":"Diesel"}]},{"id":1354925,"name":"JET TANKSTELLE","location":{"address":"LINZERSTRASSE 58","postalCode":"4780","city":"SCHÄRDING","latitude":48.450421,"longitude":13.436477},"contact":{"telephone":"0771235972"},"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":"22:00"},{"day":"FE","label":"Feiertag","order":8,"from":"07:00","to":"22:00"}],"offerInformation":{"service":false,"selfService":true,"unattended":true},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true},"paymentArrangements":{"cooperative":false,"clubCard":false},"otherServiceOffers":"Billa shop & shop, Backshop, Vignetten-Verkauf","position":3,"open":true,"distance":0.7729766074116283,"prices":[{"fuelType":"DIE","amount":1.182,"label":"Diesel"}]},{"id":4398,"name":"Bp","location":{"address":"Linzerstraße 52","postalCode":"4780","city":"Schärding","latitude":48.4511296,"longitude":13.4359547},"contact":{"telephone":"4377122194","fax":"43771221944","mail":"info@hell-alfred.at","website":"http://www.hell-alfred.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":"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},"paymentArrangements":{"cooperative":false,"clubCard":false},"position":4,"open":true,"distance":0.6851881360486911,"prices":[{"fuelType":"DIE","amount":1.192,"label":"Diesel"}]},{"id":34459,"name":"Lagerhaus Genol","location":{"address":"Otterbacherstrasse 2","postalCode":"4786","city":"Brunnenthal","latitude":48.4584665,"longitude":13.4449326},"contact":{"telephone":"4377123135","mail":"rlh_schaerding@schaerding.rlh.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":false,"creditCard":false},"paymentArrangements":{"cooperative":false,"clubCard":false},"position":5,"open":true,"distance":0.9795663890363353,"prices":[{"fuelType":"DIE","amount":1.192,"label":"Diesel"}]},{"id":1132040,"name":"Diskont Tankstelle","location":{"address":"Othmar-Spanlang-Straße 1 (\"Hofer Parkplatz\")","postalCode":"4780","city":"Schärding","latitude":48.446581,"longitude":13.439444},"contact":{"mail":"tankstellen@gutmann.cc","website":"http://www.gutmann.cc"},"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":"06:00","to":"22:00"},{"day":"FE","label":"Feiertag","order":8,"from":"06:00","to":"22:00"}],"offerInformation":{"service":false,"selfService":true,"unattended":true},"paymentMethods":{"cash":false,"debitCard":true,"creditCard":true,"others":"AP Karte"},"paymentArrangements":{"cooperative":false,"clubCard":false},"position":6,"open":true,"distance":1.2531494440658468,"prices":[]},{"id":33765,"name":"Land lebt auf Suben Gmbh","location":{"address":"Schnelldorf 60","postalCode":"4975","city":"Suben","latitude":48.4186387,"longitude":13.4362911},"contact":{"telephone":"436644558554","fax":"437711315835","mail":"Landlebtauf.suben@pfeiffer.at"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"05:30","to":"20:30"},{"day":"DI","label":"Dienstag","order":2,"from":"05:30","to":"20:30"},{"day":"MI","label":"Mittwoch","order":3,"from":"05:30","to":"20:30"},{"day":"DO","label":"Donnerstag","order":4,"from":"05:30","to":"20:30"},{"day":"FR","label":"Freitag","order":5,"from":"05:30","to":"20:30"},{"day":"SA","label":"Samstag","order":6,"from":"05:30","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":false,"unattended":false},"paymentMethods":{"cash":false,"debitCard":false,"creditCard":false},"paymentArrangements":{"cooperative":false,"clubCard":false,"accessMod":"Freie Tankstelle"},"otherServiceOffers":"Nahversorger zu Günstigen Preisen!\r\nLebensmittelmarkt zu Diskountpreisen!\r\nBackstation!\r\nLotto-Toto !\r\nAuto-Waschbox!\r\nPost-Servicestelle","position":7,"open":true,"distance":4.2461735768192215,"prices":[]},{"id":35778,"name":"BP","location":{"address":"Passauer Strasse 29 ","postalCode":"4780","city":"Schaerding","latitude":48.4640812,"longitude":13.4356825},"contact":{"telephone":"4377122261","fax":"437712226116","mail":"R52445@bprosi.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":"06:00","to":"22:00"},{"day":"FE","label":"Feiertag","order":8,"from":"06:00","to":"22:00"}],"offerInformation":{"service":false,"selfService":true,"unattended":false},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true,"others":"Routex"},"paymentArrangements":{"cooperative":false,"clubCard":false},"otherServiceOffers":"Merkur Inside, Car Wash","position":8,"open":true,"distance":0.8688480164956199,"prices":[]},{"id":262902,"name":"Shell Schaerding","location":{"address":"Passauer Strasse 21","postalCode":"4780","city":"Schaerding","latitude":48.46383,"longitude":13.4332573},"contact":{"telephone":"771236040","mail":"office@stiglechner.co.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":"07:00","to":"22:00"},{"day":"SO","label":"Sonntag","order":7,"from":"08:00","to":"22:00"},{"day":"FE","label":"Feiertag","order":8,"from":"08:00","to":"22:00"}],"offerInformation":{"service":false,"selfService":true,"unattended":false},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true,"others":"IQ Card, Euroshell"},"paymentArrangements":{"cooperative":false,"clubCard":false},"otherServiceOffers":"Bistro, Shop, Portalwaschanlage, SB-Sauger","position":9,"open":true,"distance":0.8017144638408347,"prices":[]},{"id":448796,"name":"Shell Austria","location":{"address":"ETZELSHOFEN 125","postalCode":"4975","city":"SUBEN","latitude":48.40061,"longitude":13.42603},"contact":{"telephone":"0771131620"},"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":false},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true},"paymentArrangements":{"cooperative":false,"clubCard":false},"position":10,"open":true,"distance":6.255841554824173,"prices":[]}]
                

                Das Script starte ich mit einem Cron alle 5 Minuten neu und der Parser holt den Link alle 10 Sekunden.

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

                  @Negalein :

                  Nun ja da hast du ein paar echte Schmankerl drinnen in deinem Link:
                  einmal BP groß geschrieben - einmal Bp mit kleinem p
                  einmal "SB-Tankstelle Zauner" hier würde mein Script auch nur "SB-Tankstelle" auslesen
                  einmal "Land lebt auf Suben Gmbh" hier würde mein Script nur "Land" auslesen

                  Da ich hier in Wien wohne haben wir eigentlich "nur" die großen Tankstellen und hier funktioniert eigentlich alles,
                  Wahrscheinlich musst du im Javascript bei

                  var arrname = gasStation[index].name.split(' ');
                  		if (arrname.length > 0) {
                  				var markenname = arrname[0];
                  			}
                  			else
                  			{
                  				var markenname = gasStation[index].name;
                  			}
                  

                  etwas herumbasteln bzw. natürlich dann beim Array:

                  var arrMarke = ['Aral', 'eni', 'Shell', 'OMV', 'avanti', 'bp', 'JET', 'Turmöl', 'Genol', 'AVIA', 'A1', 'DISKONT'];
                  
                  Negalein 1 Reply Last reply Reply Quote 0
                  • Negalein
                    Negalein Global Moderator @klaus88 last edited by

                    @klaus88 sagte in Skripten des E-Control Spritpreisrechners:

                    Nun ja da hast du ein paar echte Schmankerl drinnen in deinem Link:

                    Ja leider.

                    Wahrscheinlich musst du im Javascript bei

                    var arrname = gasStation[index].name.split(' '); if (arrname.length > 0) { var markenname = arrname[0]; } else { var markenname = gasStation[index].name; }

                    etwas herumbasteln

                    Wie geht das als JS-DAU?

                    bzw. natürlich dann beim Array:

                    OK, das hier schaff ich noch! 😉

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

                      @Negalein Bin jetzt auf einer Party und gönne mir ein paar Bierchen - schaue es mir morgen an wenn das Kopfweh wieder weg ist - ok? 😀

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

                        @klaus88 sagte in Skripten des E-Control Spritpreisrechners:

                        ok?

                        Klaro

                        Wünsch dir einen guten Rutsch und einen nicht zu großen Brummschädl! 😁

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

                          @Negalein sagte in Skripten des E-Control Spritpreisrechners:

                          var arrMarke = ['Aral', 'eni', 'Shell', 'OMV', 'avanti', 'bp', 'JET', 'Turmöl', 'Genol', 'AVIA', 'A1', 'DISKONT' 'IQ'];

                          Hallo Negalein,
                          Gutes neues Jahr vorab !
                          bin grad am versuchen:

                          1. Bitte vor dem letzten Eintrag im Array hast du den Beistrich vergessen --> ,'IQ'];

                          Beispiel jetzt von mir schnell eingegeben:

                          var arrMarke = ['Aral', 'eni', 'Shell', 'OMV', 'avanti', 'bp', 'JET', 'Turmöl', 'Genol', 'AVIA', 'A1', 'DISKONT', 'IQ', 'Lagerhaus', 'SB-Tankstelle']; 
                              
                          

                          Dann bekomme ich folgendes Ergebnis:
                          Lagerhaus.jpg

                          Wie du siehst, kommt für Lagerhaus --> Logo 14 und für SB-Tankstelle --> Logo 15
                          Müsste eigentlich passen - probiers mal aus und sag Bescheid!
                          lg
                          Klaus

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

                            @Negalein

                            noch was : Ich habe beim Widget nur maximal 15 Tankstellen eingegeben, da es mit Sicherheit bei uns nicht mehr gibt. D.h. wenn du im Array mehr als 15 eingibst müsstest du im Widget wo das Logo drinnen ist noch zusätzliche eingeben.:
                            Lagerhaus2.jpg

                            lg
                            Klaus

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

                              @klaus88

                              Gutes neues Jahr!!

                              DANKE, es klappt perfekt!

                              vis (1).png

                              K 1 Reply Last reply Reply Quote 1
                              • K
                                klaus88 @Negalein last edited by

                                @Negalein sagte in Skripten des E-Control Spritpreisrechners:

                                DANKE, es klappt perfekt!

                                SUPER - das freut mich !

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

                                  @klaus88

                                  Mein Script pausiert (gelbes Pausesymbol) immer wieder mal.
                                  javascript - ioBroker (7).png

                                  Kann man irgendwie herausfinden warum dies passiert?

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

                                    @Negalein Also da bin ich auch überfragt, aber ich glaube, dass es daran liegt, dass dieses Script auf Änderungen im Parser wartet und sobald sich laut Parser Daten etwas ändert sich das Script dann aktiviert.

                                    1 Reply Last reply Reply Quote 0
                                    • J
                                      jwedenig Most Active last edited by

                                      Hi!
                                      Sorry, bin neu und hätte das auch gerne.
                                      Ich habe Parser installiert, den Api eingetragen und das Skript eingetragen.
                                      Es werden aber keine Datenpunkte erstellt.
                                      Was mache ich falls? Und gibt es ein Widget für vis?
                                      Vielen Dank für die Hilfe
                                      Jürgen

                                      '*/5 * * * *'
                                      //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                      //  "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
                                         var arrMarke = ['Aral', 'eni', 'Shell', 'OMV', 'avanti', 'bp', 'JET', 'Turmöl', 'Lagerhaus', 'AVIA', 'A1', 'Diskont', 'IQ'];
                                         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
                                         
                                         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");
                                      });
                                      
                                      
                                      J 1 Reply Last reply Reply Quote 0
                                      • J
                                        jwedenig Most Active @jwedenig last edited by

                                        @jwedenig
                                        ok, ich bin schon auf etwas draufgekommen, bei Parser muss natürlich "Spritpreisrechner" stehen, sonst werden die Datenpunkte nicht erzeugt.
                                        Diese sind aber jetzt leer?
                                        Bildschirmfoto 2020-01-22 um 09.46.51.png

                                        1 Reply Last reply Reply Quote 0
                                        • J
                                          jwedenig Most Active last edited by

                                          ok, json muss aktiviert sein, jetzt habe ich auch die Daten:-)
                                          Ein Vis Widget wäre noch super! Vielen Dank!

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

                                            @jwedenig sagte in Skripten des E-Control Spritpreisrechners:

                                            Ein Vis Widget wäre noch super! Vielen Dank!

                                            https://forum.iobroker.net/topic/28717/vis-von-sigi234/23

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            553
                                            Online

                                            31.7k
                                            Users

                                            79.6k
                                            Topics

                                            1.3m
                                            Posts

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