KNX + Node-Red - Part 2: Telegram-Integration

Mit ** gekennzeichnete Links auf dieser Seite sind Affiliatelinks.

KNX + Node-Red - Part 2: Telegram-Integration
KNX + Node-Red - Part 2: Telegram-Integration
  • Matthias Kleine
  • 29.04.2021
  • Grundlagen

Nachdem nun im ersten Teil alles vorbereitet und installiert wurde, widmen wir uns gemeinsam den nächsten Punkten. Pushover ist zwar schön und gut, aber eben nur “in eine Richtung”. Das heißt, wir haben keine Möglichkeit zu antworten oder etwas zu steuern. Das ist bei Telegram anders. Mit Telegram kann man relativ einfach eine neue Schnittstelle von außen ins Haus anbieten, welche leicht zu sichern ist. Ohne VPN und andere Themen. Außerdem kann man Bilder versenden und per Text-Nachrichten eben Aktionen anstoßen. Alles kein Problem!

In diesem Teil möchte ich gerne das aktuelle Kamera-Bild von der Mobotix-Kamera an der Haustür abholen und dann in den Gruppenchat senden. So sehe ich auch unterwegs, wer eigentlich gerade vor der Tür steht. Eigentlich ganz einfach, wenn man weiß, wie die Objekte aufgebaut werden müssen. Ich gebe Dir also auf dem Weg zum gesteckten Ziel einige Tipps mit auf den Weg, wie man generell mit NodeRed arbeitet.

Was wird benötigt?

  • Einen Raspberry Pi mit Raspberry Pi OS
  • Eine laufende KNX-Installation
  • Ein KNX IP-Interface (oder IP-Router)

Video

Node-Red-Kurs

Flows

Teil 1

