Telegram-bot could not be set up

Hi, I’m trying to get Telegram to work.

config:

# Telegram bot
telegram_bot:
  - platform: webhooks
    api_key: 000000000:ASEcretapikeY
    trusted_networks:
      - 149.154.167.197/32
      - 149.154.167.198/31
      - 149.154.167.200/29
      - 149.154.167.208/28
      - 149.154.167.224/29
      - 149.154.167.232/31
    allowed_chat_ids:
      - 1111111111

# Notify settings
notify:
  - name: telegram
    platform: telegram
    api_key: 000000000:ASEcretapikeY
    chat_id: 1111111111

I have configured DuckDNS with Let’s Encrypt, and I can access Hass.io remote using this.

In Home Assistant I get a message saying:

Invalid Config
The following components and platforms could not be set up:

  • telegram-bot
  • notify.telegram

Please check your config.

Running hassio homeassistant check in the CLI, results in Success homeassistant/check.

What am I doing wrong?

Remove the api key line from the notify section.

Comment out your trusted network block.

Restart and see if it works.

If not, post error. If so, re-enable the trusted networks and see what happens.

Thank you for replying!

I did what you suggested, but unfortunately I still get the same error in Home Assistant, and the check command still reports Success.

Is there a way I could get more info from the log about why telegram-bot has invalid config?

Click on the little ‘i’ in a circle on the dev panel and look for the error message(s) in the list. Click on the message for the full details and paste them here.

Thanks! That’s a feature I wasn’t aware of.
Here’s the errors:

Error setting up platform webhooks
Error setting up platform webhooks
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/components/telegram_bot/__init__.py", line 229, in async_setup
    platform.async_setup_platform(hass, p_config)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/telegram_bot/webhooks.py", line 83, in async_setup_platform
    result = yield from hass.async_add_job(_try_to_set_webhook)
  File "/usr/lib/python3.6/asyncio/futures.py", line 332, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/telegram_bot/webhooks.py", line 76, in _try_to_set_webhook
    return bot.setWebhook(handler_url, timeout=5)
  File "/usr/lib/python3.6/site-packages/telegram/bot.py", line 60, in decorator
    result = func(self, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/telegram/bot.py", line 1813, in set_webhook
    result = self._request.post(url_, data, timeout=timeout)
  File "/usr/lib/python3.6/site-packages/telegram/utils/request.py", line 272, in post
    **urlopen_kwargs)
  File "/usr/lib/python3.6/site-packages/telegram/utils/request.py", line 210, in _request_wrapper
    raise BadRequest(message)
telegram.error.BadRequest: Bad webhook: webhook can be set up only on ports 80, 88, 443 or 8443

Setup failed for telegram_bot: Component failed to initialize.

Unable to setup dependencies of notify.telegram. Setup failed for dependencies: telegram_bot

Unable to prepare setup for platform notify.telegram: Could not setup all dependencies.

Unknown notification service specified

Try changing webhooks to polling.

I forwarded port 8443, and changed to this port in the base_url, now the message about invald config is gone, and no error in the log. But still I can’t find anything related to notify or telegram in the States view.

I tried using polling in stead of webhooks at the beginning, but then I had the same problem as now. No errors, and nothing related to notify or telegram in the Statesview.

They don’t have a state, so they won’t be in the states view.

If you have no errors have you tried sending a message?

I tried this:

2018-01-25%2012_34_29-Home%20Assistant

But I haven’t received the test yet.

I also tried this using polling.

Again, they do not have a state. You cannot set a state.

Click on the remote control icon on the far left of the panel to get to the services page…

(yours will say notify.telegram in the drop down list)

Ah, thank you!
Now I got the message.

1 Like