Benzin Preise per NodeRED ermitteln und in Echtzeit grafisch darstellen mit dem Raspberry Pi (محطة بنزين)

Erstellt am 28. Mai 2017 von It_berater

Tankstellen melden ihre Spritpreise ins Internet. Von dort können sie leicht abgerufen werden. Zum Beispiel die Benzinpreise von Langenhagen. Die Seite hat auch eine öffentliche kostenlose API. Dort kann man nach Anmeldung bis zu 3 Tankstellen kostenlos abfragen.

Ok, dann mal los, hier die Architektur:

So kann man sich dann vor dem tanken informieren und den billigen Sprit tanken:

In NodeRED erzeugt man diesen Flow:

Es wird von dem Anbieter eine JSon Datei geliefert, mit folgenden Aufbau:

Es wird dann jede Stunde der aktuelle Wert abgefragt und für die Grafik an Thingspeak gesendet:

Über einen Gui-Button kann man die Abfrage auch jederzeit auslösen. Hier wird der Preis oben links angezeigt:

Hier der von mir erstellte Flow für eigene Experimente zum kopieren:

[
    {
        "id": "3841143c.a8e13c",
        "type": "http request",
        "z": "8bbc7a94.ee94e8",
        "name": "Superpreise für Langenhagen abfragen",
        "method": "GET",
        "ret": "obj",
        "url": "https://www.benzinpreis-aktuell.de/api2/fetch.php?key=KEY-EINFUEGEN",
        "tls": "",
        "x": 220,
        "y": 200,
        "wires": [
            [
                "a5e77532.4ed78",
                "b12e99ed.63bad8"
            ]
        ]
    },
    {
        "id": "b64bcec9.890e2",
        "type": "debug",
        "z": "8bbc7a94.ee94e8",
        "name": "",
        "active": true,
        "console": "false",
        "complete": "false",
        "x": 650,
        "y": 340,
        "wires": []
    },
    {
        "id": "a5e77532.4ed78",
        "type": "contrib-json",
        "z": "8bbc7a94.ee94e8",
        "engine": "JSONPath",
        "command": "jq",
        "expr": "$.stations.0.price_super",
        "complete": "property",
        "prop": "payload",
        "name": "Shell Bothfelder Str. 15",
        "x": 210,
        "y": 280,
        "wires": [
            [
                "b64bcec9.890e2",
                "ed76c1e.0a7794",
                "9fc64464.bbdcb"
            ]
        ]
    },
    {
        "id": "b12e99ed.63bad8",
        "type": "contrib-json",
        "z": "8bbc7a94.ee94e8",
        "engine": "JSONPath",
        "command": "jq",
        "expr": "$.stations.1.price_super",
        "complete": "property",
        "prop": "payload",
        "name": "Hoyer Am Kreisel bei Mc Donalds",
        "x": 240,
        "y": 420,
        "wires": [
            [
                "b64bcec9.890e2",
                "cd27d62d.41ef48",
                "fc2bb2d.e4e8fd"
            ]
        ]
    },
    {
        "id": "ed76c1e.0a7794",
        "type": "ThingspeakSendSimple",
        "z": "8bbc7a94.ee94e8",
        "name": "An Thingspeak Kanal 1 senden",
        "writekey": "SCHREIB-KEY",
        "fieldid": "1",
        "x": 310,
        "y": 340,
        "wires": []
    },
    {
        "id": "ab52c557.c4ba8",
        "type": "comment",
        "z": "8bbc7a94.ee94e8",
        "name": "www.wenzlaff.info",
        "info": "",
        "x": 790,
        "y": 80,
        "wires": []
    },
    {
        "id": "737c9c4a.56450c",
        "type": "comment",
        "z": "8bbc7a94.ee94e8",
        "name": "Ermittelt die Super-Benzin Preise in Langenhagen und sendet sie an Thingspeak",
        "info": "https://www.benzinpreis-aktuell.de/benzinpreise-langenhagen-heute",
        "x": 320,
        "y": 80,
        "wires": []
    },
    {
        "id": "d71c9200.4ecc",
        "type": "inject",
        "z": "8bbc7a94.ee94e8",
        "name": "Jede Stunde",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "3600",
        "crontab": "",
        "once": false,
        "x": 140,
        "y": 120,
        "wires": [
            [
                "3841143c.a8e13c"
            ]
        ]
    },
    {
        "id": "cd27d62d.41ef48",
        "type": "delay",
        "z": "8bbc7a94.ee94e8",
        "name": "Warte 2 Minute",
        "pauseType": "delay",
        "timeout": "2",
        "timeoutUnits": "minutes",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 200,
        "y": 480,
        "wires": [
            [
                "cf4b7c99.f23e"
            ]
        ]
    },
    {
        "id": "cf4b7c99.f23e",
        "type": "ThingspeakSendSimple",
        "z": "8bbc7a94.ee94e8",
        "name": "An Thingspeak Kanal 2 senden",
        "writekey": "SCHREIB-KEY",
        "fieldid": "2",
        "x": 310,
        "y": 560,
        "wires": []
    },
    {
        "id": "8946d715.3895d",
        "type": "ui_button",
        "z": "8bbc7a94.ee94e8",
        "name": "",
        "group": "c18727d3.1b7608",
        "order": 7,
        "width": 0,
        "height": 0,
        "label": "Tankstellen Preise Abfrage",
        "color": "",
        "bgcolor": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "",
        "x": 400,
        "y": 120,
        "wires": [
            [
                "3841143c.a8e13c"
            ]
        ]
    },
    {
        "id": "9fc64464.bbdcb",
        "type": "template",
        "z": "8bbc7a94.ee94e8",
        "name": "Format",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "Shell Bothfeld: {{payload}} Euro\n",
        "x": 640,
        "y": 280,
        "wires": [
            [
                "e1934597.0af95"
            ]
        ]
    },
    {
        "id": "e1934597.0af95",
        "type": "ui_toast",
        "z": "8bbc7a94.ee94e8",
        "position": "top right",
        "displayTime": "10",
        "outputs": 0,
        "ok": "OK",
        "cancel": "",
        "topic": "",
        "name": "Ergebnis Dialog",
        "x": 800,
        "y": 280,
        "wires": []
    },
    {
        "id": "d53e5bcb.204348",
        "type": "template",
        "z": "8bbc7a94.ee94e8",
        "name": "Format",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "Hoyer Am Kreisel: {{payload}} Euro\n",
        "x": 640,
        "y": 480,
        "wires": [
            [
                "7280a9f4.7b75a"
            ]
        ]
    },
    {
        "id": "7280a9f4.7b75a",
        "type": "ui_toast",
        "z": "8bbc7a94.ee94e8",
        "position": "top right",
        "displayTime": "30",
        "outputs": 0,
        "ok": "OK",
        "cancel": "",
        "topic": "",
        "name": "Ergebnis Dialog",
        "x": 800,
        "y": 480,
        "wires": []
    },
    {
        "id": "fc2bb2d.e4e8fd",
        "type": "delay",
        "z": "8bbc7a94.ee94e8",
        "name": "Warte 10 Sekunden",
        "pauseType": "delay",
        "timeout": "10",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 470,
        "y": 480,
        "wires": [
            [
                "d53e5bcb.204348"
            ]
        ]
    },
    {
        "id": "c18727d3.1b7608",
        "type": "ui_group",
        "z": "",
        "name": "wenzlaff.info",
        "tab": "a9e39ea1.b18f3",
        "disp": false,
        "width": "6"
    },
    {
        "id": "a9e39ea1.b18f3",
        "type": "ui_tab",
        "z": "",
        "name": "wenzlaff.info",
        "icon": "dashboard"
    }
]

Ähnliche Artikel:

  1. Feinstaub (Particulate Matter, Pył ) Messung mit dem Raspberry Pi aus einer JSON Datei und NodeRED – Teil 1
  2. Überwachung: Automatischer Ping an Server mit NodeRED auf Raspberry Pi (مراقبة)
  3. Wie kann eine Pushover Nachricht mit dem aktuellen Wetter von OpenWether jeden Tag mit Node-Red und Raspberry Pi an das Handy und Tablet versandt werden?