[
  {
    "id": "369a07f9.32b658",
    "type": "tab",
    "label": "Haustür",
    "disabled": false,
    "info": ""
  },
  {
    "id": "2d4b7c82.440c64",
    "type": "knxEasy-in",
    "z": "369a07f9.32b658",
    "server": "7729e5a3.9a714c",
    "topic": "3/1/0",
    "dpt": "1.001",
    "initialread": false,
    "notifyreadrequest": false,
    "notifyresponse": false,
    "notifywrite": true,
    "name": "Haustür (Klingeltaster)",
    "x": 180,
    "y": 120,
    "wires": [
      [
        "2c9be674.35d2f2"
      ]
    ]
  },
  {
    "id": "59f3de43.25f6a8",
    "type": "pushover",
    "z": "369a07f9.32b658",
    "name": "",
    "device": "",
    "title": "Haustür",
    "priority": 0,
    "sound": "incoming",
    "url": "",
    "url_title": "",
    "html": false,
    "x": 1180,
    "y": 120,
    "wires": []
  },
  {
    "id": "2c9be674.35d2f2",
    "type": "switch",
    "z": "369a07f9.32b658",
    "name": "",
    "property": "payload",
    "propertyType": "msg",
    "rules": [
      {
        "t": "true"
      },
      {
        "t": "false"
      }
    ],
    "checkall": "true",
    "repair": false,
    "outputs": 2,
    "x": 470,
    "y": 120,
    "wires": [
      [
        "dc8cd98f.423aa"
      ],
      []
    ]
  },
  {
    "id": "dc8cd98f.423aa",
    "type": "change",
    "z": "369a07f9.32b658",
    "name": "",
    "rules": [
      {
        "t": "set",
        "p": "payload",
        "pt": "msg",
        "to": "Es hat an der Haustür geklingelt!",
        "tot": "str"
      }
    ],
    "action": "",
    "property": "",
    "from": "",
    "to": "",
    "reg": false,
    "x": 760,
    "y": 120,
    "wires": [
      [
        "59f3de43.25f6a8",
        "4cbb0817.3f47f8"
      ]
    ]
  },
  {
    "id": "ebfa7ab8.7f9b18",
    "type": "comment",
    "z": "369a07f9.32b658",
    "name": "Push bei Klingeln",
    "info": "",
    "x": 160,
    "y": 80,
    "wires": []
  },
  {
    "id": "2191fca1.d2f354",
    "type": "knxEasy-in",
    "z": "369a07f9.32b658",
    "server": "7729e5a3.9a714c",
    "topic": "3/1/1",
    "dpt": "1.001",
    "initialread": false,
    "notifyreadrequest": false,
    "notifyresponse": false,
    "notifywrite": true,
    "name": "Haustür (Briefkastenklappe)",
    "x": 200,
    "y": 240,
    "wires": [
      [
        "cbe885c9.ce93f8"
      ]
    ]
  },
  {
    "id": "cbe885c9.ce93f8",
    "type": "switch",
    "z": "369a07f9.32b658",
    "name": "",
    "property": "payload",
    "propertyType": "msg",
    "rules": [
      {
        "t": "true"
      },
      {
        "t": "false"
      }
    ],
    "checkall": "true",
    "repair": false,
    "outputs": 2,
    "x": 470,
    "y": 240,
    "wires": [
      [
        "b52d44fe.7047e8"
      ],
      []
    ]
  },
  {
    "id": "b52d44fe.7047e8",
    "type": "change",
    "z": "369a07f9.32b658",
    "name": "",
    "rules": [
      {
        "t": "set",
        "p": "payload",
        "pt": "msg",
        "to": "Die Post ist da!",
        "tot": "str"
      }
    ],
    "action": "",
    "property": "",
    "from": "",
    "to": "",
    "reg": false,
    "x": 760,
    "y": 240,
    "wires": [
      [
        "4cbb0817.3f47f8"
      ]
    ]
  },
  {
    "id": "812fced4.bde6",
    "type": "telegram sender",
    "z": "369a07f9.32b658",
    "name": "",
    "bot": "d312c643.b1262",
    "haserroroutput": false,
    "outputs": 1,
    "x": 1160,
    "y": 180,
    "wires": [
      []
    ]
  },
  {
    "id": "4cbb0817.3f47f8",
    "type": "function",
    "z": "369a07f9.32b658",
    "name": "",
    "func": "msg.payload = {\n    \"chatId\": -516453460,\n    \"type\": \"message\",\n    \"content\": msg.payload\n};\n\nreturn msg;",
    "outputs": 1,
    "noerr": 0,
    "initialize": "",
    "finalize": "",
    "libs": [],
    "x": 980,
    "y": 180,
    "wires": [
      [
        "812fced4.bde6"
      ]
    ]
  },
  {
    "id": "7729e5a3.9a714c",
    "type": "knxEasy-config",
    "host": "172.16.0.157",
    "port": "3671"
  },
  {
    "id": "d312c643.b1262",
    "type": "telegram bot",
    "botname": "KNXYouTubeBot",
    "usernames": "",
    "chatids": "-516453460",
    "baseapiurl": "",
    "updatemode": "polling",
    "pollinterval": "300",
    "usesocks": false,
    "sockshost": "",
    "socksport": "6667",
    "socksusername": "anonymous",
    "sockspassword": "",
    "bothost": "",
    "botpath": "",
    "localbotport": "8443",
    "publicbotport": "8443",
    "privatekey": "",
    "certificate": "",
    "useselfsignedcertificate": false,
    "sslterminated": false,
    "verboselogging": false
  }
]

Teil 2

