NEWS
Skripten des E-Control Spritpreisrechners
-
@metaxa
sehe ich auch wie du.
Als ich eure "Preisunterschiede" im Zehntelcentbereich gesehen hatte musste ich fast lachen.Bei uns gab es Unterschiede von bis zu 30 CT im Umkreis von 2 km.
Da war es sinnvoll sich zu informieren.
ein Jahr nach Einführung der Transparenzstelle war es dann nur noch 10ct.
-
Also so schaut mal meine Lösung aus:
on({id: 'javascript.0.Sprit.Sprit_JSON'/*Sprit JSON*/, change: 'any'}, function(obj) { var index = 0; /*var gasStation = JSON.parse('parser.0.Tanken');*/ var gasStation = JSON.parse(obj.state.val); /*if (gasStation.length === 0) return;*/ console.log((String('Durchlauf'))); createState("javascript.0.Sprit.Tankstelle_Test.Index", false,{type: 'number',name: 'index', read: true,write: true}); for (index = 0; index < gasStation.length; ++index) { createState("javascript.0.Sprit.Tankstelle_"+index+".Index", 0,{type: 'number',name: 'index', read: true,write: true}); setState("javascript.0.Sprit.Tankstelle_"+index+".Index", gasStation[index].id); createState("javascript.0.Sprit.Tankstelle_"+index+".name", 0,{type: 'string',name: 'name', read: true,write: true}); setState("javascript.0.Sprit.Tankstelle_"+index+".name", gasStation[index].name); createState("javascript.0.Sprit.Tankstelle_"+index+".prices", 0,{type: 'string',name: 'Preis ges', read: true,write: true}); if ((gasStation[index].prices[0])!=undefined){ setState("javascript.0.Sprit.Tankstelle_"+index+".prices", (gasStation[index].prices[0].amount).toString().replace(".",",")); }; createState("javascript.0.Sprit.Tankstelle_"+index+".adresse", 0,{type: 'string',name: 'name', read: true,write: true}); setState("javascript.0.Sprit.Tankstelle_"+index+".adresse", gasStation[index].location.address); createState("javascript.0.Sprit.Tankstelle_"+index+".adresse2", 0,{type: 'string',name: 'name', read: true,write: true}); setState("javascript.0.Sprit.Tankstelle_"+index+".adresse2", gasStation[index].location.postalCode + " "+ gasStation[index].location.city); } });
Sortiert nur nach billigst zu teuer.
-
@Georgius Hm, ich krieg nur "0"
Bei dir hagelts aber einmal keine Fehlermeldungen ..... -
Beim 2. Durchlauf sollte es dann funktionieren.
Ich verwende das Blocky zum einlesen des JSON
-
@metaxa sagte in Skripten des E-Control Spritpreisrechners:
Lieber Rainer, du hast den schier unerschöpflich, ewigen Dank, deiner unmittelbaren Nachbarn, den Ösis +
Auch von mir ein Danke..............ein Ösi....
-
Danke, erledigt, arbeite schon daran mit Vis.
Da ist noch Feintuning angesagt....
Was habe ich noch vor, tja wenn es geht möchte ich noch folgendes einblenden:-
Öffnungszeiten
-
Geöffnet/Geschlossen
-
Kilometer zur Tankstelle
-
Logo der Tankstelle (geht sicher mit Sichtbarkeit)
-
-
Öffnungszeiten sind aufwendig. Für jeden Tag gibt es ein Von und ein Endefeld +Feiertage.
Logo der Tankstelle geht in meinen Augen nicht über die Sichtbarkeit. Da würde ich für jede Tankstelle bzw. Kette ein Logo ablegen und dann einen Link erzeugen auf das Bild. Wie das im VIS geht weiß ich (noch) nicht.Geöffnet/geschlossen und km sind jeweils ein eigenes Feld.
Man kann auch auf offene Tankstellen filtern im Weblink
Wenn mir fad ist baue ich noch einen Durchschnittspreis der letzten 30 Tage ein.
-
@sigi234
((Math.round((gasStation[index].distance)*100)/100).toString().replace(".",","))
(gasStation[index].open).toString()
LG, mxa -
@Georgius sagte in Skripten des E-Control Spritpreisrechners:
Logo der Tankstelle geht in meinen Augen nicht über die Sichtbarkeit.
Denke vielleicht mit Signalbilder und Text besteht aus : Name Tankstelle (avanti)
Da spiele ich mal ein bisschen damit......... -
Hallo sigi234,
Mich würde interessieren ob du das mit den Logos schon im Vis hinbekommen hast?
Welches Script verwendest du jetzt, hab irgendwann beim Lesen den Faden verloren welches jetzt das Aktuelle ist.
Sg. Gerald -
Leider nein.............
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // "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", change: 'any'}, function(obj) { log("Start Spritvergleich"); var gasStation = JSON.parse(obj.state.val); if (gasStation.length === 0) return; var i = 0; for (var i = 1; i <= 5; i++) { console.log(i); console.log("scriptDatenPunkte.Sprit_AT.name_"+i); createState("scriptDatenPunkte.Sprit_AT.Treffer_"+i+".Name_"+i, {type: "string", name: "Platz "+i, read: true, write: true}); createState("scriptDatenPunkte.Sprit_AT.Treffer_"+i+".Preis_"+i, {type: "number", name: "Platz "+i, read: true, write: true}); createState("scriptDatenPunkte.Sprit_AT.Treffer_"+i+".Strasse_"+i, {type: "string", name: "Platz "+i, read: true, write: true}); createState("scriptDatenPunkte.Sprit_AT.Treffer_"+i+".PLZ_Ort_"+i, {type: "string", name: "Platz "+i, read: true, write: true}); } var index = 0; //for (index = 0; index < gasStation.length; ++index) { for (index = 0; index <= 4; ++index) { setState("scriptDatenPunkte.Sprit_AT.Treffer_"+(index+1)+".Name_"+(index+1), gasStation[index].name); setState("scriptDatenPunkte.Sprit_AT.Treffer_"+(index+1)+".Preis_"+(index+1), (gasStation[index].prices[0].amount)); setState("scriptDatenPunkte.Sprit_AT.Treffer_"+(index+1)+".Strasse_"+(index+1), (gasStation[index].location.address)); setState("scriptDatenPunkte.Sprit_AT.Treffer_"+(index+1)+".PLZ_Ort_"+(index+1), (gasStation[index].location.postalCode) + " " + (gasStation[index].location.city)); } log("Ende Spritvergleich"); });
Die XXX mit deinen ersetzten........
-
@sigi234
Kannst du mir trotzdem noch sagen welches Script du verwendest? -
@gerald123 sagte in Skripten des E-Control Spritpreisrechners:
@sigi234
Kannst du mir trotzdem noch sagen welches Script du verwendest?hat er 1 Beitrag über dir gepostet
-
Super Danke, habs bei mir jetzt auch am laufen.
-
Ich bekomm von Zeit zu Zeit immer wieder Fehlermeldungen im Log.
Das Script bleibt dann mit einem gelben Pausezeichen stehen.2019-11-25 12:07:35.026 - [31merror[39m: javascript.0 (608) Error in callback: TypeError: Cannot read property 'amount' of undefined 2019-11-25 12:07:35.027 - [31merror[39m: javascript.0 (608) at Object.<anonymous> (script.js.common.Spritpreisrechner:34:107) 2019-11-25 12:07:35.027 - [31merror[39m: javascript.0 (608) at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1101:38) 2019-11-25 12:07:35.027 - [31merror[39m: javascript.0 (608) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:439:25) 2019-11-25 12:07:35.027 - [31merror[39m: javascript.0 (608) at change (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:4744:37) 2019-11-25 12:07:35.027 - [31merror[39m: javascript.0 (608) at Immediate.setImmediate (/opt/iobroker/node_modules/iobroker.js-controller/lib/states/statesInRedis.js:226:41) 2019-11-25 12:07:35.028 - [31merror[39m: javascript.0 (608) at runCallback (timers.js:705:18) 2019-11-25 12:07:35.028 - [31merror[39m: javascript.0 (608) at tryOnImmediate (timers.js:676:5) 2019-11-25 12:07:35.028 - [31merror[39m: javascript.0 (608) at processImmediate (timers.js:658:5)
Liegt das an der e-Control?
-
Servus, da tue ich mir schwer was dazu zu sagen. Bin kein Scripter, mehr der Kopierer. Bei mir läuft das Script nach Umstieg auf JS Controller 2.1.0 & JS Script Engine 4.3.2 fehlerfrei.
LG, mxa -
@sigi234 said in Skripten des E-Control Spritpreisrechners:
@Georgius sagte in Skripten des E-Control Spritpreisrechners:
Logo der Tankstelle geht in meinen Augen nicht über die Sichtbarkeit.
Denke vielleicht mit Signalbilder und Text besteht aus : Name Tankstelle (avanti)
Da spiele ich mal ein bisschen damit.........@sigi234 Könntest du dieses VIS Widget für das Spritpreis Script exportieren und hier im Forum teilen ? Das gefällt mir sehr gut
beste Grüße
-
@Qlink sagte in Skripten des E-Control Spritpreisrechners:
@sigi234 said in Skripten des E-Control Spritpreisrechners:
@Georgius sagte in Skripten des E-Control Spritpreisrechners:
Logo der Tankstelle geht in meinen Augen nicht über die Sichtbarkeit.
Denke vielleicht mit Signalbilder und Text besteht aus : Name Tankstelle (avanti)
Da spiele ich mal ein bisschen damit.........@sigi234 Könntest du dieses VIS Widget für das Spritpreis Script exportieren und hier im Forum teilen ? Das gefällt mir sehr gut
beste Grüße
[{"tpl":"tplCGradialGauge","data":{"g_fixed":false,"g_visibility":false,"g_css_font_text":false,"g_css_background":false,"g_css_shadow_padding":false,"g_css_border":false,"g_gestures":false,"g_signals":false,"g_last_change":false,"visibility-cond":"==","visibility-val":1,"visibility-groups-action":"hide","factor":"1","valueOffset":"0","hCount":"5","minorTicks":"4","animation":true,"needle":"true","needleShadow":"true","needleType":"arrow","borders":true,"borderOuterWidth":"1","borderMiddleWidth":"1","borderInnerWidth":"1","borderShadowWidth":"1","valueBox":true,"ticksAngle":"270","startAngle":"45","signals-cond-0":"==","signals-val-0":true,"signals-icon-0":"/vis/signals/lowbattery.png","signals-icon-size-0":0,"signals-blink-0":false,"signals-horz-0":0,"signals-vert-0":0,"signals-hide-edit-0":false,"signals-cond-1":"==","signals-val-1":true,"signals-icon-1":"/vis/signals/lowbattery.png","signals-icon-size-1":0,"signals-blink-1":false,"signals-horz-1":0,"signals-vert-1":0,"signals-hide-edit-1":false,"signals-cond-2":"==","signals-val-2":true,"signals-icon-2":"/vis/signals/lowbattery.png","signals-icon-size-2":0,"signals-blink-2":false,"signals-horz-2":0,"signals-vert-2":0,"signals-hide-edit-2":false,"lc-type":"last-change","lc-is-interval":true,"lc-is-moment":false,"lc-format":"","lc-position-vert":"top","lc-position-horz":"right","lc-offset-vert":0,"lc-offset-horz":0,"lc-font-size":"12px","lc-font-family":"","lc-font-style":"","lc-bkg-color":"","lc-color":"","lc-border-width":"0","lc-border-style":"","lc-border-color":"","lc-border-radius":10,"lc-zindex":0,"minValue":"0.800","maxValue":"1.500","oid":"javascript.0.scriptDatenPunkte.Sprit_AT.Treffer_1.Preis_1","title":"Tankstelle 1","valueDec":"3","valueInt":"1","animationDuration":"1000","animationTarget":"needle","animatedValue":false,"animateOnInit":false,"valueTextShadow":true,"colorPlate":"#000000","colorBorderOuter":"#000000","colorBorderOuterEnd":"#000000","colorValueBoxRect":"#000000","colorValueBoxBackground":"#000000","colorValueBoxRectEnd":"#000000","colorPlateEnd":"#000000","colorMajorTicks":"#ffffff","colorMinorTicks":"#e6e6e6","colorTitle":"#ffffff","colorNeedle":"#29ff14","colorNeedleEnd":"#2dfa14","needleCircleInner":true,"needleCircleOuter":true,"needleCircleSize":"9","colorNeedleCircleInner":"#4af524","colorNeedleCircleInnerEnd":"#000000","colorNeedleCircleOuterEnd":"#2dfd0d","colorNeedleCircleOuter":"#000000","colorUnits":"#ffffff","colorNumbers":"transparent","colorValueText":"#ffffff","highlightsFrom1":"0.800","highlightsTo1":"1.000","highlightsColor1":"#3efc22","highlightsFrom2":"1.000","highlightsTo2":"1.100","highlightsColor2":"#147118","units":"€/Liter","highlightsFrom3":"1.100","highlightsTo3":"1.200","highlightsColor3":"#085413","highlightsFrom4":"1.200","highlightsTo4":"1.300","highlightsColor4":"#ffc524","highlightsFrom5":"1.300","highlightsTo5":"1.500","highlightsColor5":"#bd0026","animationRule":"linear","colorBorderMiddle":"#c8cacb","colorBorderMiddleEnd":"#c8cacb"},"style":{"left":"71px","top":"168px","z-index":"2","width":"179px","height":"163px","font-family":"RobotoCondensed-Light"},"widgetSet":"canvas-gauges"},{"tpl":"tplValueStringRaw","data":{"oid":"javascript.0.scriptDatenPunkte.Sprit_AT.Treffer_1.Name_1","g_fixed":false,"g_visibility":false,"g_css_font_text":true,"g_css_background":false,"g_css_shadow_padding":false,"g_css_border":false,"g_gestures":false,"g_signals":false,"g_last_change":false,"visibility-cond":"==","visibility-val":1,"visibility-groups-action":"hide","signals-cond-0":"==","signals-val-0":true,"signals-icon-0":"/vis/signals/lowbattery.png","signals-icon-size-0":0,"signals-blink-0":false,"signals-horz-0":0,"signals-vert-0":0,"signals-hide-edit-0":false,"signals-cond-1":"==","signals-val-1":true,"signals-icon-1":"/vis/signals/lowbattery.png","signals-icon-size-1":0,"signals-blink-1":false,"signals-horz-1":0,"signals-vert-1":0,"signals-hide-edit-1":false,"signals-cond-2":"==","signals-val-2":true,"signals-icon-2":"/vis/signals/lowbattery.png","signals-icon-size-2":0,"signals-blink-2":false,"signals-horz-2":0,"signals-vert-2":0,"signals-hide-edit-2":false,"lc-type":"last-change","lc-is-interval":true,"lc-is-moment":false,"lc-format":"","lc-position-vert":"top","lc-position-horz":"right","lc-offset-vert":0,"lc-offset-horz":0,"lc-font-size":"12px","lc-font-family":"","lc-font-style":"","lc-bkg-color":"","lc-color":"","lc-border-width":"0","lc-border-style":"","lc-border-color":"","lc-border-radius":10,"lc-zindex":0},"style":{"left":"39px","top":"69px","width":"240px","height":"25px","z-index":"3","font-size":"small","text-align":"center","font-family":"RobotoCondensed-Light"},"widgetSet":"basic"},{"tpl":"tplFrame","data":{"g_fixed":true,"g_visibility":false,"g_css_font_text":true,"g_css_background":true,"g_css_shadow_padding":true,"g_css_border":true,"g_gestures":false,"g_signals":false,"g_last_change":false,"visibility-cond":"==","visibility-val":1,"visibility-groups-action":"hide","title":"","title_color":"#FFFFFF","title_top":"-10","title_left":"30","header_height":"0","header_color":"","signals-cond-0":"==","signals-val-0":true,"signals-icon-0":"/vis/signals/lowbattery.png","signals-icon-size-0":0,"signals-blink-0":false,"signals-horz-0":0,"signals-vert-0":0,"signals-hide-edit-0":false,"signals-cond-1":"==","signals-val-1":true,"signals-icon-1":"/vis/signals/lowbattery.png","signals-icon-size-1":0,"signals-blink-1":false,"signals-horz-1":0,"signals-vert-1":0,"signals-hide-edit-1":false,"signals-cond-2":"==","signals-val-2":true,"signals-icon-2":"/vis/signals/lowbattery.png","signals-icon-size-2":0,"signals-blink-2":false,"signals-horz-2":0,"signals-vert-2":0,"signals-hide-edit-2":false,"lc-type":"last-change","lc-is-interval":true,"lc-is-moment":false,"lc-format":"","lc-position-vert":"top","lc-position-horz":"right","lc-offset-vert":0,"lc-offset-horz":0,"lc-font-size":"12px","lc-font-family":"","lc-font-style":"","lc-bkg-color":"","lc-color":"","lc-border-width":"0","lc-border-style":"","lc-border-color":"","lc-border-radius":10,"lc-zindex":0,"title_back":"","title_font":"","name":"Border Tag 2","filterkey":"Wetter"},"style":{"left":"34px","top":"57px","width":"247px","height":"281px","color":"","z-index":"1","border-radius":"10px","box-shadow":"2px 2px 3px rgba(20, 20, 20, 50)","background":"#202020","border-color":"","background-color":"transparent","font-family":"RobotoCondensed-Light"},"widgetSet":"basic"},{"tpl":"tplHtml","data":{"g_fixed":false,"g_visibility":false,"g_css_font_text":false,"g_css_background":true,"g_css_shadow_padding":false,"g_css_border":false,"g_gestures":false,"g_signals":false,"g_last_change":false,"visibility-cond":"==","visibility-val":1,"visibility-groups-action":"hide","refreshInterval":"0","signals-cond-0":"==","signals-val-0":true,"signals-icon-0":"/vis/signals/lowbattery.png","signals-icon-size-0":0,"signals-blink-0":false,"signals-horz-0":0,"signals-vert-0":0,"signals-hide-edit-0":false,"signals-cond-1":"==","signals-val-1":true,"signals-icon-1":"/vis/signals/lowbattery.png","signals-icon-size-1":0,"signals-blink-1":false,"signals-horz-1":0,"signals-vert-1":0,"signals-hide-edit-1":false,"signals-cond-2":"==","signals-val-2":true,"signals-icon-2":"/vis/signals/lowbattery.png","signals-icon-size-2":0,"signals-blink-2":false,"signals-horz-2":0,"signals-vert-2":0,"signals-hide-edit-2":false,"lc-type":"last-change","lc-is-interval":true,"lc-is-moment":false,"lc-format":"","lc-position-vert":"top","lc-position-horz":"right","lc-offset-vert":0,"lc-offset-horz":0,"lc-font-size":"12px","lc-font-family":"","lc-font-style":"","lc-bkg-color":"","lc-color":"","lc-border-width":"0","lc-border-style":"","lc-border-color":"","lc-border-radius":10,"lc-zindex":0},"style":{"left":"158px","top":"101px","width":"122px","height":"3px","background":"linear-gradient(to left, #282828 5px, white 200px )","z-index":"3","font-family":"RobotoCondensed-Light"},"widgetSet":"basic"},{"tpl":"tplHtml","data":{"g_fixed":false,"g_visibility":false,"g_css_font_text":false,"g_css_background":true,"g_css_shadow_padding":false,"g_css_border":false,"g_gestures":false,"g_signals":false,"g_last_change":false,"visibility-cond":"==","visibility-val":1,"visibility-groups-action":"hide","refreshInterval":"0","signals-cond-0":"==","signals-val-0":true,"signals-icon-0":"/vis/signals/lowbattery.png","signals-icon-size-0":0,"signals-blink-0":false,"signals-horz-0":0,"signals-vert-0":0,"signals-hide-edit-0":false,"signals-cond-1":"==","signals-val-1":true,"signals-icon-1":"/vis/signals/lowbattery.png","signals-icon-size-1":0,"signals-blink-1":false,"signals-horz-1":0,"signals-vert-1":0,"signals-hide-edit-1":false,"signals-cond-2":"==","signals-val-2":true,"signals-icon-2":"/vis/signals/lowbattery.png","signals-icon-size-2":0,"signals-blink-2":false,"signals-horz-2":0,"signals-vert-2":0,"signals-hide-edit-2":false,"lc-type":"last-change","lc-is-interval":true,"lc-is-moment":false,"lc-format":"","lc-position-vert":"top","lc-position-horz":"right","lc-offset-vert":0,"lc-offset-horz":0,"lc-font-size":"12px","lc-font-family":"","lc-font-style":"","lc-bkg-color":"","lc-color":"","lc-border-width":"0","lc-border-style":"","lc-border-color":"","lc-border-radius":10,"lc-zindex":0},"style":{"left":"37px","top":"101px","width":"122px","height":"3px","background":"linear-gradient(to right, #282828 5px, white 200px )","z-index":"3","font-family":"RobotoCondensed-Light"},"widgetSet":"basic"},{"tpl":"tplStatefulImage8","data":{"oid":"javascript.0.scriptDatenPunkte.Sprit_AT.Treffer_1.Name_1","g_fixed":false,"g_visibility":false,"g_css_font_text":false,"g_css_background":false,"g_css_shadow_padding":false,"g_css_border":false,"g_gestures":false,"g_signals":true,"g_last_change":false,"refreshInterval":"0","count":"5","signals-cond-0":"consist","signals-val-0":"avanti","signals-icon-0":"/vis.0/Logo-Avanti.jpg","signals-icon-size-0":"62","signals-blink-0":false,"signals-horz-0":0,"signals-vert-0":0,"signals-hide-edit-0":false,"signals-cond-1":"==","signals-val-1":true,"signals-icon-1":"/vis/signals/lowbattery.png","signals-icon-size-1":0,"signals-blink-1":false,"signals-horz-1":0,"signals-vert-1":0,"signals-hide-edit-1":false,"signals-cond-2":"==","signals-val-2":true,"signals-icon-2":"/vis/signals/lowbattery.png","signals-icon-size-2":0,"signals-blink-2":false,"signals-horz-2":0,"signals-vert-2":0,"signals-hide-edit-2":false,"lc-type":"last-change","lc-is-interval":true,"lc-is-moment":false,"lc-format":"","lc-position-vert":"top","lc-position-horz":"right","lc-offset-vert":0,"lc-offset-horz":0,"lc-font-size":"12px","lc-font-family":"","lc-font-style":"","lc-bkg-color":"","lc-color":"","lc-border-width":"0","lc-border-style":"","lc-border-color":"","lc-border-radius":10,"lc-zindex":0,"signals-oid-0":"javascript.0.scriptDatenPunkte.Sprit_AT.Treffer_1.Name_1","visibility-cond":"==","visibility-val":1,"visibility-groups-action":"hide"},"style":{"left":"43px","top":"109px","width":"60px","height":"60px","z-index":"10","font-family":"RobotoCondensed-Light"},"widgetSet":"basic"}]
-
@sigi234
Würdest du die Tankstellenbilder zur Verfügung stellen? -