{"id":4410,"date":"2019-09-09T21:25:41","date_gmt":"2019-09-09T20:25:41","guid":{"rendered":"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/?p=4410"},"modified":"2021-02-22T14:14:04","modified_gmt":"2021-02-22T13:14:04","slug":"homematic-nachrichten-pushen-mit-telegram","status":"publish","type":"post","link":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/2019\/09\/09\/homematic-nachrichten-pushen-mit-telegram\/","title":{"rendered":"Homematic Nachrichten pushen mit Telegram"},"content":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_4410\" class=\"pvc_stats all  \" data-element-id=\"4410\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p style=\"text-align: justify\">Mit der Homematic CCU ist es ja schon lange m\u00f6glich, Nachrichten aus Systemereignissen heraus zu generieren und per E-Mail zu versenden. Ein einfaches Beispiel hierf\u00fcr ist die Best\u00e4tigung der Alarmanlage. Wird diese scharf oder unscharf geschaltet, so kann der Status als Email versendet werden. Oder hat man Umweltdatensensoren verbaut, so kann man sich auch die Daten, wie Temperatur, Luftfeuchte etc. senden lassen. Dazu muss einfach nur das Email-Plug-In unter Zusatzsoftware installiert und eingerichtet werden. Die Nachrichten werden dann per Script Aufruf versendet. Jedes Mal, wenn der Ziel-Email-Client, zum Beispiel am Smartphone, die Nachrichten abruft, ist man wieder informiert.<\/p>\n<p style=\"text-align: justify\">Es muss aber nicht unbedingt die E-Mail-L\u00f6sung sein um Nachrichten zu versenden. Eine weitere M\u00f6glichkeit ist der Messenger &#8222;Telegram&#8220;. Er ist den Nachrichten Messengern WhatsApp, Signal, etc. \u00e4hnlich und versendet per Push-Service. Der Versand unterschiedlichster Daten ist hier m\u00f6glich. Bilder, Videos und Audiodateien k\u00f6nnen genau so einfach wie Textnachrichten versendet werden. Um einen den Telegram Dienst mit der Homematic nutzen zu k\u00f6nnen, muss man sich der freien Telegram API bedienen. In den folgenden Zeilen zeige ich, wie ich ein f\u00fcr mich funktionsf\u00e4higes System aufgebaut habe, um von der Homematic CCU Nachrichten und IPCam-Bilder an ein Smartphone mit installiertem Telegram Messenger zu senden.<\/p>\n<p style=\"text-align: justify\">In dem Beispiel beschreibe ich die Installation und Einrichtung auf einem Android System. Beginnend mit dem Download der APP &#8222;Telegram Messenger&#8220; aus dem Google Appstore kann derselbe dann installiert und gestartet werden. Nach dem registrieren der Telefonnummer sollte die Software dann auch schon bereit sein.<\/p>\n<h6>Einrichten des Bots:<\/h6>\n<p style=\"text-align: justify\">In der rechten, oberen Ecke des Bildschirms ist das Lupensymbol f\u00fcr die Suche zu sehen. Das ist anzuw\u00e4hlen, um ein Eingabefeld zu erhalten. In dieses Feld ist nun <em><strong>BotFather<\/strong><\/em> einzugeben. Das ist quasi das Administrationstool f\u00fcr das Erstellen und Einrichten von Bots. <em>Unter einem <b>Bot<\/b> (von englisch <span lang=\"en-Latn\">robot<\/span> \u201aRoboter\u2018) versteht man ein Computerprogramm, das weitgehend automatisch sich wiederholende Aufgaben abarbeitet, ohne dabei auf eine Interaktion mit einem menschlichen Benutzer angewiesen zu sein.( Quelle: Wikipedia)<\/em><\/p>\n<div id=\"attachment_4416\" style=\"width: 325px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/Screenshot_20190809_114454_org.telegram.messenger.jpg\"><img fetchpriority=\"high\" decoding=\"async\" aria-describedby=\"caption-attachment-4416\" class=\"wp-image-4416 \" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/Screenshot_20190809_114454_org.telegram.messenger-169x300.jpg\" alt=\"\" width=\"315\" height=\"559\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/Screenshot_20190809_114454_org.telegram.messenger-169x300.jpg 169w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/Screenshot_20190809_114454_org.telegram.messenger-576x1024.jpg 576w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/Screenshot_20190809_114454_org.telegram.messenger.jpg 720w\" sizes=\"(max-width: 315px) 100vw, 315px\" \/><\/a><p id=\"caption-attachment-4416\" class=\"wp-caption-text\">Suchen des BotFather<\/p><\/div>\n<p style=\"text-align: justify\">Ist der BotFather gefunden, dann kann der einfach angeklickt werden und es \u00f6ffnet sich ein Fenster.&nbsp; Um die Einrichtung des eigenen Bots zu starten, ist in der Nachrichtenzeile folgendes Kommando einzutippen:<\/p>\n<p><strong>\/start<\/strong><\/p>\n<p style=\"text-align: justify\">Jetzt kommt als Antwort eine Liste mit Befehlen, die f\u00fcr die Bot-Einrichtung und Konfiguration n\u00fctzlich sind. Um nun einen neuen Bot zu erstellen ist<\/p>\n<p><strong>\/newbot<\/strong><\/p>\n<p style=\"text-align: justify\">einzugeben. Als n\u00e4chstes ist ein Name f\u00fcr den Bot auszuw\u00e4hlen. Hier habe ich als Beispiel <strong>CCU <\/strong>gew\u00e4hlt. Sollte der Name bereits vergeben sein, dann einen anderen w\u00e4hlen. Das gilt ebenso f\u00fcr den Benutzernamen, der mit &#8222;_bot&#8220; zu enden hat. Hier habe ich <strong>iretro_bot<\/strong> gew\u00e4hlt.<\/p>\n<p><a href=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/Screenshot_20190809_115951_org.telegram.messenger.jpg\"><img decoding=\"async\" class=\"aligncenter wp-image-4427\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/Screenshot_20190809_115951_org.telegram.messenger-201x300.jpg\" alt=\"\" width=\"315\" height=\"470\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/Screenshot_20190809_115951_org.telegram.messenger-201x300.jpg 201w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/Screenshot_20190809_115951_org.telegram.messenger-685x1024.jpg 685w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/Screenshot_20190809_115951_org.telegram.messenger.jpg 718w\" sizes=\"(max-width: 315px) 100vw, 315px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">Ist der Name gew\u00e4hlt und g\u00fcltig, so kommt als Antwort eine Meldung mit einem Token, der in der Regel 45 Zeichen lang ist. Dieser Token ist zu kopieren oder abzuschreiben. Er ist der Schl\u00fcssel f\u00fcr den Bot. Die Arbeiten am Smartphone sind nun soweit abgeschlossen und es geht am PC weiter. Im Browser (am besten Firefox) ist die Telegram Website aufzurufen. <a href=\"https:\/\/web.telegram.org\">web.telegram.org <\/a>ist der Link zu Website. Diese Schritte dienen dazu, neben dem Token auch noch die ChatID zu erhalten, die in weiterer Folge in den Homematic Skripten ben\u00f6tigt wird. Um sich im Webbrowser anmelden zu k\u00f6nnen, ist die zu Anfang in der App registrierte Telefonnummer einzugeben. Ist die Nummer eingegeben wird auf das Smartphone ein Anmeldecode gesendet. Mit dem kann die Telegram Session im Browser gestartet werden. Jetzt sollte im Browser Telegram auch der<em><strong> iretro_bot<\/strong><\/em> per Suche zu finden sein. Ist er gefunden, dann ist er mit &#8222;<strong>STARTEN<\/strong>&#8220; zu \u00f6ffnen und irgendeine beliebige Nachricht einzugeben. Das Eingeben einer beliebigen Nachricht ist wichtig um dann auch die ChatID erhalten zu k\u00f6nnen. Ist das geschehen, dann ist in der Adresszeile desselben Browserfensters der folgende Link einzugeben:<\/p>\n<p>https:\/\/api.telegram.org\/bot<strong><em>hier_den_45_Zeichen_langen_APItoken_eingeben<\/em><\/strong>\/getUpdates<\/p>\n<p style=\"text-align: justify\">und mit Enter best\u00e4tigen. Jetzt sollte im Browser in etwa folgendes zu sehen sein: (Tab JSON ausgew\u00e4hlt) Den Inhalt der Website habe ich in die untenstehende Tabelle kopiert. (die originale ID wurde nat\u00fcrlich ge\u00e4ndert&#8230;)<\/p>\n<table class=\"treeTable\" style=\"width: 0%;height: 466px\" role=\"tree\" aria-label=\"\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody role=\"presentation\">\n<tr id=\"\/ok\" class=\"treeRow booleanRow opened selected\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"height: 18px;width: 89.9833px\" role=\"presentation\"><span class=\"treeLabel booleanLabel\" aria-labelledby=\"default\" data-level=\"0\">ok<\/span><\/td>\n<td class=\"treeValueCell booleanCell\" style=\"height: 18px;width: 90.9333px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-number\">true<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\" class=\"treeRow objectRow hasChildren opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"height: 18px;width: 89.9833px\" role=\"presentation\"><span class=\"treeLabel objectLabel\" aria-labelledby=\"default\" data-level=\"0\">result<\/span><\/td>\n<td class=\"treeValueCell objectCell\" style=\"height: 18px;width: 90.9333px\" role=\"presentation\">0<\/td>\n<\/tr>\n<tr id=\"\/result\/0\/update_id\" class=\"treeRow numberRow opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel numberLabel\" aria-labelledby=\"default\" data-level=\"2\">update_id<\/span><\/td>\n<td class=\"treeValueCell numberCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-number\">121212121<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/0\/message\" class=\"treeRow objectRow hasChildren opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel objectLabel\" aria-labelledby=\"default\" data-level=\"2\">message<\/span><\/td>\n<td class=\"treeValueCell objectCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\">&nbsp;<\/td>\n<\/tr>\n<tr id=\"\/result\/0\/message\/message_id\" class=\"treeRow numberRow opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel numberLabel\" aria-labelledby=\"default\" data-level=\"3\">message_id<\/span><\/td>\n<td class=\"treeValueCell numberCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-number\">106<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/0\/message\/from\" class=\"treeRow objectRow hasChildren opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel objectLabel\" aria-labelledby=\"default\" data-level=\"3\">from id<br \/>\n<\/span><\/td>\n<td class=\"treeValueCell objectCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-number\">123456789<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/0\/message\/from\/is_bot\" class=\"treeRow booleanRow opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel booleanLabel\" aria-labelledby=\"default\" data-level=\"4\">is_bot<\/span><\/td>\n<td class=\"treeValueCell booleanCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-number\">false<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/0\/message\/from\/first_name\" class=\"treeRow stringRow opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel stringLabel\" aria-labelledby=\"default\" data-level=\"4\">first_name<\/span><\/td>\n<td class=\"treeValueCell stringCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-string\">&#8222;ingmarsretro&#8220;<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/0\/message\/from\/language_code\" class=\"treeRow stringRow opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel stringLabel\" aria-labelledby=\"default\" data-level=\"4\">language_code<\/span><\/td>\n<td class=\"treeValueCell stringCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-string\">&#8222;de&#8220;<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/0\/message\/chat\" class=\"treeRow objectRow hasChildren opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel objectLabel\" aria-labelledby=\"default\" data-level=\"3\">chat <span class=\"treeLabel numberLabel\" aria-labelledby=\"default\" data-level=\"4\">id<\/span><br \/>\n<\/span><\/td>\n<td class=\"treeValueCell objectCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-number\">123456789<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/0\/message\/chat\/first_name\" class=\"treeRow stringRow opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel stringLabel\" aria-labelledby=\"default\" data-level=\"4\">first_name<\/span><\/td>\n<td class=\"treeValueCell stringCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-string\">&#8222;ingmarsretro&#8220;<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/0\/message\/chat\/type\" class=\"treeRow stringRow opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel stringLabel\" aria-labelledby=\"default\" data-level=\"4\">type<\/span><\/td>\n<td class=\"treeValueCell stringCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-string\">&#8222;private&#8220;<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/0\/message\/date\" class=\"treeRow numberRow opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel numberLabel\" aria-labelledby=\"default\" data-level=\"3\">date<\/span><\/td>\n<td class=\"treeValueCell numberCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-number\">1565349110<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/0\/message\/text\" class=\"treeRow stringRow opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel stringLabel\" aria-labelledby=\"default\" data-level=\"3\">text<\/span><\/td>\n<td class=\"treeValueCell stringCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-string\">&#8222;test&#8220;<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/1\/update_id\" class=\"treeRow numberRow opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel numberLabel\" aria-labelledby=\"default\" data-level=\"2\">update_id<\/span><\/td>\n<td class=\"treeValueCell numberCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-number\">121212121<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/1\/message\" class=\"treeRow objectRow hasChildren opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel objectLabel\" aria-labelledby=\"default\" data-level=\"2\">message<\/span><\/td>\n<td class=\"treeValueCell objectCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\">&nbsp;<\/td>\n<\/tr>\n<tr id=\"\/result\/1\/message\/message_id\" class=\"treeRow numberRow opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel numberLabel\" aria-labelledby=\"default\" data-level=\"3\">message_id<\/span><\/td>\n<td class=\"treeValueCell numberCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-number\">111<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/1\/message\/from\" class=\"treeRow objectRow hasChildren opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel objectLabel\" aria-labelledby=\"default\" data-level=\"3\">from id<br \/>\n<\/span><\/td>\n<td class=\"treeValueCell objectCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-number\">123456789<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/1\/message\/from\/is_bot\" class=\"treeRow booleanRow opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel booleanLabel\" aria-labelledby=\"default\" data-level=\"4\">is_bot<\/span><\/td>\n<td class=\"treeValueCell booleanCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-number\">false<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/1\/message\/from\/first_name\" class=\"treeRow stringRow opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel stringLabel\" aria-labelledby=\"default\" data-level=\"4\">first_name<\/span><\/td>\n<td class=\"treeValueCell stringCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-string\">&#8222;iretro&#8220;<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/1\/message\/from\/language_code\" class=\"treeRow stringRow opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel stringLabel\" aria-labelledby=\"default\" data-level=\"4\">language_code<\/span><\/td>\n<td class=\"treeValueCell stringCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-string\">&#8222;de&#8220;<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/1\/message\/chat\" class=\"treeRow objectRow hasChildren opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel objectLabel\" aria-labelledby=\"default\" data-level=\"3\">chat id<br \/>\n<\/span><\/td>\n<td class=\"treeValueCell objectCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-number\">123456789<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/1\/message\/chat\/first_name\" class=\"treeRow stringRow opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel stringLabel\" aria-labelledby=\"default\" data-level=\"4\">first_name<\/span><\/td>\n<td class=\"treeValueCell stringCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-string\">&#8222;iretro&#8220;<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/1\/message\/chat\/type\" class=\"treeRow stringRow opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel stringLabel\" aria-labelledby=\"default\" data-level=\"4\">type<\/span><\/td>\n<td class=\"treeValueCell stringCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-string\">&#8222;private&#8220;<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/1\/message\/date\" class=\"treeRow numberRow opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel numberLabel\" aria-labelledby=\"default\" data-level=\"3\">date<\/span><\/td>\n<td class=\"treeValueCell numberCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-number\">1565349112<\/span><\/span><\/td>\n<\/tr>\n<tr id=\"\/result\/1\/message\/text\" class=\"treeRow stringRow opened\" style=\"height: 18px\" role=\"treeitem\">\n<td class=\"treeLabelCell\" style=\"width: 89.9833px;height: 18px\" role=\"presentation\"><span class=\"treeLabel stringLabel\" aria-labelledby=\"default\" data-level=\"3\">text<\/span><\/td>\n<td class=\"treeValueCell stringCell\" style=\"width: 90.9333px;height: 18px\" role=\"presentation\"><span aria-labelledby=\"value\"><span class=\"objectBox objectBox-string\">&#8222;test&#8220;<\/span><\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"text-align: justify\">Nun kann durch Eingabe in die Browserzeile eine Testnachricht vom PC an das Smartphone gesendet werden.<\/p>\n<p>https:\/\/api.telegram.org\/bot<strong><em>APITOKEN<\/em><\/strong>\/sendMessage?chat_id=<strong><em>123456789<\/em><\/strong>&amp;text=Hallo das ist ein Test<\/p>\n<p style=\"text-align: justify\">Nach Best\u00e4tigen erscheint die Nachricht in der Telegram App am Smartphone und alles hat geklappt. F\u00fcr alles Weitere wird nun nur mehr der API-Token und die chatID ben\u00f6tigt.<\/p>\n<h6>Homematic und Telegram<\/h6>\n<p style=\"text-align: justify\">Jetzt ist soweit alles f\u00fcr den Einsatz von Telegram mit der Homematic vorbereitet. Meine Beispiele hier beziehen sich auf eine CCU2. Als Addon muss die aktuelle Version des CUxD auf der CCU installiert sein. (Zum Zeitpunkt des erstellen des Blogbeitrages ist es 2.3.0). Der CUx-Daemon erm\u00f6glicht es unter anderem, per Skript auf das Linux System der CCU zuzugreifen und stellt somit eine universelle Schnittstelle zu anderen Systemen dar.<\/p>\n<p style=\"text-align: justify\">Die einfachste und am schnellsten realisierbare Anwendung mit Telegram ist, ein von der Homematic getriggertes Skript zu starten, das eine PUSH-Nachricht versendet. Dazu erstellt man in der CCU ein neues Programm und w\u00e4hlt zuerst unter <em>Bedingung<\/em> einen &#8222;Trigger&#8220; aus. Mit &#8222;Trigger&#8220; ist zum Beispiel eine Tastereingabe, eine Bewegungserkennung des Bewegungsmelders, oder auch einfach nur das Ausl\u00f6sen eines beliebigen Sensors gemeint. Das sollte f\u00fcr einen HomeMatic Benutzer auch kein Problem darstellen. Dann w\u00e4hlt man als <em>Aktivit\u00e4t<\/em> Skript aus und \u00f6ffnet das Scripteingabefenster.&nbsp; Das folgende Code-Beispiel sendet eine Nachricht an das Handy, wenn bei der HomeMatic der gew\u00e4hlte Trigger ausgel\u00f6st ist und das Script gestartet wird:<\/p>\n<div style=\"background: #ffffff;overflow: auto;width: auto;border: solid gray;border-width: .1em .1em .1em .8em;padding: .2em .6em\">\n<pre style=\"margin: 0;line-height: 125%\">!Variablen definieren\r\nstring msg = \"Das ist eine Testnachricht von der CCU\";\r\nstring chatid = \"123456789\"; !das ist die chatid\r\nstring botAPI = \"987654321:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi\"; !und das ist die BOT API id\r\n\r\n!Textnachricht versenden\r\ndom.GetObject(\"CUxD.CUX2801001:1.CMD_EXEC\").State(\"extra\/curl -s -k https:\/\/api.telegram.org\/bot\"#botAPI#\"\/sendMessage -F text='\"#msg#\"' -F chat_id=\"#chatid);\r\n<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Die ChatID in dem Beispielscript und auch die botAPI ist hier nur symbolisch angef\u00fchrt. W\u00e4ren da reale IDs angef\u00fchrt, dann w\u00fcrden eure Versuche alle als Nachrichten auf meinem Handy landen. \ud83d\ude42 Diese beiden IDs sind also durch die vorher ermittelten zu ersetzen.<\/p>\n<p>&nbsp;<\/p>\n<h6>Versenden von Kamerabildern<\/h6>\n<p style=\"text-align: justify\">Es geht aber noch besser. Viele User haben neben der HomeMatic CCU auch noch IP-Kameras im Einsatz. Da bietet es sich doch an, den Trigger der HomeMatic und seine Webanbindung f\u00fcr das Versenden der IP-Kamera Bilder zu verwenden. Denn Telegramm kann neben Textnachrichten auch Bilddateien versenden.<\/p>\n<p style=\"text-align: justify\">Um das zu realisieren muss die IP Kamera in der Lage sein, einen Snapshot per http &#8211; Aufruf zu erzeugen. Das sollte bei den meisten Kameras m\u00f6glich sein. In diesem Beispiel habe ich eine <em><strong>Dlink DCS-932<\/strong><\/em> und eine<em><strong> Vivotec FD81xx<\/strong><\/em> Domkamera getestet. Es klappt mit beiden.<\/p>\n<p>Hier die grundlegenden Snapshotaufrufe der Kameras:<br \/>\nDLINK:<br \/>\nhttps:\/\/benutzername:passwort@ip_der_kamera\/image\/jpeg.cgi<\/p>\n<p>VIVOTEK:<br \/>\nhttps:\/\/benutzername:passwort@ip_der_kamera\/cgi-bin\/viewer\/video.jpg?<\/p>\n<p style=\"text-align: justify\">Als n\u00e4chstes muss sichergestellt sein, dass die HomeMatic nach dem Aufruf der Snapshot-Links die von der Kamera gelieferten Bilder auch irgendwo im Dateisystem der CCU speichern kann. Hier hilft der CUx-Daemon wieder weiter. Ich speichere im \/tmp Ordner das Bild der Kamera unter dem Dateinamen &#8222;cambild.jpg&#8220;<\/p>\n<div id=\"attachment_4417\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/cuxDaemon.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4417\" class=\"wp-image-4417 size-medium\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/cuxDaemon-300x197.jpg\" alt=\"\" width=\"300\" height=\"197\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/cuxDaemon-300x197.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/cuxDaemon-768x503.jpg 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/cuxDaemon-1024x671.jpg 1024w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/cuxDaemon.jpg 1288w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-4417\" class=\"wp-caption-text\">CUxD Startbildschirm<\/p><\/div>\n<p style=\"text-align: justify\">Nach dem Aufruf desKameralinks \u00fcber das unten gelistete Script sollte die Datei im \/tmp Ordner zu sehen sein.<\/p>\n<div id=\"attachment_4418\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/cuxDaemon1.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4418\" class=\"wp-image-4418 size-medium\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/cuxDaemon1-300x197.jpg\" alt=\"\" width=\"300\" height=\"197\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/cuxDaemon1-300x197.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/cuxDaemon1-768x503.jpg 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/cuxDaemon1-1024x671.jpg 1024w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/cuxDaemon1.jpg 1286w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-4418\" class=\"wp-caption-text\">\/tmp Ordner<\/p><\/div>\n<p style=\"text-align: justify\">Eine Kontrolle des Inhaltes der Datei &#8222;cambild.jpg&#8220; kann einfach durch Doppelklicken durchgef\u00fchrt werden. Das Bild sollte dann im CUxD Fenster zu sehen sein.<\/p>\n<div id=\"attachment_4419\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/cuxDaemon2.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4419\" class=\"wp-image-4419 size-medium\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/cuxDaemon2-300x197.jpg\" alt=\"\" width=\"300\" height=\"197\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/cuxDaemon2-300x197.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/cuxDaemon2-768x504.jpg 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/cuxDaemon2-1024x672.jpg 1024w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/08\/cuxDaemon2.jpg 1288w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-4419\" class=\"wp-caption-text\">Kamerabild im CUxD Fenster<\/p><\/div>\n<p style=\"text-align: justify\">Das folgend gelistete Script in einem neu erstellten HomeMatic Programm kann nun durch Aufruf das Kamerabild abholen und versendet es als Telegram Push Nachricht.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff;overflow: auto;width: auto;border: solid gray;border-width: .1em .1em .1em .8em;padding: .2em .6em\">\n<pre style=\"margin: 0;line-height: 125%\">string picture = \"\/tmp\/cambild.jpg\";  !das ist der Pfad in dem die Bilddatei erzeugt und gespeichert wird\r\nstring chatid = \"123456789\";        !das ist die chatid\r\nstring botAPI = \"987654321:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi\";  !und das ist die BOT API id\r\n\r\n!Kamera aufrufen und snapshotdatei in \/tmp\/ anlegen und als datei cambild.jpg speichern\r\ndom.GetObject(\"CUxD.CUX2801001:1.CMD_EXEC\").State(\"wget --auth-no-challenge -O \/tmp\/cambild.jpg 'https:\/\/user:passwort@000.000.000.000:80\/image\/jpeg.cgi?profileid=1'\");\r\n\r\n!Kamerabild per Telegram versenden\r\ndom.GetObject(\"CUxD.CUX2801001:1.CMD_EXEC\").State(\"extra\/curl -s -k https:\/\/api.telegram.org\/bot\"#botAPI#\"\/sendPhoto -F chat_id=\"#chatid#\" -F photo='@\"#picture#\"'\");\r\n<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_4410\" class=\"pvc_stats all  \" data-element-id=\"4410\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>Mit der Homematic CCU ist es ja schon lange m\u00f6glich, Nachrichten aus Systemereignissen heraus zu generieren und per E-Mail zu versenden. Ein einfaches Beispiel hierf\u00fcr ist die Best\u00e4tigung der Alarmanlage. Wird diese scharf oder unscharf geschaltet, so kann der Status als Email versendet werden. Oder hat man Umweltdatensensoren verbaut, so kann man sich auch die&hellip; <br \/> <a class=\"read-more\" href=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/2019\/09\/09\/homematic-nachrichten-pushen-mit-telegram\/\">Weiterlesen<\/a><\/p>\n","protected":false},"author":86,"featured_media":4418,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"ngg_post_thumbnail":0,"footnotes":""},"categories":[1],"tags":[469,1311,1310,1314,1313,1307,1306,1308,1303,1304,1305,1312,1309],"class_list":["post-4410","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-allgemeines","tag-ccu","tag-cux-daemon","tag-cuxd","tag-dlink-dcs932","tag-fd81xx","tag-homematic-ipcam","tag-homematic-push-nachrichten","tag-ipcam-bilder-per-telegram","tag-telegram","tag-telegram-messenger","tag-telegram-und-homematic","tag-vivotec","tag-whatsapp-alternative"],"a3_pvc":{"activated":true,"total_views":1145,"today_views":1},"_links":{"self":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/posts\/4410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/users\/86"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/comments?post=4410"}],"version-history":[{"count":0,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/posts\/4410\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/media\/4418"}],"wp:attachment":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/media?parent=4410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/categories?post=4410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/tags?post=4410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}