[
    {
        "id": "3000e92b.c4c9c6",
        "type": "subflow",
        "name": "Kamerabild per Telegram",
        "info": "",
        "category": "",
        "in": [
            {
                "x": 40,
                "y": 80,
                "wires": [
                    {
                        "id": "f8bbd532.b0f758"
                    }
                ]
            }
        ],
        "out": [],
        "env": [],
        "meta": {},
        "color": "#DDAA99"
    },
    {
        "id": "f8bbd532.b0f758",
        "type": "http request",
        "z": "3000e92b.c4c9c6",
        "name": "Kamerabild",
        "method": "GET",
        "ret": "bin",
        "paytoqs": "ignore",
        "url": "http://172.16.0.238/record/current.jpg",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "x": 170,
        "y": 80,
        "wires": [
            [
                "8249ce3d.568428"
            ]
        ]
    },
    {
        "id": "8249ce3d.568428",
        "type": "file",
        "z": "3000e92b.c4c9c6",
        "name": "",
        "filename": "/home/pi/haustuer.jpg",
        "appendNewline": false,
        "createDir": false,
        "overwriteFile": "true",
        "encoding": "none",
        "x": 380,
        "y": 80,
        "wires": [
            [
                "423442fd.bb72a4"
            ]
        ]
    },
    {
        "id": "423442fd.bb72a4",
        "type": "function",
        "z": "3000e92b.c4c9c6",
        "name": "",
        "func": "msg.payload = {\n    \"chatId\": -516453460,\n    \"type\": \"photo\",\n    \"content\": \"/home/pi/haustuer.jpg\",\n    \"caption\": \"Haustür\"\n};\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 580,
        "y": 80,
        "wires": [
            [
                "dce7ca25.435398"
            ]
        ]
    },
    {
        "id": "dce7ca25.435398",
        "type": "telegram sender",
        "z": "3000e92b.c4c9c6",
        "name": "",
        "bot": "d312c643.b1262",
        "haserroroutput": false,
        "outputs": 1,
        "x": 760,
        "y": 80,
        "wires": [
            []
        ]
    },
    {
        "id": "369a07f9.32b658",
        "type": "tab",
        "label": "Haustür",
        "disabled": false,
        "info": ""
    },
    {
        "id": "59f3de43.25f6a8",
        "type": "pushover",
        "z": "369a07f9.32b658",
        "name": "",
        "device": "",
        "title": "Haustür",
        "priority": 0,
        "sound": "incoming",
        "url": "",
        "url_title": "",
        "html": false,
        "x": 1180,
        "y": 160,
        "wires": []
    },
    {
        "id": "2c9be674.35d2f2",
        "type": "switch",
        "z": "369a07f9.32b658",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 470,
        "y": 160,
        "wires": [
            [
                "dc8cd98f.423aa",
                "1574573d.948e11",
                "b08b7f4c.4fc1e"
            ],
            []
        ]
    },
    {
        "id": "dc8cd98f.423aa",
        "type": "change",
        "z": "369a07f9.32b658",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "Es hat an der Haustür geklingelt!",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 760,
        "y": 160,
        "wires": [
            [
                "59f3de43.25f6a8",
                "4cbb0817.3f47f8"
            ]
        ]
    },
    {
        "id": "ebfa7ab8.7f9b18",
        "type": "comment",
        "z": "369a07f9.32b658",
        "name": "Push bei Klingeln",
        "info": "",
        "x": 160,
        "y": 120,
        "wires": []
    },
    {
        "id": "2191fca1.d2f354",
        "type": "knxEasy-in",
        "z": "369a07f9.32b658",
        "server": "7729e5a3.9a714c",
        "topic": "3/1/1",
        "dpt": "1.001",
        "initialread": false,
        "notifyreadrequest": false,
        "notifyresponse": false,
        "notifywrite": true,
        "name": "Haustür (Briefkastenklappe)",
        "x": 200,
        "y": 280,
        "wires": [
            [
                "cbe885c9.ce93f8"
            ]
        ]
    },
    {
        "id": "cbe885c9.ce93f8",
        "type": "switch",
        "z": "369a07f9.32b658",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 470,
        "y": 280,
        "wires": [
            [
                "b52d44fe.7047e8"
            ],
            []
        ]
    },
    {
        "id": "b52d44fe.7047e8",
        "type": "change",
        "z": "369a07f9.32b658",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "Die Post ist da!",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 760,
        "y": 280,
        "wires": [
            [
                "4cbb0817.3f47f8"
            ]
        ]
    },
    {
        "id": "812fced4.bde6",
        "type": "telegram sender",
        "z": "369a07f9.32b658",
        "name": "",
        "bot": "d312c643.b1262",
        "haserroroutput": false,
        "outputs": 1,
        "x": 1160,
        "y": 220,
        "wires": [
            []
        ]
    },
    {
        "id": "4cbb0817.3f47f8",
        "type": "function",
        "z": "369a07f9.32b658",
        "name": "",
        "func": "msg.payload = {\n    \"chatId\": -516453460,\n    \"type\": \"message\",\n    \"content\": msg.payload\n};\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 980,
        "y": 220,
        "wires": [
            [
                "812fced4.bde6"
            ]
        ]
    },
    {
        "id": "e74ae03f.e0b69",
        "type": "knxEasy-in",
        "z": "369a07f9.32b658",
        "server": "7729e5a3.9a714c",
        "topic": "3/1/0",
        "dpt": "1.001",
        "initialread": false,
        "notifyreadrequest": false,
        "notifyresponse": false,
        "notifywrite": true,
        "name": "Haustür (Klingeltaster)",
        "x": 180,
        "y": 160,
        "wires": [
            [
                "2c9be674.35d2f2"
            ]
        ]
    },
    {
        "id": "1574573d.948e11",
        "type": "subflow:3000e92b.c4c9c6",
        "z": "369a07f9.32b658",
        "x": 790,
        "y": 60,
        "wires": []
    },
    {
        "id": "b08b7f4c.4fc1e",
        "type": "delay",
        "z": "369a07f9.32b658",
        "name": "",
        "pauseType": "delay",
        "timeout": "3",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 740,
        "y": 100,
        "wires": [
            [
                "4939c29f.ebb804"
            ]
        ]
    },
    {
        "id": "4939c29f.ebb804",
        "type": "subflow:3000e92b.c4c9c6",
        "z": "369a07f9.32b658",
        "name": "",
        "x": 950,
        "y": 100,
        "wires": []
    },
    {
        "id": "7729e5a3.9a714c",
        "type": "knxEasy-config",
        "host": "172.16.0.157",
        "port": "3671"
    },
    {
        "id": "d312c643.b1262",
        "type": "telegram bot",
        "botname": "KNXYouTubeBot",
        "usernames": "",
        "chatids": "-516453460",
        "baseapiurl": "",
        "updatemode": "polling",
        "pollinterval": "300",
        "usesocks": false,
        "sockshost": "",
        "socksport": "6667",
        "socksusername": "anonymous",
        "sockspassword": "",
        "bothost": "",
        "botpath": "",
        "localbotport": "8443",
        "publicbotport": "8443",
        "privatekey": "",
        "certificate": "",
        "useselfsignedcertificate": false,
        "sslterminated": false,
        "verboselogging": false
    }
]

