Skip to content
  • Home
  • Recent
  • Tags
  • 0 Unread 0
  • Categories
  • Unreplied
  • Popular
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. JavaScript
  5. Skripten des E-Control Spritpreisrechners

NEWS

  • Jahresrückblick 2025 – unser neuer Blogbeitrag ist online! ✨
    BluefoxB
    Bluefox
    17
    1
    2.4k

  • Neuer Blogbeitrag: Monatsrückblick - Dezember 2025 🎄
    BluefoxB
    Bluefox
    13
    1
    963

  • Weihnachtsangebot 2025! 🎄
    BluefoxB
    Bluefox
    25
    1
    2.2k

Skripten des E-Control Spritpreisrechners

Scheduled Pinned Locked Moved JavaScript
javascriptmonitoring
292 Posts 21 Posters 49.8k Views 17 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • NegaleinN Negalein

    @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?

    K Offline
    K Offline
    klaus88
    wrote on last edited by
    #221

    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!

    NegaleinN 1 Reply Last reply
    0
    • K klaus88

      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!

      NegaleinN Offline
      NegaleinN Offline
      Negalein
      Global Moderator
      wrote on last edited by
      #222

      @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

      ° Node.js & System Update ---> sudo apt update, iob stop, sudo apt full-upgrade
      ° Node.js Fixer ---> iob nodejs-update
      ° Fixer ---> iob fix

      1 Reply Last reply
      0
      • NegaleinN Offline
        NegaleinN Offline
        Negalein
        Global Moderator
        wrote on last edited by Negalein
        #223

        @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.

        ° Node.js & System Update ---> sudo apt update, iob stop, sudo apt full-upgrade
        ° Node.js Fixer ---> iob nodejs-update
        ° Fixer ---> iob fix

        K 1 Reply Last reply
        0
        • NegaleinN 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 Offline
          K Offline
          klaus88
          wrote on last edited by
          #224

          @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'];
          
          NegaleinN 1 Reply Last reply
          0
          • K klaus88

            @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'];
            
            NegaleinN Offline
            NegaleinN Offline
            Negalein
            Global Moderator
            wrote on last edited by
            #225

            @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! ;)

            ° Node.js & System Update ---> sudo apt update, iob stop, sudo apt full-upgrade
            ° Node.js Fixer ---> iob nodejs-update
            ° Fixer ---> iob fix

            K 1 Reply Last reply
            0
            • NegaleinN Negalein

              @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 Offline
              K Offline
              klaus88
              wrote on last edited by
              #226

              @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? :grinning:

              NegaleinN 1 Reply Last reply
              1
              • K klaus88

                @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? :grinning:

                NegaleinN Offline
                NegaleinN Offline
                Negalein
                Global Moderator
                wrote on last edited by
                #227

                @klaus88 sagte in Skripten des E-Control Spritpreisrechners:

                ok?

                Klaro

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

                ° Node.js & System Update ---> sudo apt update, iob stop, sudo apt full-upgrade
                ° Node.js Fixer ---> iob nodejs-update
                ° Fixer ---> iob fix

                K 1 Reply Last reply
                0
                • NegaleinN Negalein

                  @klaus88 sagte in Skripten des E-Control Spritpreisrechners:

                  Ich habe das Problem mit den Logos folgendermaßen gelöst

                  Hi Klaus!

                  Habe heute dein Script in Angriff genommen, bzw. meins mit deinen Zeilen passend erweitert.

                  Muss der Tankstellenname so geschrieben werden, wie in das Script vom Parser bekommt?
                  Also DISKONT<-->Diskont?

                  So steht es im Script:

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

                  So in den Objekten:
                  objects - ioBroker (8).png

                  Und wie am Screenshot ersichtlich werden einige DP nicht befüllt.

                  Liegt es eventuell an den Parser-Einstellungen?

                  https://api.e-control.at/sprit/1.0/search/gas-stations/by-address?latitude=48.456680&longitude=13.431940&fuelType=DIE&includeClosed=false
                  

                  EDIT: Funktioniert nun, nachdem ich im Parser kurz von JSON auf BOOLEAN umgestellt habe, gespeichert, wieder von BOOLEAN auf JSON und wieder gespeichert.

                  K Offline
                  K Offline
                  klaus88
                  wrote on last edited by
                  #228

                  @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
                  0
                  • NegaleinN Negalein

                    @klaus88 sagte in Skripten des E-Control Spritpreisrechners:

                    ok?

                    Klaro

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

                    K Offline
                    K Offline
                    klaus88
                    wrote on last edited by klaus88
                    #229

                    @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
                    0
                    • NegaleinN Offline
                      NegaleinN Offline
                      Negalein
                      Global Moderator
                      wrote on last edited by
                      #230

                      @klaus88

                      Gutes neues Jahr!!

                      DANKE, es klappt perfekt!

                      vis (1).png

                      ° Node.js & System Update ---> sudo apt update, iob stop, sudo apt full-upgrade
                      ° Node.js Fixer ---> iob nodejs-update
                      ° Fixer ---> iob fix

                      K 1 Reply Last reply
                      1
                      • NegaleinN Negalein

                        @klaus88

                        Gutes neues Jahr!!

                        DANKE, es klappt perfekt!

                        vis (1).png

                        K Offline
                        K Offline
                        klaus88
                        wrote on last edited by
                        #231

                        @Negalein sagte in Skripten des E-Control Spritpreisrechners:

                        DANKE, es klappt perfekt!

                        SUPER - das freut mich !

                        1 Reply Last reply
                        0
                        • NegaleinN Offline
                          NegaleinN Offline
                          Negalein
                          Global Moderator
                          wrote on last edited by
                          #232

                          @klaus88

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

                          Kann man irgendwie herausfinden warum dies passiert?

                          ° Node.js & System Update ---> sudo apt update, iob stop, sudo apt full-upgrade
                          ° Node.js Fixer ---> iob nodejs-update
                          ° Fixer ---> iob fix

                          K 1 Reply Last reply
                          0
                          • NegaleinN Negalein

                            @klaus88

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

                            Kann man irgendwie herausfinden warum dies passiert?

                            K Offline
                            K Offline
                            klaus88
                            wrote on last edited by
                            #233

                            @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
                            0
                            • J Offline
                              J Offline
                              jwedenig
                              Most Active
                              wrote on last edited by
                              #234

                              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
                              0
                              • J jwedenig

                                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 Offline
                                J Offline
                                jwedenig
                                Most Active
                                wrote on last edited by
                                #235

                                @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
                                0
                                • J Offline
                                  J Offline
                                  jwedenig
                                  Most Active
                                  wrote on last edited by
                                  #236

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

                                  sigi234S 1 Reply Last reply
                                  0
                                  • J jwedenig

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

                                    sigi234S Online
                                    sigi234S Online
                                    sigi234
                                    Forum Testing Most Active
                                    wrote on last edited by
                                    #237

                                    @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

                                    Bitte benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.
                                    Immer Daten sichern!

                                    J 1 Reply Last reply
                                    1
                                    • sigi234S sigi234

                                      @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 Offline
                                      J Offline
                                      jwedenig
                                      Most Active
                                      wrote on last edited by
                                      #238

                                      @sigi234
                                      super, dankeeeee

                                      1 Reply Last reply
                                      0
                                      • S Offline
                                        S Offline
                                        salmi
                                        wrote on last edited by
                                        #239

                                        Hallo,

                                        ich habe das Problem das bei Lagerhaus kein Logo kommt sowie bei der Tankstelle Heppner & Oberndorfer Bedienungstankstelle ich hätte das Script auch schon angepasst aber irgendwie will es nicht. Kann bitte mal wer drüber schauen ober wer einen Fehler findet.

                                        sprit.JPG

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

                                        LG Stefan

                                        NegaleinN 1 Reply Last reply
                                        0
                                        • S salmi

                                          Hallo,

                                          ich habe das Problem das bei Lagerhaus kein Logo kommt sowie bei der Tankstelle Heppner & Oberndorfer Bedienungstankstelle ich hätte das Script auch schon angepasst aber irgendwie will es nicht. Kann bitte mal wer drüber schauen ober wer einen Fehler findet.

                                          sprit.JPG

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

                                          LG Stefan

                                          NegaleinN Offline
                                          NegaleinN Offline
                                          Negalein
                                          Global Moderator
                                          wrote on last edited by Negalein
                                          #240

                                          @salmi sagte in Skripten des E-Control Spritpreisrechners:

                                          das Problem das bei Lagerhaus kein Logo kommt sowie bei der Tankstelle Heppner & Oberndorfer

                                          Ich glaube er nimmt nur den 1. Teil vom Namen

                                          Versuch mal so

                                          var arrMarke = ['Aral', 'eni', 'Shell', 'OMV', 'avanti', 'bp', 'JET', 'Turmöl', 'Lagerhaus', 'AVIA', 'A1', 'Diskont', 'IQ', 'Heppner & Oberndorfer Bedienungstankstelle', 'Genol', 'Heppner', ];
                                          

                                          ° Node.js & System Update ---> sudo apt update, iob stop, sudo apt full-upgrade
                                          ° Node.js Fixer ---> iob nodejs-update
                                          ° Fixer ---> iob fix

                                          S 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          Support us

                                          ioBroker
                                          Community Adapters
                                          Donate

                                          341

                                          Online

                                          32.6k

                                          Users

                                          82.2k

                                          Topics

                                          1.3m

                                          Posts
                                          Community
                                          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
                                          ioBroker Community 2014-2025
                                          logo
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Home
                                          • Recent
                                          • Tags
                                          • Unread 0
                                          • Categories
                                          • Unreplied
                                          • Popular
                                          • GitHub
                                          • Docu
                                          • Hilfe