Gibt es denn andere Alternativen, die eifach zu installieren sind und nicht mit so viel Aufwand verbunden sind?
Ankündigung
Einklappen
Keine Ankündigung bisher.
Telegram, Alternative zu WhatsApp
Einklappen
X
-
Code und Usage findest Du hier im Github.
Theoretisch könnte das Telegram Plugin mit Befehlen auch Informationen über Items, Logiken & Co. liefern genau so wie das CLI oder auch das Backend. Wenn man via Telegram Werte ändern können soll, ist es ggf. auch sinnvoll noch Rechte auszuwerten also z.B. wie visu_acl = rw dann ein telegram_cli = r für readonly / telegram_cli = rw für read und write. (Einfach aus Sicherheitsgründen, damit keiner einen Aktor schalten kann der Sicherheitsrelevant ist)
Dann wäre es noch gut, wenn Du das Plugin gleich Multiinstanzfähig machen könntest. Ich würde z.B. gerne einen Kanal für mich haben wo Systemweit wichtige Dinge sind und einen für die ganze Familie. Und die Informationen für die Familie sind natürlich klar andere als die vom System.Zuletzt geändert von bmx; 19.04.2017, 07:02.
Kommentar
-
Hm,
ich überlege gerade ob es nicht besser wäre, olog einen weiteren "Output Channel" zur Verfügung zu stellen. Denn die eigentliche Logik, also was, wie, formatiert, text, etc. geloggt wird macht ja olog schon hervorragend. Eine Doppelimplemtierung wäre da allein wegen der pflege ungünstig. Vielleicht macht es Sinn ein einfaches Messaging in Telegram zu implementieren und dann zusätzlich einen "Channel" den man olog übergeben kann um komplexere Logging Routinen zu implementieren.
Das Verändern von Variablen habe ich auf dem Schirm, aber ich möchte erst einmal mein (erstes) Plugin "richtig" zum Laufen bringen. In Summe hat Telegram tolle Möglichkeiten, mit vorgefertigten Menüs die Werte Auswahl ohne groß tippen zu ermöglichen, oder die Navigation durch den Itembaum zu ermöglichen. Aber man ist da relativ schnell bei einem alternativen Visu Interface
Grüße
MarkusZuletzt geändert von bmx; 08.05.2017, 09:43.
Kommentar
-
Mir paßt es nicht, das ein amerikanischer Konzern mit allem was ich hochlade Geld verdienen darf, meine Daten sind mir wichtig und gehen Facebook & Co. nichts an.
Außerdem gibt es wegen Patentproblemen kein Whatsapp Plugin (mehr) so daß Telegram eine prima Alternative dazu ist.
@gama: Via SmartHomeNG Logik könnte man auch mal lokal die Kameras abfragen nach dem aktuellsten Einbrecherbild und das dann per Telegram verteilen :-)
Wenn Du soweit bist, teste ich Dein Plugin gerne ...
Kommentar
-
Hallo!
Ich bekomme, wenn ich länger keine Nachricht verschickt habe, einen Fehler beim verschicken der ersten Nachricht per Telegram:
Code:2017-05-01 19:52:23 ERROR Klingel Logic: Klingel, File: /usr/lib/python3.4/ssl.py, Line: 617, Method: read, Exception: ('Connection aborted.', ConnectionResetError(104, 'Die Verbindung wurde vom Kommunikationspartner zurückgesetzt')) Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/urllib3/connectionpool.py", line 600, in urlopen chunked=chunked) File "/usr/local/lib/python3.4/dist-packages/urllib3/connectionpool.py", line 386, in _make_request six.raise_from(e, None) File "<string>", line 2, in raise_from File "/usr/local/lib/python3.4/dist-packages/urllib3/connectionpool.py", line 382, in _make_request httplib_response = conn.getresponse() File "/usr/lib/python3.4/http/client.py", line 1172, in getresponse response.begin() File "/usr/lib/python3.4/http/client.py", line 351, in begin version, status, reason = self._read_status() File "/usr/lib/python3.4/http/client.py", line 313, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "/usr/lib/python3.4/socket.py", line 371, in readinto return self._sock.recv_into(b) File "/usr/lib/python3.4/ssl.py", line 745, in recv_into return self.read(nbytes, buffer) File "/usr/lib/python3.4/ssl.py", line 617, in read v = self._sslobj.read(len, buffer) ConnectionResetError: [Errno 104] Die Verbindung wurde vom Kommunikationspartner zurückgesetzt During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/smarthome/lib/scheduler.py", line 354, in _task exec(obj.bytecode) File "/usr/local/smarthome/logics/alarmautomatik.py", line 27, in <module> sh.telegram._broadcast('Alarmautomatik wurde deaktiviert!') File "/usr/local/smarthome/plugins/telegram/__init__.py", line 104, in _broadcast self._bot.sendMessage(cid, msg) File "/usr/local/lib/python3.4/dist-packages/telepot/__init__.py", line 408, in sendMessage return self._api_request('sendMessage', _rectify(p)) File "/usr/local/lib/python3.4/dist-packages/telepot/__init__.py", line 397, in _api_request return api.request((self._token, method, params, files), **kwargs) File "/usr/local/lib/python3.4/dist-packages/telepot/api.py", line 130, in request r = fn(*args, **kwargs) # `fn` must be thread-safe File "/usr/local/lib/python3.4/dist-packages/urllib3/request.py", line 148, in request_encode_body return self.urlopen(method, url, **extra_kw) File "/usr/local/lib/python3.4/dist-packages/urllib3/poolmanager.py", line 313, in urlopen response = conn.urlopen(method, u.request_uri, **kw) File "/usr/local/lib/python3.4/dist-packages/urllib3/connectionpool.py", line 649, in urlopen _stacktrace=sys.exc_info()[2]) File "/usr/local/lib/python3.4/dist-packages/urllib3/util/retry.py", line 357, in increment raise six.reraise(type(error), error, _stacktrace) File "/usr/local/lib/python3.4/dist-packages/urllib3/packages/six.py", line 685, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.4/dist-packages/urllib3/connectionpool.py", line 600, in urlopen chunked=chunked) File "/usr/local/lib/python3.4/dist-packages/urllib3/connectionpool.py", line 386, in _make_request six.raise_from(e, None) File "<string>", line 2, in raise_from File "/usr/local/lib/python3.4/dist-packages/urllib3/connectionpool.py", line 382, in _make_request httplib_response = conn.getresponse() File "/usr/lib/python3.4/http/client.py", line 1172, in getresponse response.begin() File "/usr/lib/python3.4/http/client.py", line 351, in begin version, status, reason = self._read_status() File "/usr/lib/python3.4/http/client.py", line 313, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "/usr/lib/python3.4/socket.py", line 371, in readinto return self._sock.recv_into(b) File "/usr/lib/python3.4/ssl.py", line 745, in recv_into return self.read(nbytes, buffer) File "/usr/lib/python3.4/ssl.py", line 617, in read v = self._sslobj.read(len, buffer) urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Die Verbindung wurde vom Kommunikationspartner zurückgesetzt'))
Danke und Grüße
David
Kommentar
-
Hallo,
ja, laut Log habe ich exakt das gleiche Problem. Das Senden einer Nachricht funktioniert des Öfteren nicht, ob es damit zusammenhängt, dass vorher längere Zeit nichts gesendet wurde weiß ich nicht? Leider habe ich auch keine Idee, was das Problem verursacht und wie man es beheben kann.
Gruß
Franz
Kommentar
-
Hallo!
Bei mir scheint es zu gehen, hab folgendes ins __Init__ eingefügt:
Code:telepot.api._pools = { 'default': urllib3.PoolManager(num_pools=3, maxsize=10, retries=3, timeout=30), }
Code:import telepot.api
Grüße
David
- 1 Likes
Kommentar
-
Moin,
um ein lokales Photo zu versenden und ggf. auch nur Nachrichten, habe ich dieses Plug-In zusammengeflickt
(der bisherige Stand von gama in GitHub hat dies nicht hergegeben)
Wäre cool, wenn Ihr das Photo-Versenden-Feature mit aufnehmen könntet
(falls nicht ehe schon geplant)
Als Erweiterung für die Zukunft wären Bilder lokal + remote =per HTML-Adresse; gemäß folgender Anleitung noch sinnvoll.
http://stackoverflow.com/questions/3...h-telegram-bot
Dies könnte man nutzen um Webcam-Bilder zu versenden...
Nun folgt mein Zwischenstand:
__init__.py
Code:#!/usr/bin/env python3 ######################################################################### # Copyright 2017 KNX-User-Forum: KHome http://knx-user-forum.de/ # Based on NMA-Plug-In ######################################################################### # This file is part of SmartHome.py https://github.com/smarthomeNG # # SmartHome.py is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # SmartHome.py is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with SmartHome.py. If not, see <http://www.gnu.org/licenses/>. ######################################################################### import logging import telepot logger = logging.getLogger('telegram') class telegram(): def __init__(self, smarthome, botkey=None, targetid=None): self._botkey = botkey self._targetid = targetid self._sh = smarthome def run(self): pass def stop(self): pass def __call__(self, mytype='', message='', photofile=None, botkey=None, targetid=None): localbotkey = self._botkey if botkey: localbotkey = botkey localtargetid = self._targetid if targetid: localtargetid = targetid try: bot = telepot.Bot(localbotkey) bot.getMe() if (mytype == 'sendMessage'): logger.debug('Sending Message ' + message + ' to ID: ' + str(localtargetid) ) bot.sendMessage(int(localtargetid), message) elif (mytype == 'sendPhoto'): logger.debug('Sending Photo, file: ' + photofile + ' with caption: ' + message + ' to ID: ' + str(localtargetid)) bot.sendPhoto(int(localtargetid),open(photofile,'rb'), message) elif (mytype == 'dummy'): logger.debug('For future functions') else: logger.error('Type for telegram unknown: ' + mytype) except Exception as e: logger.warning('Could not send telegram message, error: {1}'.format(e))
README.md
Code:# Telegram # Requirements telepot python library, get it from http://telepot.readthedocs.io/en/latest/index.html e.g. pip install telepot or pip3 install telepot or: https://github.com/nickoala/telepot Telegram Bot-Key get it from https://telegram.org/ for free Hint: "chat" to Botfather and ask for "/newbot" as described here: https://core.telegram.org/bots#6-botfather Telegram Target-ID Write a message to the new bot via your smartphone, I wrote: "test" Now I've check this via python3 shell (replace 'YOUR-BOT-KEY' with your own new one) > import telepot > bot = telepot.Bot('YOUR-BOT-KEY') > bot.getMe() ANSWER: {'first_name': 'XXXX', 'id': 111111111111, 'username': 'YYYYYYYYYYY'} # this is your Bot-ID: "11111111111" - I don't think it's needed, just go ahead > response = bot.getUpdates() > print(response) ANSWER: [{'edited_message': {'chat': {'last_name': 'uuuuuuuuuu', 'first_name': 'uuuuuuuuuu', 'id': 22222222222, 'type': 'private'}, 'text': 'Test', '... # this is YOUR-TARGET-ID: "22222222222222" # Configuration ## plugin.conf <pre> [telegram] class_name = telegram class_path = plugins.telegram # botkey = 'YOUR-BOT-KEY' # targetid = YOUR-TARGET-ID </pre> Description of the attributes: * __botkey__: set bot-key globally so you do not have to set it in the function calls * __targetid__: set targetid globally so you do not have to set it in the function calls # Functions There are serveral functions you could access through the telepot-API. Some are used by the first keyword. These simple messages are implemented (as an improvement to the NMA Plug-In) <pre> sh.telegram('sendMessage', 'your message string') sh.telegram('sendPhoto', 'your message string, caption', 'path_to_photo_file') </pre> This function takes several arguments: * __mytype__: Keyword to distinguish the action / parameter-set {'sendMessage', 'sendPhoto'} * __message__: Text, which you want to share * __photofile__: Path to local file * __targetid__: targetid - not necessary if global is set * __botkey__: botkey - not necessary if global is set # Examples <pre> sh.telegram('sendMessage', 'Hello from Bot') sh.telegram('sendPhoto', 'Outside', '/home/pi/test.jpg') </pre>
- 1 Likes
Kommentar
-
Irgendwie antwortet mein Bot erst, nachdem ich ihn übers Plugin eingebunden habe.. deshalb hat er bei nicht laufendem Plugin auf "/subscribe" nicht reagiert. Keine Ahnung, ob das so sein soll
Ich bin nun nach dieser Anleitung vorgegangen:
https://www.forsomedefinition.com/au...notifications/
um die ChatID ausfindig zu machen. Vielleicht könnt man da auch die relevanten Parts ins README nehmen für noobs wie mich?
Kommunikation mit BotFather zB via https://telegram.me/botfather
beliebigen Text an neuen Bot schicken
Danach die URL aufrufen: https://api.telegram.org/bot$TOKEN/getUpdates
Woran kann's liegen wenn die Fehlermeldung kommt: could not broadcast to chat id
Die ChatID stimmt 100%, gerade kontrolliert. /subscribe liefert mir die gleiche ID.
UPDATE: Es kamen nun schon mehrfach erfolgreiche Meldungen von Smarthome raus. Mittendrin dann aber wieder ein broadcast error..Zuletzt geändert von Onkelandy; 28.05.2017, 20:59.
Kommentar
-
Hi,
kannst Du deine "frischen" Erfahrungen zum Installieren in ein paar Stichworte zusammenfassen - dann nehme ich das gerne in die Doku mit auf.
/subscribe soll mal dazu dienen, dass ich Benutzer, z.B. über Passwort und/oder Auth-Url authentifizieren sollen. Aktuell wird die chat-id zurückgemeldet die manuell in die conf Datei eingetragen werden muss.
Den Fehler, dass er nicht Nachrichten verschicken kann, hatte ich die letzte Zeit auch. Ich meine, dass eine Änderung bei PoolManger auf
urllib3.PoolManager(num_pools=3, maxsize=10, retries=10, timeout=30) Besserung gebracht hat. Ich hatte aber in letzter Zeit etwas Probleme mit dem I-Net und war mir der Ursache nicht gewiss... wäre gut, wenn das jemand verifizieren könnte.
Grüße
Markus
Kommentar
-
Zitat von gama Beitrag anzeigen/subscribe Aktuell wird die chat-id zurückgemeldet die manuell in die conf Datei eingetragen werden muss.
Das funktioniert anscheinend nicht richtig. Hier mal was ich dir noch in dein Pull Request reingeschrieben hatte letzte Woche. Ich weiss nicht ob du das gesehen hast da das Request ja schon geschlossen wurde:
Hallo @gamade,
Seems to be a problem if an unknown user sends "/subscribe" to the bot to get his ID.
Line 210: self._bot.sendMessage(tmp_chat_id, "Welcome at %s. Please register your ID: [%d]" % (self._name, tmp_chat_id))
That line does not work. If you remove the %s and self._name it does work:
self._bot.sendMessage(tmp_chat_id, "Please register your ID: [%d]" % (tmp_chat_id))
I have no clue why the self._name does not work here as it works two line above on the "you are already signed up" line ....
Serge
Kommentar
Kommentar