Telegram issues in 0.45

even im having issue on telegram webhooks. notify works fine.

config

notify:  
  - name: telegram
    platform: telegram
    api_key: xxxx
    chat_id: 54321

telegram_bot:
    platform: webhooks
    api_key : xxxxxx
    allowed_chat_ids:
        -  12345
2017-06-03 17:44:34 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "C:\Users\mohammed\AppData\Roaming\.homeassistant\deps\aiohttp\web_protocol.py", line 417, in start
    resp = yield from self._request_handler(request)
  File "C:\Users\mohammed\AppData\Roaming\.homeassistant\deps\aiohttp\web.py", line 289, in _handle
    resp = yield from handler(request)
  File "C:\Users\mohammed\AppData\Local\Programs\Python\Python35\lib\asyncio\coroutines.py", line 209, in coro
    res = yield from res
  File "C:\Users\mohammed\AppData\Local\Programs\Python\Python35\lib\asyncio\coroutines.py", line 209, in coro
    res = yield from res
  File "C:\Users\mohammed\AppData\Local\Programs\Python\Python35\lib\site-packages\homeassistant\components\http\ban.py", line 58, in ban_middleware_handler
    return (yield from handler(request))
  File "C:\Users\mohammed\AppData\Local\Programs\Python\Python35\lib\site-packages\homeassistant\components\http\__init__.py", line 424, in handle
    result = yield from result
  File "C:\Users\mohammed\AppData\Local\Programs\Python\Python35\lib\site-packages\homeassistant\components\telegram_bot\webhooks.py", line 86, in post
    if not self.process_message(data):
  File "C:\Users\mohammed\AppData\Local\Programs\Python\Python35\lib\site-packages\homeassistant\components\telegram_bot\__init__.py", line 515, in process_message
    message_ok, event_data = self._get_message_data(data)
  File "C:\Users\mohammed\AppData\Local\Programs\Python\Python35\lib\site-packages\homeassistant\components\telegram_bot\__init__.py", line 504, in _get_message_data
    ATTR_FROM_LAST: msg_data['from']['last_name']
KeyError: 'last_name'

HA v0.46 is out, I’ve tested it successfully, and these errors should have gone now, can you try it?

The Telegram Bot is expecting some fields about the origin of received messages:

data = {
    ATTR_USER_ID: msg_data['from']['id'],
    ATTR_FROM_FIRST: msg_data['from']['first_name'],
    ATTR_FROM_LAST: msg_data['from']['last_name']
}

Your account (the user which sends messages to the Bot) has not defined ‘first name’ and ‘last name’? Perhaps they should be optional in Home Assistant…

added Last name now it works thanks :slight_smile:

hello i have this error on my log:

2017-06-05 09:39:51 ERROR (Thread-5) [homeassistant.components.telegram_bot] Can’t load photo into ByteIO: HTTPConnectionPool(host=‘192.168.1.98’, port=8080): Max retries exceeded with url: /photo.jpg (Caused by ConnectTimeoutError(, ‘Connection to 192.168.1.98 timed out. (connect timeout=15)’))
2017-06-05 09:39:51 ERROR (Thread-5) [homeassistant.components.telegram_bot] Can’t send file with kwargs: {‘url’: ‘http://192.168.1.98:8080/photo.jpg’, ‘title’: ‘Home Assistant’, ‘message’: ‘Campainha Escada’, ‘caption’: ‘Campainha da Escada’}

my automation is:

  • alias: ‘Campainha’
    trigger:
    platform: state
    entity_id: binary_sensor.Campainha
    state: ‘on’
    action:
    • service: mqtt.publish
      data:
      topic: ‘home/433toMQTT’
      payload: ‘10340193off’
      retain: ‘true’
    • service: notify.telegram
      data:
      title: ‘Home Assistant’
      message: ‘Campainha Escada’
      data:
      photo:
      url: http://192.168.1.98:8080/photo.jpg
      caption: ‘Campainha da Escada’

when i try to send a simple text Works fine, but photo no.

046 fixed something for me.
now i get an error message with image processing.

I could fix this by creating a workarround
in my automation i use a shell command (wget) to save the screensshot and then i will use the file option from telegram to send the image.

works great now :slight_smile:

Thanks