Core: Telegram commands not working when using polling method, in .45

Created on 7 Jun 2017  路  23Comments  路  Source: home-assistant/core

Home Assistant release (hass --version):
.45
Component/platform:
Telegram
Description of problem:
Prior to updating to .45, I was using Telegram webhooks. Telegram was able to receive commands, via automations as well as send notifications.

Once updated to .45, webhooks no longer seems to work so I switched to polling, per the documentation. Notifications work fine but I can no longer get commands to work. If I send a command, such as /ping, nothing happens at all. I dont even see the command being received in the journal. Not sure what the issue is.

No errors show up in the log, either.

I've also tried rebuilding the deps folder, but it has had no effect on this issue

Expected:
Commands to work, via automation.

Problem-relevant configuration.yaml entries and steps to reproduce:
Config:

notify:
  - platform: telegram
    name: TeleBot
    api_key: !secret telegram_API
    chat_id: !secret telegram_group_ID

telegram_bot:
  platform: polling
  api_key: !secret telegram_API
  allowed_chat_ids:
    - !secret telegram_ID_1

Example automation

- alias: 'pingpong'
  trigger:
    platform: event
    event_type: telegram_command
    event_data:
      command: '/ping'
  action:
    - service: notify.TeleBot
      data:
        message: "pong!"

Additional info:

Most helpful comment

I think I found the problem. I'll try posting a fix this weekend...

All 23 comments

issue seems worse on current version (0.46). no longer able to import module urllib3.contrib.appengine which causes failure of platform. may be issue with urllib3?

Confirm the issue also in 0.46:
with polling configuration, notifications work fine but commands doesn't work.

@tacofart resolved, check in your telegram app settings if you have set both firstname and lastname. (i had set only first name)

The issue is in __init__.py, line 546-547.

Setting both, commands now working.

if you have only first name set (like me) you have first to dequeue polling. I have temporaneously commented out line 547, restarted hass, then decommented.

Where is the init.py file? I checked __init__.py in .homeassistant/deps/telegram, but it's not long enough to have a line 547.

Thanks!

i have hassbian, so the file is in /srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/telegram_bot/

Thanks, was able to find it.
I'm not the OP, but I was having the same issue. Following your instructions (adding Last Name and commenting that line out) resolved the issue. Thanks so much!

For me on Ubuntu 16.04, it was in /opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/telegram_bot

u're welcome! now you can remove the comment on that line.

Can confirm it started working after adding last name and restarting hass. No need to comment out anything.

There are riports of polling randomly dying after a couple hours with this error:

ERROR (MainThread) [homeassistant.components.telegram_bot.polling] Client connection error

My hass is suffering from this too since polling was added as a component (I have first, last name set from the getgo)

@GMFalka Yep, Im seeing this too. Looks like it worked for about 2 hours after I added a last name and restarted before that error popped up. Now commands wont work again.

do you have WARNING (Thread-4) [urllib3.connectionpool] Connection pool is full, discarding in home-assistant.log?

In this case, can you try to downgrade urrlib to version 1.20?

ex. in hassbian:

source /srv/homeassistant/bin/activate
pip3 install urllib3==1.20 --upgrade --target /home/homeassistant/.homeassistant/deps/

I think I found the problem. I'll try posting a fix this weekend...

@sander76 which problem are you referring to? Seems like a couple have popped up in here now, and my original one has sorta been figured out

@tacofart the error where people are reporting "connection error" and telegram stops working. I know the problem.. now some time and a computer to make a pr.

Thank you @sander76.

Sometimes I get this telegram api error in the log:

2017-06-11 19:55:34 WARNING (Thread-5) [urllib3.connectionpool] Connection pool is full, discarding connection: api.telegram.org

@sander76 any luck figuring it out, or are you able to post the issue so others can look at it?

Oh sweet, looks like its in .47

@tacofart I don't have any problems anymore. What's your experience ? Otherwise we should close this issue.

One issue (which is actually no issue)
Sometimes the polling times out. This is reported as an error to hass (as a Client connection error .), but actually everything keeps working as a new polling request will be initiated. This will be fixed..

It works very well. Thanks @sander76 for the fix!

@sander76 works great, thanks for your help. Did the original issue, that required a last name, get fixed? Havent had a chance to test it.

I think I saw a fix for that too. Not by me though.

Was this page helpful?
0 / 5 - 0 ratings