SveinHa Skrevet 20. april 2023 Skrevet 20. april 2023 (endret) Inspirert av denne tråden hoppet jeg på å få litt drivstoffpriser inn i Node Red. Har på en måte ikke bruk for det siden jeg har appen på telefonen men det var nå litt gøy å lage. Det ble 2 varianter, den første er nok den som vil bli brukt for det meste: Redigert: Stasjonsnavnet får farge etter alder på prisoppdatering og prisen markeres ur fra over/under gjenomsnittspris. Variant 2 er langt mer fleksibel: Første tabellen inneholder > 2000 bensinstasjoner så der har jeg laget et søkefelt (case sensitive) for å begrense utvalget. Søker på alle felt. Klikk på en stasjon i venstre tabell flytter den over til favoritt tabellen i midten. Klikk på en stasjon i favoritt tabellen fjerner den. Alle stasjonene som befinner seg i favoritter vises i høyre tabell med alle drivstofftyper de har, pris og alder på prisdata. Hele greiene ser slik ut i Node Red: [{"id":"9103052baf82e5d0","type":"inject","z":"2447f70b5f1095ba","name":"Hvert 10 min","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"600","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":360,"y":130,"wires":[["d4dc462af536e73f"]]},{"id":"18ec6499f1fefde8","type":"function","z":"2447f70b5f1095ba","name":"Esso Avaldsnes","func":"var station = 'Esso Avaldsnes';\nvar msg2 = {}\nmsg.payload = msg.payload.filter((/** @type {{ discountInfo: string; }} */ e) => e.discountInfo == station);\nmsg.payload[0].stationDetails = msg.payload[0].stationDetails.filter(e => e.type == 'D');\nvar price = msg.payload[0].stationDetails[0].price;\nvar now = Number(new Date());\nvar age = (now - msg.payload[0].stationDetails[0].lastUpdated) / 3600 / 1000; //age in hours\nflow.set(\"EssoAval\", price);\n\nvar s1 = flow.get(\"EssoAval\") || 0\nvar s2 = flow.get(\"RevhStor\") || 0\nvar s3 = flow.get(\"ShelAval\") || 0\nvar s4 = flow.get(\"TankFlyp\") || 0\nvar s5 = flow.get(\"UnoXAval\") || 0\nvar s6 = flow.get(\"YX7ENorh\") || 0\nvar snitt = (s1 + s2 + s3 + s4 + s5 + s6) / 6;\nif (price < snitt) msg2.color = \"LIME\"; else msg2.color = \"RED\";\n\nmsg2.topic = station;\nmsg2.age = age.toFixed(1);\nif (age < 1) {\n msg2.stationcolor = \"LIME\";\n}\nelse if (age < 6) {\n msg2.stationcolor = \"YELLOW\";\n}\nelse if (age <= 12) {\n msg2.stationcolor = \"ORANGE\";\n}\nelse if (age > 12) {\n msg2.stationcolor = \"RED\";\n}\nmsg2.topic = station;\nmsg2.payload = price;\nreturn [msg, msg2];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":770,"y":130,"wires":[["0e5b02362818c9c1"],["835b0df2bd3edcbb","7014c2032a87fc3b"]]},{"id":"e7e0a907d77667f2","type":"function","z":"2447f70b5f1095ba","name":"Uno-X Avaldsnes","func":"var station = 'Uno-X Avaldsnes';\nvar msg2 = {}\nmsg.payload = msg.payload.filter((/** @type {{ discountInfo: string; }} */ e) => e.discountInfo == station);\nmsg.payload[0].stationDetails = msg.payload[0].stationDetails.filter(e => e.type == 'D');\nvar price = msg.payload[0].stationDetails[0].price;\nvar now = Number(new Date());\nvar age = (now - msg.payload[0].stationDetails[0].lastUpdated) / 3600 / 1000; //age in hours\nflow.set(\"UnoXAval\", price);\n\nvar s1 = flow.get(\"EssoAval\") || 0\nvar s2 = flow.get(\"RevhStor\") || 0\nvar s3 = flow.get(\"ShelAval\") || 0\nvar s4 = flow.get(\"TankFlyp\") || 0\nvar s5 = flow.get(\"UnoXAval\") || 0\nvar s6 = flow.get(\"YX7ENorh\") || 0\nvar snitt = (s1 + s2 + s3 + s4 + s5 + s6) / 6;\nif (price < snitt) msg2.color = \"LIME\"; else msg2.color = \"RED\";\n\nmsg2.topic = station;\nmsg2.age = age.toFixed(1);\nif (age < 1) {\n msg2.stationcolor = \"LIME\";\n}\nelse if (age < 6) {\n msg2.stationcolor = \"YELLOW\";\n}\nelse if (age <= 12) {\n msg2.stationcolor = \"ORANGE\";\n}\nelse if (age > 12) {\n msg2.stationcolor = \"RED\";\n}\nmsg2.topic = station;\nmsg2.payload = price;\nreturn [msg, msg2];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":160,"wires":[["0e5b02362818c9c1"],["835b0df2bd3edcbb","671050bdedc0c3cb"]]},{"id":"283d51c6efeddbb7","type":"function","z":"2447f70b5f1095ba","name":"YX 7-Eleven Norheim","func":"var station = 'YX 7-Eleven Norheim';\nvar msg2 = {}\nmsg.payload = msg.payload.filter((/** @type {{ discountInfo: string; }} */ e) => e.discountInfo == station);\nmsg.payload[0].stationDetails = msg.payload[0].stationDetails.filter(e => e.type == 'D');\nvar price = msg.payload[0].stationDetails[0].price;\nvar now = Number(new Date());\nvar age = (now - msg.payload[0].stationDetails[0].lastUpdated) / 3600 / 1000; //age in hours\nflow.set(\"YX7ENorh\", price);\n\nvar s1 = flow.get(\"EssoAval\") || 0\nvar s2 = flow.get(\"RevhStor\") || 0\nvar s3 = flow.get(\"ShelAval\") || 0\nvar s4 = flow.get(\"TankFlyp\") || 0\nvar s5 = flow.get(\"UnoXAval\") || 0\nvar s6 = flow.get(\"YX7ENorh\") || 0\nvar snitt = (s1 + s2 + s3 + s4 + s5 + s6) / 6;\nif (price < snitt) msg2.color = \"LIME\"; else msg2.color = \"RED\";\n\nmsg2.topic = station;\nmsg2.age = age.toFixed(1);\nif (age < 1) {\n msg2.stationcolor = \"LIME\";\n}\nelse if (age < 6) {\n msg2.stationcolor = \"YELLOW\";\n}\nelse if (age <= 12) {\n msg2.stationcolor = \"ORANGE\";\n}\nelse if (age > 12) {\n msg2.stationcolor = \"RED\";\n}\nmsg2.topic = station;\nmsg2.payload = price;\nreturn [msg, msg2];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":790,"y":190,"wires":[["0e5b02362818c9c1"],["835b0df2bd3edcbb","8e502b90702d3857"]]},{"id":"85dd9827b7d9a90c","type":"function","z":"2447f70b5f1095ba","name":"Tanken Helganes - Flyplassvegen","func":"var station = 'Tanken Helganes - Flyplassvegen';\nvar msg2 = {}\nmsg.payload = msg.payload.filter((/** @type {{ discountInfo: string; }} */ e) => e.discountInfo == station);\nmsg.payload[0].stationDetails = msg.payload[0].stationDetails.filter(e => e.type == 'D');\nvar price = msg.payload[0].stationDetails[0].price;\nvar now = Number(new Date());\nvar age = (now - msg.payload[0].stationDetails[0].lastUpdated) / 3600 / 1000; //age in hours\nflow.set(\"TankFlyp\", price);\n\nvar s1 = flow.get(\"EssoAval\") || 0\nvar s2 = flow.get(\"RevhStor\") || 0\nvar s3 = flow.get(\"ShelAval\") || 0\nvar s4 = flow.get(\"TankFlyp\") || 0\nvar s5 = flow.get(\"UnoXAval\") || 0\nvar s6 = flow.get(\"YX7ENorh\") || 0\nvar snitt = (s1 + s2 + s3 + s4 + s5 + s6) / 6;\nif (price < snitt) msg2.color = \"LIME\"; else msg2.color = \"RED\";\n\nmsg2.topic = station;\nmsg2.age = age.toFixed(1);\nif (age < 1) {\n msg2.stationcolor = \"LIME\";\n}\nelse if (age < 6) {\n msg2.stationcolor = \"YELLOW\";\n}\nelse if (age <= 12) {\n msg2.stationcolor = \"ORANGE\";\n}\nelse if (age > 12) {\n msg2.stationcolor = \"RED\";\n}\nmsg2.topic = station;\nmsg2.payload = price;\nreturn [msg, msg2];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":830,"y":220,"wires":[["0e5b02362818c9c1"],["835b0df2bd3edcbb","b1eaf76d80b124b2"]]},{"id":"e577f959c4c3e385","type":"function","z":"2447f70b5f1095ba","name":"Shell Avaldsnes","func":"var station = 'Shell Avaldsnes';\nvar msg2 = {}\nmsg.payload = msg.payload.filter((/** @type {{ discountInfo: string; }} */ e) => e.discountInfo == station);\nmsg.payload[0].stationDetails = msg.payload[0].stationDetails.filter(e => e.type == 'D');\nvar price = msg.payload[0].stationDetails[0].price;\nvar now = Number(new Date());\nvar age = (now - msg.payload[0].stationDetails[0].lastUpdated) / 3600 / 1000; //age in hours\nflow.set(\"ShelAval\", price);\n\nvar s1 = flow.get(\"EssoAval\") || 0\nvar s2 = flow.get(\"RevhStor\") || 0\nvar s3 = flow.get(\"ShelAval\") || 0\nvar s4 = flow.get(\"TankFlyp\") || 0\nvar s5 = flow.get(\"UnoXAval\") || 0\nvar s6 = flow.get(\"YX7ENorh\") || 0\nvar snitt = (s1 + s2 + s3 + s4 + s5 + s6) / 6;\nif (price < snitt) msg2.color = \"LIME\"; else msg2.color = \"RED\";\n\nmsg2.topic = station;\nmsg2.age = age.toFixed(1);\nif (age < 1) {\n msg2.stationcolor = \"LIME\";\n}\nelse if (age < 6) {\n msg2.stationcolor = \"YELLOW\";\n}\nelse if (age <= 12) {\n msg2.stationcolor = \"ORANGE\";\n}\nelse if (age > 12) {\n msg2.stationcolor = \"RED\";\n}\nmsg2.topic = station;\nmsg2.payload = price;\nreturn [msg, msg2];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":770,"y":250,"wires":[["0e5b02362818c9c1"],["835b0df2bd3edcbb","13527989f83e29d2"]]},{"id":"0e5b02362818c9c1","type":"debug","z":"2447f70b5f1095ba","name":"debug 88","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1000,"y":350,"wires":[]},{"id":"835b0df2bd3edcbb","type":"ui_chart","z":"2447f70b5f1095ba","name":"","group":"c5147f5beba7be52","order":1,"width":"23","height":"8","label":"Dieselpris (7d)","chartType":"line","legend":"true","xformat":"DD/MM HH","interpolate":"step","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"7","removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":1150,"y":130,"wires":[["dc20c0baebcded39"]]},{"id":"dc20c0baebcded39","type":"persist in","z":"2447f70b5f1095ba","name":"Dieselpriser","storageNode":"8a6654beead70801","x":1250,"y":80,"wires":[]},{"id":"52943a1fc077d28f","type":"persist out","z":"2447f70b5f1095ba","name":"Dieselpriser","storageNode":"8a6654beead70801","x":1070,"y":80,"wires":[["835b0df2bd3edcbb"]]},{"id":"7014c2032a87fc3b","type":"ui_text","z":"2447f70b5f1095ba","group":"c5147f5beba7be52","order":2,"width":"8","height":"1","name":"","label":"<font color=\"{{msg.stationcolor}}\">{{msg.topic}} ({{msg.age}}h)","format":"<font color=\"{{msg.color}}\">Kr.{{msg.payload}}","layout":"row-spread","className":"","x":1120,"y":160,"wires":[]},{"id":"671050bdedc0c3cb","type":"ui_text","z":"2447f70b5f1095ba","group":"c5147f5beba7be52","order":3,"width":"8","height":"1","name":"","label":"<font color=\"{{msg.stationcolor}}\">{{msg.topic}} ({{msg.age}}h)","format":"<font color=\"{{msg.color}}\">Kr.{{msg.payload}}","layout":"row-spread","className":"","x":1120,"y":190,"wires":[]},{"id":"8e502b90702d3857","type":"ui_text","z":"2447f70b5f1095ba","group":"c5147f5beba7be52","order":4,"width":"8","height":"1","name":"","label":"<font color=\"{{msg.stationcolor}}\">{{msg.topic}} ({{msg.age}}h)","format":"<font color=\"{{msg.color}}\">Kr.{{msg.payload}}","layout":"row-spread","className":"","x":1120,"y":220,"wires":[]},{"id":"b1eaf76d80b124b2","type":"ui_text","z":"2447f70b5f1095ba","group":"c5147f5beba7be52","order":5,"width":"8","height":"1","name":"","label":"<font color=\"{{msg.stationcolor}}\">{{msg.topic}} ({{msg.age}}h)","format":"<font color=\"{{msg.color}}\">Kr.{{msg.payload}}","layout":"row-spread","className":"","x":1120,"y":250,"wires":[]},{"id":"13527989f83e29d2","type":"ui_text","z":"2447f70b5f1095ba","group":"c5147f5beba7be52","order":6,"width":"8","height":"1","name":"","label":"<font color=\"{{msg.stationcolor}}\">{{msg.topic}} ({{msg.age}}h)","format":"<font color=\"{{msg.color}}\">Kr.{{msg.payload}}","layout":"row-spread","className":"","x":1120,"y":280,"wires":[]},{"id":"80fadd7556b173c2","type":"ui_text","z":"2447f70b5f1095ba","group":"c5147f5beba7be52","order":8,"width":"8","height":"1","name":"Legend","label":"<font color=\"LIME\"><1h <font color=\"YELLOW\"><6h <font color=\"ORANGE\"><=12h <font color=\"RED\">>12h<font color=#43464B> . . . . . . . . . . . . <font color=\"LIME\"> < <font color=\"WHITE\">avg<font color=\"RED\"><","format":"","layout":"row-spread","className":"","x":1130,"y":380,"wires":[]},{"id":"c622a1c1b5d187fe","type":"function","z":"2447f70b5f1095ba","name":"List all stations","func":"flow.set(\"Stations\",msg.payload);\nvar arr = [];\nvar msg2 = {}\nfor (var i = 0;i < msg.payload.length;i++){\n let obj = {}\n obj.id = msg.payload[i].id;\n obj.name = msg.payload[i].name || \"-\"\n obj.brand = msg.payload[i].brand || \"-\"\n obj.discountInfo = msg.payload[i].discountInfo || \"-\"\n arr.push(obj);\n}\nmsg2.payload = arr;\nreturn msg2; ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":440,"wires":[["6ffebf4f1340a92e","f193882be2dc7762"]]},{"id":"32b13b757f4465ec","type":"function","z":"2447f70b5f1095ba","name":"Revheim Storbilvask","func":"var station = 'Revheim Storbilvask';\nvar msg2 = {}\nmsg.payload = msg.payload.filter((/** @type {{ discountInfo: string; }} */ e) => e.discountInfo == station);\nmsg.payload[0].stationDetails = msg.payload[0].stationDetails.filter(e => e.type == 'D');\nvar price = msg.payload[0].stationDetails[0].price;\nvar now = Number(new Date());\nvar age = (now - msg.payload[0].stationDetails[0].lastUpdated) / 3600 / 1000; //age in hours\nflow.set(\"RevhStor\",price);\n\nvar s1 = flow.get(\"EssoAval\") || 0\nvar s2 = flow.get(\"RevhStor\") || 0\nvar s3 = flow.get(\"ShelAval\") || 0\nvar s4 = flow.get(\"TankFlyp\") || 0\nvar s5 = flow.get(\"UnoXAval\") || 0\nvar s6 = flow.get(\"YX7ENorh\") || 0\nvar snitt = (s1 + s2 + s3 + s4 + s5 + s6) / 6;\nif (price < snitt) msg2.color = \"LIME\"; else msg2.color = \"RED\";\n\nmsg2.topic = station;\nmsg2.age = age.toFixed(1);\nif (age < 1) {\n msg2.stationcolor = \"LIME\";\n}\nelse if (age < 6) {\n msg2.stationcolor = \"YELLOW\";\n}\nelse if (age <= 12) {\n msg2.stationcolor = \"ORANGE\";\n}\nelse if (age > 12) {\n msg2.stationcolor = \"RED\";\n}\nmsg2.topic = station;\nmsg2.payload = price;\nreturn [msg, msg2];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":790,"y":280,"wires":[["0e5b02362818c9c1"],["a789bc33845b6aae","835b0df2bd3edcbb"]]},{"id":"a789bc33845b6aae","type":"ui_text","z":"2447f70b5f1095ba","group":"c5147f5beba7be52","order":7,"width":"8","height":"1","name":"","label":"<font color=\"{{msg.stationcolor}}\">{{msg.topic}} ({{msg.age}}h)","format":"<font color=\"{{msg.color}}\">Kr.{{msg.payload}}","layout":"row-spread","className":"","x":1120,"y":310,"wires":[]},{"id":"28fe85a134fe0971","type":"debug","z":"2447f70b5f1095ba","name":"debug 89","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":750,"y":340,"wires":[]},{"id":"6ffebf4f1340a92e","type":"ui_table","z":"2447f70b5f1095ba","group":"0d788a3660f620b1","name":"All stations","order":4,"width":"10","height":"15","columns":[{"field":"name","title":"","width":"30%","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"brand","title":"","width":"27%","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"discountInfo","title":"","width":"40%","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}}],"outputs":1,"cts":true,"x":760,"y":440,"wires":[["fc1b2554d6e80f6b"]]},{"id":"fc1b2554d6e80f6b","type":"function","z":"2447f70b5f1095ba","name":"add to favs","func":"var favs = flow.get(\"Favs\") || []\nvar pl = msg.payload;\nvar arr = [];\nvar exists = false;\narr = favs;\n\nfor (var i = 0;i < favs.length;i++){\n if (favs[i].id == pl.id) exists = true;\n}\nif (exists == false) arr.push(pl);\n\nflow.set(\"Favs\", arr);\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":480,"wires":[["6bfcbbe7c43dcc84"]]},{"id":"5fd3c4e366a636d6","type":"ui_table","z":"2447f70b5f1095ba","group":"0d788a3660f620b1","name":"Selected stations","order":5,"width":"10","height":"16","columns":[{"field":"name","title":"","width":"30%","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"brand","title":"","width":"30%","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"discountInfo","title":"","width":"40%","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}}],"outputs":1,"cts":true,"x":780,"y":480,"wires":[["03dc6f5b94c49e02"]]},{"id":"6bfcbbe7c43dcc84","type":"function","z":"2447f70b5f1095ba","name":"List fav stations","func":"var favs = flow.get(\"Favs\") || []\nvar arr = []\nvar msg2 = {}\nfor (var i = 0;i < favs.length;i++){\n let obj = {}\n obj.id = favs[i].id;\n obj.name = favs[i].name;\n obj.brand = favs[i].brand;\n obj.discountInfo = favs[i].discountInfo;\n arr.push(obj);\n}\nmsg2.payload = arr;\nreturn msg2; ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":550,"y":480,"wires":[["5fd3c4e366a636d6","f193882be2dc7762"]]},{"id":"03dc6f5b94c49e02","type":"function","z":"2447f70b5f1095ba","name":"Remove station from fav","func":"var i,j = 0;\nvar favs = flow.get(\"Favs\") || []\nvar favs2 = []\nvar remove = msg.payload;\nvar arr = []\nvar msg2 = {}\nfor (i = 0;i < favs.length;i++){\n if (favs[i].id != remove.id){\n favs2[j] = favs[i];\n j++;\n }\n}\nflow.set(\"Favs\", favs2)\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":650,"y":550,"wires":[["6bfcbbe7c43dcc84"]]},{"id":"4d95ecb3e17e80a4","type":"ui_table","z":"2447f70b5f1095ba","group":"0d788a3660f620b1","name":"Drivstoffpriser","order":6,"width":"10","height":"16","columns":[{"field":"discountInfo","title":"","width":"55%","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"type","title":"","width":"15%","align":"right","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"price","title":"Kr","width":"15%","align":"right","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"age","title":"hrs.","width":"15%","align":"right","formatter":"plaintext","formatterParams":{"target":"_blank"}}],"outputs":1,"cts":true,"x":770,"y":600,"wires":[[]]},{"id":"bf43e528a5851b0d","type":"function","z":"2447f70b5f1095ba","name":"List priser for favs","func":"var favs = flow.get(\"Favs\") || []\nvar stats = flow.get(\"Stations\") || []\nvar arr = []\nvar msg2 = {}\nvar now = Number(new Date());\nvar age = 0;\n\nfor (var i = 0;i < stats.length;i++){ //bla gjennom alle stasjoner\n for (var j = 0;j < favs.length;j++){ // bla gjennom favoritter\n if (stats[i].id == favs[j].id){ //er gjeldende stasjon i favoritter?\n for (var k = 0; k < stats[i].stationDetails.length; k++){ // bla gjennom drivstofftyper\n let obj = {}\n obj.name = stats[i].name;\n obj.brand = stats[i].brand;\n obj.discountInfo = stats[i].discountInfo;\n // fix dårlig benevning\n if (obj.brand == obj.discountInfo) obj.discountInfo = obj.discountInfo + \" \" + obj.name;\n obj.type = stats[i].stationDetails[k].type;\n obj.price = stats[i].stationDetails[k].price;\n obj.age = ((now - stats[i].stationDetails[k].lastUpdated) / 3600 / 1000).toFixed(1);// + \"h\"; //age in hours\n arr.push(obj);\n }\n }\n }\n}\nmsg2.payload = arr;\nreturn msg2;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":600,"wires":[["4d95ecb3e17e80a4"]]},{"id":"f193882be2dc7762","type":"delay","z":"2447f70b5f1095ba","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":310,"y":600,"wires":[["bf43e528a5851b0d"]]},{"id":"d9d0882ba114f2ae","type":"ui_text_input","z":"2447f70b5f1095ba","name":"","label":"Søk...","tooltip":"","group":"0d788a3660f620b1","order":7,"width":"10","height":"1","passthru":true,"mode":"text","delay":300,"topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":300,"y":410,"wires":[["dd937fc64214f72d"]]},{"id":"dd937fc64214f72d","type":"function","z":"2447f70b5f1095ba","name":"List selected stations","func":"var stats = flow.get(\"Stations\") || []\nvar searchText = msg.payload;\nvar arr = [];\nvar msg2 = {}\nfor (var i = 0;i < stats.length;i++){\n let obj = {}\n obj.id = stats[i].id;\n obj.name = stats[i].name || \"-\"\n obj.brand = stats[i].brand || \"-\"\n obj.discountInfo = stats[i].discountInfo || \"-\"\n // plukk ut bare stasjoner som inneholder søkebegrepet\n if (obj.name.includes(searchText) || obj.brand.includes(searchText) || obj.discountInfo.includes(searchText)){\n arr.push(obj);\n }\n}\nmsg2.payload = arr;\nreturn msg2;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":410,"wires":[["6ffebf4f1340a92e"]]},{"id":"13d4a47fe1d5ae74","type":"ui_text","z":"2447f70b5f1095ba","group":"0d788a3660f620b1","order":1,"width":"10","height":"1","name":"","label":"Alle stasjoner","format":"{{msg.payload}}","layout":"row-spread","className":"","x":1150,"y":430,"wires":[]},{"id":"65cdb903a6486baf","type":"ui_text","z":"2447f70b5f1095ba","group":"0d788a3660f620b1","order":2,"width":"10","height":"1","name":"","label":"Favoritter","format":"{{msg.payload}}","layout":"row-spread","className":"","x":1130,"y":460,"wires":[]},{"id":"6e102042f9d3270e","type":"ui_text","z":"2447f70b5f1095ba","group":"0d788a3660f620b1","order":3,"width":"10","height":"1","name":"","label":"Priser","format":"{{msg.payload}}","layout":"row-spread","className":"","x":1120,"y":490,"wires":[]},{"id":"d4dc462af536e73f","type":"http request","z":"2447f70b5f1095ba","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api.drivstoffappen.no/api/stations?stationType=0&countryCode=NO","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"Content-Type","valueType":"other","valueValue":"application/json"},{"keyType":"other","keyValue":"X-API-KEY","valueType":"other","valueValue":"2CD114509703F6E0A976C32FCB79C4F62966EEC6"},{"keyType":"other","keyValue":"User-Agent","valueType":"other","valueValue":"Drivstoffappen/1.3.8 (com.raskebiler.drivstoff.appen; build:130; iOS 15.2.1) Alamofire/5.4.4"}],"x":540,"y":130,"wires":[["c622a1c1b5d187fe","18ec6499f1fefde8","e7e0a907d77667f2","283d51c6efeddbb7","85dd9827b7d9a90c","e577f959c4c3e385","32b13b757f4465ec","28fe85a134fe0971"]]},{"id":"c5147f5beba7be52","type":"ui_group","name":"Wide","tab":"8b4128994ad0c3a1","order":2,"disp":false,"width":"31","collapse":false,"className":""},{"id":"8a6654beead70801","type":"persist-store","filename":"diesel.json","interval":"600"},{"id":"0d788a3660f620b1","type":"ui_group","name":"Drivstoffpriser","tab":"1083c01bcc75e66c","order":1,"disp":true,"width":"31","collapse":false,"className":""},{"id":"8b4128994ad0c3a1","type":"ui_tab","name":"Sol + vær","icon":"wb_sunny","order":4,"disabled":false,"hidden":false},{"id":"1083c01bcc75e66c","type":"ui_tab","name":"Drivstoff","icon":"local_gas_station","order":22,"disabled":false,"hidden":false}] Endret 29. april 2023 av SveinHa 2 Siter
hflatoey Skrevet 29. april 2023 Skrevet 29. april 2023 Har to elbiler, ellers hadde det sikkert vært nyttig 🙂 Siter
Anbefalte innlegg
Bli med i samtalen
Du kan publisere innhold nå og registrere deg senere. Hvis du har en konto, logg inn nå for å poste med kontoen din.