Error setting up platform telegram

Is anyone getting error - [homeassistant.components.notify] Error setting up platform telegram.
My telegram Id is working fine as i get images of ftp on my bot from script on rpi but cannot setup in notify.My notify.yaml config is like -

 - platform: telegram
   name: Telegram
   api_key: !secret telegram_api
   chat_id: !secret telegram_chatid

I cannot see the telegram in service tab. I also have pushbullet,join setup and they are showing up and working. Can anyone guide what is wrong.

Can you post the full error from home_assistant.log? There should be some additional lines before the “error setting up platform” message. For instance, you may be missing a dependency.

I cheked but couldnt find any -

17-03-06 02:33:44 ERROR (MainThread) [homeassistant.components.notify] Error setting up platform telegram
Traceback (most recent call last):
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/notify/init.py”, line 101, in async_setup_platform
None, platform.get_service, hass, p_config, discovery_info)
File “/usr/lib/python3.4/asyncio/futures.py”, line 388, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.4/asyncio/tasks.py”, line 286, in _wakeup

How about before the error? Usually, you get the error after something’s gone wrong.

I cleared the log file and restarted HA now i am getting error -

    17-03-06 09:38:21 ERROR (MainThread) [homeassistant.components.notify] Error setting up platform telegram
    Traceback (most recent call last):
      File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/notify/__init__.py", line 101, in async_setup_platform
        None, platform.get_service, hass, p_config, discovery_info)
      File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
        yield self  # This tells Task to wait for completion.
      File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
        value = future.result()
      File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
        raise self._exception
      File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
        result = self.fn(*self.args, **self.kwargs)
      File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/notify/telegram.py", line 48, in get_service
        bot = telegram.Bot(token=api_key)
      File "/home/homeassistant/.homeassistant/deps/telegram/bot.py", line 53, in __init__
        self.token = self._validate_token(token)
      File "/home/homeassistant/.homeassistant/deps/telegram/bot.py", line 79, in _validate_token
        raise InvalidToken()
    telegram.error.InvalidToken: Invalid token

I confirmed from -https://api.telegram.org/botxxxx:xxxxxxxxxxxxx/getMe and it returns me the values.
My secret file is given as :

telegram_api: xxxxxxxxx
telegram_chatid: botxxxxxxx

Hi. You must remove “bot” from the chatid.

Tried removing bot from chatid still the same.

Question:
Your api key is like: NNNNNNNNN:XXXXXXXXXXXXXXXX-XXXXXXXXX
and your chatid like NNNNNNNN

where N is number and X is alphanumeric

I think this is what i an doing wrong. I didnt put chatid in front of api.I am doing api_key:XXXXXXXXXXXXXXXXXXXXXXXXX

I double checked api key and there is no - in my api key its just all alpha numeric without - inbetween.

May by the - is in my apikey and not in yours

The front of api-key is not the chatid.

The api-key is what you put on the url, whitout the “bot” part.

Thanks got it working. Was not using api key is like: NNNNNNNNN:XXXXXXXXXXXXXXXXXXXXXXXXX in this format. :slight_smile: