[
    {
        "id": "180b7e98628a2a9b",
        "type": "tab",
        "label": "Spritmonitor",
        "disabled": false,
        "info": "# Spritmonitor\r\n\r\nDieser Flow ruft Daten aus dem Spritmonitor ab und stellt sie im NodeRed Dashboard dar.\r\nFür diesen Flow und der Verwendung der API benötigen Sie eine Application ID.\r\n\r\nWeitere Informationen finden Sie unter: https://github.com/FundF/Spritmonitor-API-sample-code.\r\n\r\nFalls sie bereits ein Token haben, dann können Sie es in diesem Flow in der Umgebungsvariable `ApplicationID` abspeichern.\r\nStandardmäßig können die letzten 5 Jahre abgefragt werden. Wünschen Sie einen früheren Zeitraum zur Auswahl, so können Sie eine Jahreszahl in der Umgebungsvariable `sinceYears` festlegen.\r\n\r\nZur Erstellung ihres persönlichen Zugangstokens, erstellen Sie sich eines [auf der Seite zur Passwortänderung](https://www.spritmonitor.de/de/mein_account/passwort_aendern.html) und kopieren dies an eine sichere Stelle.\r\n\r\n---\r\n\r\nThis flow retrieves data from Spritmonitor.de and presents the data on the NodeRed Dashboard.\r\nTo use this flow and the API an application ID is required.\r\n\r\nFor further information see: https://github.com/FundF/Spritmonitor-API-sample-code.\r\n\r\nIf you have already an application token, you can store the token in the environement `ApplicationID`  of this flow.\r\nPer default you can select the last 5 years. If you whish to ask for earlier years then you can specify this in the environement variable `sinceYears` of this flow, instead of modifying the flow.\r\n\r\nYou can create your personal access token [on the page where you change your password](https://www.spritmonitor.de/en/mein_account/passwort_aendern.html) and copy this token to a safe place.",
        "env": [
            {
                "name": "ApplicationID",
                "value": "",
                "type": "str"
            },
            {
                "name": "sinceYear",
                "value": "",
                "type": "num"
            }
        ]
    },
    {
        "id": "492b8f05655a8de9",
        "type": "junction",
        "z": "180b7e98628a2a9b",
        "x": 3060,
        "y": 360,
        "wires": [
            [
                "65231065d3bd4601"
            ]
        ]
    },
    {
        "id": "234af19bb5cebcf5",
        "type": "junction",
        "z": "180b7e98628a2a9b",
        "x": 1540,
        "y": 700,
        "wires": [
            [
                "73ceb696d4d74724",
                "92cd61654fd87ff3",
                "ac0c9f97e97ef311",
                "f0d987185087e184",
                "44b8ddc38f155a87"
            ]
        ]
    },
    {
        "id": "25c8db05d839b4fd",
        "type": "junction",
        "z": "180b7e98628a2a9b",
        "x": 1360,
        "y": 960,
        "wires": [
            [
                "3625c31ff7a1e803",
                "ec46375d59c72fdf"
            ]
        ]
    },
    {
        "id": "640b1067b6a9a9a4",
        "type": "junction",
        "z": "180b7e98628a2a9b",
        "x": 1840,
        "y": 1060,
        "wires": [
            [
                "1b55e76cb71326bb",
                "412a564372f2a9fe",
                "1cea91c8e0030670"
            ]
        ]
    },
    {
        "id": "aa43298e9f36d5a8",
        "type": "junction",
        "z": "180b7e98628a2a9b",
        "x": 2300,
        "y": 720,
        "wires": [
            [
                "4b6aecce660a12a7",
                "86b52ee43408e73d"
            ]
        ]
    },
    {
        "id": "3ec8915422b09722",
        "type": "junction",
        "z": "180b7e98628a2a9b",
        "x": 2400,
        "y": 1160,
        "wires": [
            [
                "4ca1d0db1cf957f1",
                "7d4b38136967ced7",
                "e28b0339ed6c5b08"
            ]
        ]
    },
    {
        "id": "68ffa627923541cb",
        "type": "junction",
        "z": "180b7e98628a2a9b",
        "x": 2820,
        "y": 300,
        "wires": [
            [
                "65bab6181422de9f"
            ]
        ]
    },
    {
        "id": "3b080e41f31ea6e0",
        "type": "junction",
        "z": "180b7e98628a2a9b",
        "x": 1000,
        "y": 620,
        "wires": [
            [
                "ab1e10b5f5d99009"
            ]
        ]
    },
    {
        "id": "eb9501cd8e489fc3",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "headers",
                "pt": "flow",
                "to": "{\t   \"accept\":\"application/json\",\t   \"Authorization\":\"Bearer \" & payload,\t   \"APPLICATION-ID\":$env(\"ApplicationID\")\t}",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1430,
        "y": 220,
        "wires": [
            [
                "2af34278f3882be7"
            ]
        ]
    },
    {
        "id": "31e131eb95a7f3d0",
        "type": "http request",
        "z": "180b7e98628a2a9b",
        "name": "Anmeldung",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "https://api.spritmonitor.de/v1/vehicles.json",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 2070,
        "y": 260,
        "wires": [
            [
                "e6ad7f31979703b1"
            ]
        ]
    },
    {
        "id": "efc398fb3570c5de",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "headers",
                "pt": "msg",
                "to": "headers",
                "tot": "flow"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1870,
        "y": 260,
        "wires": [
            [
                "31e131eb95a7f3d0"
            ]
        ]
    },
    {
        "id": "e6ad7f31979703b1",
        "type": "switch",
        "z": "180b7e98628a2a9b",
        "name": "",
        "property": "statusCode",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "200",
                "vt": "num"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 2230,
        "y": 260,
        "wires": [
            [
                "6280a616f5c67b53"
            ],
            [
                "01ee464014b12ad0"
            ]
        ]
    },
    {
        "id": "01ee464014b12ad0",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "Anmeldung fehlgeschlagen",
        "rules": [
            {
                "t": "set",
                "p": "label",
                "pt": "msg",
                "to": "Anmeldung nicht erfolgreich!",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "anmeldung.ok",
                "pt": "flow",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2460,
        "y": 300,
        "wires": [
            [
                "492b8f05655a8de9",
                "68ffa627923541cb"
            ]
        ]
    },
    {
        "id": "65bab6181422de9f",
        "type": "ui_text",
        "z": "180b7e98628a2a9b",
        "group": "e3666278fb9f3db1",
        "order": 2,
        "width": 0,
        "height": 0,
        "name": "Anmeldestatus",
        "label": "{{msg.label}}",
        "format": "{{msg.payload}}",
        "layout": "col-center",
        "className": "",
        "x": 3140,
        "y": 300,
        "wires": []
    },
    {
        "id": "6280a616f5c67b53",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "label",
                "pt": "msg",
                "to": "Anmeldung erfolgreich:",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2420,
        "y": 240,
        "wires": [
            [
                "43423aeb4b224891"
            ]
        ]
    },
    {
        "id": "43423aeb4b224891",
        "type": "json",
        "z": "180b7e98628a2a9b",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 2590,
        "y": 240,
        "wires": [
            [
                "cdf4040cd9b8791e"
            ]
        ]
    },
    {
        "id": "cdf4040cd9b8791e",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "Anmeldung erfolgreich",
        "rules": [
            {
                "t": "set",
                "p": "fahrzeuge",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$count(payload) & \" Fahrzeuge gefunden!\"\t",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "anmeldung.ok",
                "pt": "flow",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2780,
        "y": 240,
        "wires": [
            [
                "65bab6181422de9f",
                "492b8f05655a8de9"
            ]
        ]
    },
    {
        "id": "d203383a2ba8a3cc",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "fahrzeuge",
                "tot": "flow"
            },
            {
                "t": "set",
                "p": "options",
                "pt": "msg",
                "to": "payload.{make & \" - \" & model:id} ",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 470,
        "y": 560,
        "wires": [
            [
                "e0ca375bca5e4511"
            ]
        ]
    },
    {
        "id": "e059153745380131",
        "type": "comment",
        "z": "180b7e98628a2a9b",
        "name": "Anmeldung",
        "info": "",
        "x": 150,
        "y": 60,
        "wires": []
    },
    {
        "id": "ab1e10b5f5d99009",
        "type": "ui_dropdown",
        "z": "180b7e98628a2a9b",
        "name": "",
        "label": "",
        "tooltip": "",
        "place": "Fahrzeug wählen",
        "group": "9b626ac5e26ef90a",
        "order": 1,
        "width": 0,
        "height": 0,
        "passthru": false,
        "multiple": false,
        "options": [
            {
                "label": "",
                "value": "",
                "type": "str"
            }
        ],
        "payload": "",
        "topic": "topic",
        "topicType": "msg",
        "className": "",
        "x": 1120,
        "y": 620,
        "wires": [
            [
                "7041e8c0ca24e250",
                "82974f3862aa79fb"
            ]
        ]
    },
    {
        "id": "7041e8c0ca24e250",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "Aktives Fahrzeug",
        "rules": [
            {
                "t": "move",
                "p": "payload",
                "pt": "msg",
                "to": "carID",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "fahrzeuge",
                "tot": "flow"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload[id=$$.carID]",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "carID",
                "pt": "flow",
                "to": "carID",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1350,
        "y": 620,
        "wires": [
            [
                "7ed1a66148f7fa86",
                "234af19bb5cebcf5"
            ]
        ]
    },
    {
        "id": "f0d987185087e184",
        "type": "ui_text",
        "z": "180b7e98628a2a9b",
        "group": "9b626ac5e26ef90a",
        "order": 2,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Kennzeichen",
        "format": "{{msg.payload.sign}}",
        "layout": "row-spread",
        "className": "",
        "x": 1750,
        "y": 740,
        "wires": []
    },
    {
        "id": "ac0c9f97e97ef311",
        "type": "ui_text",
        "z": "180b7e98628a2a9b",
        "group": "9b626ac5e26ef90a",
        "order": 5,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Durchschnittsverbrauch",
        "format": "{{msg.payload.consumption}} {{msg.payload.consumptionunit}}",
        "layout": "row-spread",
        "className": "",
        "x": 1790,
        "y": 780,
        "wires": []
    },
    {
        "id": "92cd61654fd87ff3",
        "type": "ui_text",
        "z": "180b7e98628a2a9b",
        "group": "9b626ac5e26ef90a",
        "order": 6,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "gefahrene Kilometer",
        "format": "{{msg.payload.tripsum}} {{msg.payload.tripunit}}",
        "layout": "row-spread",
        "className": "",
        "x": 1780,
        "y": 820,
        "wires": []
    },
    {
        "id": "73ceb696d4d74724",
        "type": "ui_text",
        "z": "180b7e98628a2a9b",
        "group": "9b626ac5e26ef90a",
        "order": 7,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "getankt [gesamt]",
        "format": "{{msg.payload.quantitysum}} l",
        "layout": "row-spread",
        "className": "",
        "x": 1770,
        "y": 860,
        "wires": []
    },
    {
        "id": "86b52ee43408e73d",
        "type": "ui_text",
        "z": "180b7e98628a2a9b",
        "group": "9b626ac5e26ef90a",
        "order": 4,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Kraftstoffart",
        "format": "{{msg.payload[0].name}}",
        "layout": "row-spread",
        "className": "",
        "x": 2430,
        "y": 740,
        "wires": []
    },
    {
        "id": "7ed1a66148f7fa86",
        "type": "template",
        "z": "180b7e98628a2a9b",
        "name": "",
        "field": "url",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "https://api.spritmonitor.de/v1/vehicle/{{carID}}/tanks.json",
        "output": "str",
        "x": 1600,
        "y": 620,
        "wires": [
            [
                "fa72cbf8b647918c"
            ]
        ]
    },
    {
        "id": "c616ddb9048f7522",
        "type": "http request",
        "z": "180b7e98628a2a9b",
        "name": "Betankung insgesamt",
        "method": "GET",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 2240,
        "y": 620,
        "wires": [
            [
                "684888fc21922bf5",
                "aa43298e9f36d5a8"
            ]
        ]
    },
    {
        "id": "fa72cbf8b647918c",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "headers",
                "pt": "msg",
                "to": "headers",
                "tot": "flow"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1790,
        "y": 620,
        "wires": [
            [
                "9e425b8438f6c31d"
            ]
        ]
    },
    {
        "id": "4b6aecce660a12a7",
        "type": "ui_text",
        "z": "180b7e98628a2a9b",
        "group": "9b626ac5e26ef90a",
        "order": 3,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Kilometerstand",
        "format": "{{msg.payload[0].maxkmpos}} km",
        "layout": "row-spread",
        "className": "",
        "x": 2440,
        "y": 700,
        "wires": []
    },
    {
        "id": "684888fc21922bf5",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "tankID",
                "pt": "flow",
                "to": "payload[0].id",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2490,
        "y": 620,
        "wires": [
            []
        ]
    },
    {
        "id": "9b600598091d57ba",
        "type": "comment",
        "z": "180b7e98628a2a9b",
        "name": "Aktives Fahrzeug",
        "info": "",
        "x": 160,
        "y": 420,
        "wires": []
    },
    {
        "id": "e1b839cbd2fe1712",
        "type": "comment",
        "z": "180b7e98628a2a9b",
        "name": "Betankungen",
        "info": "",
        "x": 250,
        "y": 980,
        "wires": []
    },
    {
        "id": "3c380426bd8546c6",
        "type": "ui_dropdown",
        "z": "180b7e98628a2a9b",
        "name": "",
        "label": "Jahr",
        "tooltip": "",
        "place": "bitte auswählen ...",
        "group": "047787a3340d50f2",
        "order": 2,
        "width": "6",
        "height": "1",
        "passthru": true,
        "multiple": false,
        "options": [],
        "payload": "",
        "topic": "topic",
        "topicType": "msg",
        "className": "",
        "x": 610,
        "y": 1200,
        "wires": [
            [
                "c050b79dca4c5aea"
            ]
        ]
    },
    {
        "id": "44b8ddc38f155a87",
        "type": "ui_text",
        "z": "180b7e98628a2a9b",
        "group": "047787a3340d50f2",
        "order": 1,
        "width": "6",
        "height": "1",
        "name": "",
        "label": "Fahrzeug:",
        "format": "{{msg.payload.make}} - {{msg.payload.model}}",
        "layout": "row-center",
        "className": "",
        "x": 1740,
        "y": 700,
        "wires": []
    },
    {
        "id": "2a6afa98b6c29fbb",
        "type": "template",
        "z": "180b7e98628a2a9b",
        "name": "",
        "field": "url",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "https://api.spritmonitor.de/v1/vehicle/{{carID}}/tank/{{tankID}}/fuelings.json?offset=0&limit=400&sdate=01.01.{{payload}}&edate=31.12.{{payload}}",
        "output": "str",
        "x": 1180,
        "y": 1200,
        "wires": [
            [
                "f72662904a439d4c"
            ]
        ]
    },
    {
        "id": "41e3bac907528721",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "carID",
                "pt": "msg",
                "to": "carID",
                "tot": "flow"
            },
            {
                "t": "set",
                "p": "tankID",
                "pt": "msg",
                "to": "tankID",
                "tot": "flow"
            },
            {
                "t": "set",
                "p": "selectedYear",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 990,
        "y": 1200,
        "wires": [
            [
                "2a6afa98b6c29fbb"
            ]
        ]
    },
    {
        "id": "a984b698dd14fd45",
        "type": "http request",
        "z": "180b7e98628a2a9b",
        "name": "Betankung im Jahr (Detail)",
        "method": "GET",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 1640,
        "y": 1200,
        "wires": [
            [
                "640b1067b6a9a9a4"
            ]
        ]
    },
    {
        "id": "f72662904a439d4c",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "headers",
                "pt": "msg",
                "to": "headers",
                "tot": "flow"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1370,
        "y": 1200,
        "wires": [
            [
                "a984b698dd14fd45"
            ]
        ]
    },
    {
        "id": "412a564372f2a9fe",
        "type": "ui_table",
        "z": "180b7e98628a2a9b",
        "group": "047787a3340d50f2",
        "name": "",
        "order": 3,
        "width": "12",
        "height": "12",
        "columns": [
            {
                "field": "date",
                "title": "Datum",
                "width": "15px",
                "align": "center",
                "formatter": "plaintext",
                "formatterParams": {
                    "target": "_blank"
                }
            },
            {
                "field": "odometer",
                "title": "Kilometerstand",
                "width": "25px",
                "align": "right",
                "formatter": "plaintext",
                "formatterParams": {
                    "target": "_blank"
                }
            },
            {
                "field": "trip",
                "title": "Fahrt [km]",
                "width": "18px",
                "align": "right",
                "formatter": "plaintext",
                "formatterParams": {
                    "target": "_blank"
                }
            },
            {
                "field": "quantity_converted",
                "title": "Getankt [l]",
                "width": "18px",
                "align": "right",
                "formatter": "plaintext",
                "formatterParams": {
                    "target": "_blank"
                }
            },
            {
                "field": "cost",
                "title": "Kosten [€]",
                "width": "18px",
                "align": "right",
                "formatter": "plaintext",
                "formatterParams": {
                    "target": "_blank"
                }
            },
            {
                "field": "stationname",
                "title": "Tankstelle",
                "width": "",
                "align": "center",
                "formatter": "plaintext",
                "formatterParams": {
                    "target": "_blank"
                }
            },
            {
                "field": "bc_speed",
                "title": "&Oslash-Geschwindigkeit (BC) [km/h]",
                "width": "38px",
                "align": "right",
                "formatter": "plaintext",
                "formatterParams": {
                    "target": "_blank"
                }
            },
            {
                "field": "bc_consumption",
                "title": "&Oslash-Verbrauch (BC) [l]",
                "width": "28px",
                "align": "right",
                "formatter": "plaintext",
                "formatterParams": {
                    "target": "_blank"
                }
            }
        ],
        "outputs": 0,
        "cts": false,
        "x": 1970,
        "y": 1060,
        "wires": []
    },
    {
        "id": "219aced3395fba74",
        "type": "ui_template",
        "z": "180b7e98628a2a9b",
        "group": "047787a3340d50f2",
        "name": "Summen Betankungen",
        "order": 4,
        "width": 0,
        "height": 0,
        "format": "<font size=4 style=\"font-weight:500\" color=var(--nr-dashboard-TextColor)>&nbsp;Summen {{msg.payload}}</font>",
        "storeOutMessages": true,
        "fwdInMessages": true,
        "resendOnRefresh": true,
        "templateScope": "local",
        "className": "",
        "x": 2900,
        "y": 980,
        "wires": [
            []
        ]
    },
    {
        "id": "1b55e76cb71326bb",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "delete",
                "p": "summen",
                "pt": "flow"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2020,
        "y": 1160,
        "wires": [
            [
                "4d471d6801b4fb2c"
            ]
        ]
    },
    {
        "id": "4d471d6801b4fb2c",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "(\t    $new := payload.{\"km\":trip = null ? 0 : $number(trip), \"getankt\" : $number(quantity), \"kosten\" :  $number(cost)};\t    $total :=  {\"km\" : $round($sum($new.km),2), \"getankt\" : $round($sum($new.getankt),2), \"kosten\" : $round($sum($new.kosten),2)};\t)",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2250,
        "y": 1160,
        "wires": [
            [
                "3ec8915422b09722"
            ]
        ]
    },
    {
        "id": "e28b0339ed6c5b08",
        "type": "ui_text",
        "z": "180b7e98628a2a9b",
        "group": "047787a3340d50f2",
        "order": 5,
        "width": "4",
        "height": "1",
        "name": "",
        "label": "Kilometer:",
        "format": "{{msg.payload.km}} km",
        "layout": "row-center",
        "className": "",
        "x": 2520,
        "y": 1120,
        "wires": []
    },
    {
        "id": "4ca1d0db1cf957f1",
        "type": "ui_text",
        "z": "180b7e98628a2a9b",
        "group": "047787a3340d50f2",
        "order": 6,
        "width": "4",
        "height": "1",
        "name": "",
        "label": "Getankt:",
        "format": "{{msg.payload.getankt}} l",
        "layout": "row-center",
        "className": "",
        "x": 2520,
        "y": 1160,
        "wires": []
    },
    {
        "id": "7d4b38136967ced7",
        "type": "ui_text",
        "z": "180b7e98628a2a9b",
        "group": "047787a3340d50f2",
        "order": 7,
        "width": "4",
        "height": "1",
        "name": "",
        "label": "Gesamtkosten:",
        "format": "{{msg.payload.kosten}} €",
        "layout": "row-center",
        "className": "",
        "x": 2540,
        "y": 1200,
        "wires": []
    },
    {
        "id": "82974f3862aa79fb",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "Übernehme Jahr für neues Fahrzeug",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "selectedYear",
                "tot": "flow"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 350,
        "y": 1260,
        "wires": [
            [
                "3c380426bd8546c6"
            ]
        ]
    },
    {
        "id": "48a73ff79f2cb53a",
        "type": "ui_text_input",
        "z": "180b7e98628a2a9b",
        "name": "",
        "label": "Anmeldetoken",
        "tooltip": "Das Anmeldetoken ist erforderlich für den Zugriff auf Ihre Daten",
        "group": "e3666278fb9f3db1",
        "order": 1,
        "width": 0,
        "height": 0,
        "passthru": false,
        "mode": "password",
        "delay": "300",
        "topic": "Anmeldetoken",
        "sendOnBlur": true,
        "className": "",
        "topicType": "str",
        "x": 660,
        "y": 140,
        "wires": [
            [
                "1cd8219c6bd86cec"
            ]
        ]
    },
    {
        "id": "46d9c02ff25a9672",
        "type": "ui_button",
        "z": "180b7e98628a2a9b",
        "name": "An-/Abmelden",
        "group": "e3666278fb9f3db1",
        "order": 3,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "{{msg.topic}}",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "anmeldung.token",
        "payloadType": "flow",
        "topic": "topic",
        "topicType": "msg",
        "x": 580,
        "y": 260,
        "wires": [
            [
                "3b1df508490b3395"
            ]
        ]
    },
    {
        "id": "1cd8219c6bd86cec",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "anmeldung.token",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 900,
        "y": 140,
        "wires": [
            []
        ]
    },
    {
        "id": "190c03a69577c331",
        "type": "complete",
        "z": "180b7e98628a2a9b",
        "name": "",
        "scope": [
            "01ee464014b12ad0",
            "cdf4040cd9b8791e",
            "8bdcf24f059aa5d7"
        ],
        "uncaught": false,
        "x": 170,
        "y": 140,
        "wires": [
            [
                "b99396b97211ec1e",
                "bdcd72b2f5e2894a"
            ]
        ]
    },
    {
        "id": "b99396b97211ec1e",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 450,
        "y": 140,
        "wires": [
            [
                "48a73ff79f2cb53a"
            ]
        ]
    },
    {
        "id": "3b1df508490b3395",
        "type": "delay",
        "z": "180b7e98628a2a9b",
        "name": "",
        "pauseType": "delay",
        "timeout": "300",
        "timeoutUnits": "milliseconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 800,
        "y": 260,
        "wires": [
            [
                "424c689d975b22d4"
            ]
        ]
    },
    {
        "id": "b188bcd7fbbacf85",
        "type": "inject",
        "z": "180b7e98628a2a9b",
        "name": "",
        "props": [
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "Anmelden",
        "x": 170,
        "y": 260,
        "wires": [
            [
                "46d9c02ff25a9672"
            ]
        ]
    },
    {
        "id": "424c689d975b22d4",
        "type": "switch",
        "z": "180b7e98628a2a9b",
        "name": "An- oder Abmelden?",
        "property": "topic",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "Anmelden",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "Abmelden",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 1040,
        "y": 260,
        "wires": [
            [
                "e3dd835cd20237af"
            ],
            [
                "8bdcf24f059aa5d7"
            ]
        ]
    },
    {
        "id": "e3dd835cd20237af",
        "type": "switch",
        "z": "180b7e98628a2a9b",
        "name": "Token?",
        "property": "anmeldung.token",
        "propertyType": "flow",
        "rules": [
            {
                "t": "nempty"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 1240,
        "y": 220,
        "wires": [
            [
                "eb9501cd8e489fc3"
            ]
        ]
    },
    {
        "id": "2af34278f3882be7",
        "type": "switch",
        "z": "180b7e98628a2a9b",
        "name": "Application ID?",
        "property": "headers.APPLICATION-ID",
        "propertyType": "flow",
        "rules": [
            {
                "t": "empty"
            },
            {
                "t": "nempty"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 1640,
        "y": 220,
        "wires": [
            [
                "8e4e25c458944be3"
            ],
            [
                "efc398fb3570c5de"
            ]
        ]
    },
    {
        "id": "4b020143ef34cf96",
        "type": "ui_toast",
        "z": "180b7e98628a2a9b",
        "position": "dialog",
        "displayTime": "3",
        "highlight": "",
        "sendall": true,
        "outputs": 1,
        "ok": "OK",
        "cancel": "",
        "raw": true,
        "className": "",
        "topic": "",
        "name": "",
        "x": 2010,
        "y": 160,
        "wires": [
            []
        ]
    },
    {
        "id": "8e4e25c458944be3",
        "type": "template",
        "z": "180b7e98628a2a9b",
        "name": "",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "<!DOCTYPE html>\n<html>\n<head>\n<style>\n    a:visited {\n    color: MediumSeaGreen;\n    background-color: transparent;\n    text-decoration: none;\n    }\n</style>\n<title>Spritmonitor</title>\n</head>\n<body>\n\n<h1>Spritmonitor</h1>\n<p>Dieser Flow ruft Daten aus dem Spritmonitor ab und stellt sie im NodeRed Dashboard dar.<br>\nFür diesen Flow und der Verwendung der API benötigen Sie eine Application ID.<br></p>\n\n<p>Weitere Informationen finden Sie <a href=\"https://github.com/FundF/Spritmonitor-API-sample-code\"> auf Github</a></p>\n\n<hr>\n\n<p>This flow retrieves data from Spritmonitor.de and presents the data on the NodeRed Dashboard.<br>\nTo use this flow and the API an application ID is required.<br><p>\n\n<p>For further information see <a href=\"https://github.com/FundF/Spritmonitor-API-sample-code\"> on github</a></p>\n\n</body>\n</html>\n",
        "output": "str",
        "x": 1840,
        "y": 160,
        "wires": [
            [
                "4b020143ef34cf96"
            ]
        ]
    },
    {
        "id": "bdcd72b2f5e2894a",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "An-/Abmelden",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "anmeldung.ok",
                "tot": "flow"
            },
            {
                "t": "change",
                "p": "topic",
                "pt": "msg",
                "from": "true",
                "fromt": "bool",
                "to": "Abmelden",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "topic",
                "pt": "msg",
                "from": "false",
                "fromt": "bool",
                "to": "Anmelden",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 360,
        "y": 200,
        "wires": [
            [
                "46d9c02ff25a9672"
            ]
        ]
    },
    {
        "id": "8bdcf24f059aa5d7",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "Abmeldung erfolgreich",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "",
                "tot": "str"
            },
            {
                "t": "delete",
                "p": "anmeldung.token",
                "pt": "flow"
            },
            {
                "t": "delete",
                "p": "headers.Authorization",
                "pt": "flow"
            },
            {
                "t": "set",
                "p": "anmeldung.ok",
                "pt": "flow",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1300,
        "y": 360,
        "wires": [
            [
                "8d2fc353d3d3e26c"
            ]
        ]
    },
    {
        "id": "8d2fc353d3d3e26c",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "label",
                "pt": "msg",
                "to": "",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2500,
        "y": 360,
        "wires": [
            [
                "492b8f05655a8de9",
                "68ffa627923541cb"
            ]
        ]
    },
    {
        "id": "9e425b8438f6c31d",
        "type": "switch",
        "z": "180b7e98628a2a9b",
        "name": "Anmeldung ok?",
        "property": "anmeldung.ok",
        "propertyType": "flow",
        "rules": [
            {
                "t": "true"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 2000,
        "y": 620,
        "wires": [
            [
                "c616ddb9048f7522"
            ]
        ]
    },
    {
        "id": "1e8841c8aa14b01e",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "[{\"maxkmpos\":\"\",\"name\":\"\"}]",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2050,
        "y": 880,
        "wires": [
            [
                "aa43298e9f36d5a8"
            ]
        ]
    },
    {
        "id": "65231065d3bd4601",
        "type": "switch",
        "z": "180b7e98628a2a9b",
        "name": "Anmeldung OK?",
        "property": "anmeldung.ok",
        "propertyType": "flow",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 240,
        "y": 540,
        "wires": [
            [
                "d203383a2ba8a3cc"
            ],
            [
                "2897ae5dd1095836"
            ]
        ]
    },
    {
        "id": "2897ae5dd1095836",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "options",
                "pt": "msg",
                "to": "[]",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 470,
        "y": 700,
        "wires": [
            [
                "1b52e7b69911c5d2",
                "3b080e41f31ea6e0"
            ]
        ]
    },
    {
        "id": "1b52e7b69911c5d2",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "Fahrzeuge löschen",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"id\":null,\"make\":\"\",\"model\":\"\",\"consumption\":\"\",\"consumptionunit\":\"\",\"tripsum\":\"\",\"tripunit\":\"\",\"quantitysum\":\"\",\"maintank\":null,\"maintanktype\":null,\"sign\":\"\",\"picture_ts\":null,\"bcconsumptionunit\":null,\"country\":\"\",\"rankingInfo\":null}",
                "tot": "json"
            },
            {
                "t": "delete",
                "p": "selectedYear",
                "pt": "flow"
            },
            {
                "t": "delete",
                "p": "fahrzeuge",
                "pt": "flow"
            },
            {
                "t": "delete",
                "p": "carID",
                "pt": "flow"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1270,
        "y": 700,
        "wires": [
            [
                "234af19bb5cebcf5",
                "25c8db05d839b4fd"
            ]
        ]
    },
    {
        "id": "3625c31ff7a1e803",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "Lösche Daten",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "[]",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1560,
        "y": 920,
        "wires": [
            [
                "640b1067b6a9a9a4",
                "1e8841c8aa14b01e"
            ]
        ]
    },
    {
        "id": "c050b79dca4c5aea",
        "type": "switch",
        "z": "180b7e98628a2a9b",
        "name": "Anmeldung ok?",
        "property": "anmeldung.ok",
        "propertyType": "flow",
        "rules": [
            {
                "t": "true"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 780,
        "y": 1200,
        "wires": [
            [
                "41e3bac907528721"
            ]
        ]
    },
    {
        "id": "ec46375d59c72fdf",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "Lösche Auswahl",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1560,
        "y": 980,
        "wires": [
            [
                "1e15ca609622d1b9"
            ]
        ]
    },
    {
        "id": "1e15ca609622d1b9",
        "type": "function",
        "z": "180b7e98628a2a9b",
        "name": "Drop Down initialisieren",
        "func": "const endYear = new Date().getFullYear();\nlet startYear = env.get(\"sinceYear\") || 0;\n\nmsg.options =  [];\n\n// @ts-ignore\nif (startYear === 0) startYear = endYear - 5;\n\n// @ts-ignore\nfor (let i = endYear; i >= startYear ; i--){\n    msg.options.push(i.toString());\n}\nmsg.payload = \"\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 390,
        "y": 1140,
        "wires": [
            [
                "3c380426bd8546c6"
            ]
        ]
    },
    {
        "id": "86208f75ce87a04a",
        "type": "inject",
        "z": "180b7e98628a2a9b",
        "name": "Init",
        "props": [
            {
                "p": "init",
                "v": "true",
                "vt": "bool"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "x": 130,
        "y": 1140,
        "wires": [
            [
                "1e15ca609622d1b9"
            ]
        ]
    },
    {
        "id": "e0a4cf23c70d02b9",
        "type": "inject",
        "z": "180b7e98628a2a9b",
        "name": "trigger",
        "props": [
            {
                "p": "trigger",
                "v": "true",
                "vt": "bool"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 1210,
        "y": 960,
        "wires": [
            [
                "25c8db05d839b4fd"
            ]
        ]
    },
    {
        "id": "a230df6cc2627964",
        "type": "inject",
        "z": "180b7e98628a2a9b",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[]",
        "payloadType": "json",
        "x": 2090,
        "y": 940,
        "wires": [
            [
                "8d5ec8b688d4a841"
            ]
        ]
    },
    {
        "id": "1cea91c8e0030670",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "betankungen",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2030,
        "y": 980,
        "wires": [
            [
                "8d5ec8b688d4a841"
            ]
        ]
    },
    {
        "id": "8d5ec8b688d4a841",
        "type": "switch",
        "z": "180b7e98628a2a9b",
        "name": "is array?",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "istype",
                "v": "array",
                "vt": "array"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 2240,
        "y": 980,
        "wires": [
            [
                "30b5f9d67cf96bc3"
            ]
        ]
    },
    {
        "id": "30b5f9d67cf96bc3",
        "type": "switch",
        "z": "180b7e98628a2a9b",
        "name": "Anzahl Elemente?",
        "property": "$count(payload)",
        "propertyType": "jsonata",
        "rules": [
            {
                "t": "eq",
                "v": "0",
                "vt": "num"
            },
            {
                "t": "gt",
                "v": "0",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 2430,
        "y": 980,
        "wires": [
            [
                "609035d95cb72154"
            ],
            [
                "df3089c81d8b625a"
            ]
        ]
    },
    {
        "id": "609035d95cb72154",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2650,
        "y": 960,
        "wires": [
            [
                "219aced3395fba74"
            ]
        ]
    },
    {
        "id": "df3089c81d8b625a",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "\"(\" & $count(payload) & \" Betankungen)\"",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2650,
        "y": 1000,
        "wires": [
            [
                "219aced3395fba74"
            ]
        ]
    },
    {
        "id": "e0ca375bca5e4511",
        "type": "switch",
        "z": "180b7e98628a2a9b",
        "name": "",
        "property": "options",
        "propertyType": "msg",
        "rules": [
            {
                "t": "istype",
                "v": "object",
                "vt": "object"
            },
            {
                "t": "istype",
                "v": "array",
                "vt": "array"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 650,
        "y": 560,
        "wires": [
            [
                "dd37e67e1346d7f6"
            ],
            [
                "3b080e41f31ea6e0"
            ]
        ]
    },
    {
        "id": "dd37e67e1346d7f6",
        "type": "change",
        "z": "180b7e98628a2a9b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "options",
                "pt": "msg",
                "to": "[options]",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 830,
        "y": 520,
        "wires": [
            [
                "3b080e41f31ea6e0"
            ]
        ]
    },
    {
        "id": "e3666278fb9f3db1",
        "type": "ui_group",
        "name": "Anmelden",
        "tab": "895187d1da3bdc76",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "9b626ac5e26ef90a",
        "type": "ui_group",
        "name": "Aktives Fahrzeug",
        "tab": "895187d1da3bdc76",
        "order": 2,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "047787a3340d50f2",
        "type": "ui_group",
        "name": "Betankungen",
        "tab": "895187d1da3bdc76",
        "order": 3,
        "disp": true,
        "width": "12",
        "collapse": false,
        "className": ""
    },
    {
        "id": "895187d1da3bdc76",
        "type": "ui_tab",
        "name": "Spritmonitor",
        "icon": "dashboard",
        "order": 7,
        "disabled": false,
        "hidden": false
    }
]