Produkte

Hier findest Du die letzten beiden Generationen des Raspberry. Darunter findest Du das passende Gehäuse und SD-Karten.

Raspberry Pi 4 Modell B, 2-GB-Kit **

Raspberry Pi 4 Modell B, 2-GB-Kit

Raspberry 1373331 Pi 3 Modell B+ Mainboard, 1GB **

Raspberry 1373331 Pi 3 Modell B+ Mainboard, 1GB

SanDisk Ultra 32GB microSDHC Speicherkarte + Adapter bis zu 98 MB/Sek., Class 10, U1, A1, FFP **

SanDisk Ultra 32GB microSDHC Speicherkarte + Adapter bis zu 98 MB/Sek., Class 10, U1, A1, FFP

Rydges SpeedPower PC Netzteil 5V 2,5A / 2500 mAh Ladegerät für Raspberry Pi Modell A und B & Banana Pi - Pi Model B+ (B Plus) und Pi 2 Model B/Pi Xero und Pi 3 (Modell 03/2016) **

Rydges SpeedPower PC Netzteil 5V 2,5A / 2500 mAh Ladegerät für Raspberry Pi Modell A und B & Banana Pi - Pi Model B+ (B Plus) und Pi 2 Model B/Pi Xero und Pi 3 (Modell 03/2016)

Bei einem Netzteil für den Raspberry sollte unbedingt darauf geachtet werden, dass es mindestens 2500mA (2,5A) liefern kann! Andernfalls kann es zu seltsamen Seiteneffekten kommen, wodurch der Raspberry langsam wird, abstürzt oder plötzlich gar nicht mehr startet. Die erforderliche Leistung wird umso höher, desto mehr USB-Geräte angeschlossen werden. Daher sollte am Netzteil auf keinen Fall gespart werden!

Ich will mehr

Smart-Home-Training von A-Z

Steig noch tiefer in die Themen ein und meistere Deine Projekte!

ioBroker-Master-Kurs

ioBroker-Master-Kurs

Mehr Infos
Hausbau-Kurs

Hausbau mit KNX

Mehr Infos
Lox-Kurs

Lox-Kurs

Mehr Infos
NodeRed-Kurs

NodeRed-Kurs

Mehr Infos