Hass telepot

I’ve made a custom component to talk to a telegram bot.

I’d like to add it to home assistant, but I see there are already two components dealing with telegram:

  • a notify component which only allows for one way (outgoing) communication.
  • telegram-webhook : Allows for talking to hass through a telegram bot using a webhook. (Fires an event inside hass which can be picked up by an automation as a trigger.).

I still feel my component has added value; The notify command only notifies, the webhook component requires hass to be exposed to the internet. My component does use polling and allows for more customization.

What do you think ? And in wich domain should this component belong to ?

Sander.

I may just give your telepot a try. I can’t really figure out GussyH’s install and purpose.
My requirements are fairly simple (and most will be) What I want to create now is a notification to ask if I should send the vacuum out. So if it’s 10:15AM and the vacuum is fully charged, send me a telegram note asking if I want to /SendOut or /KeepDocked. I would think that this would be fairly easy with your script.

Should be perfectly possible…

I want to control my HASS with telegram, but I wouldn’t like to expose it to Internet, so telegram-webhook is not an option… Any news of this contribution?

I’m working on a telegram bot platform, where you can choose for either polling or webhook, but it is not ready yet. In the meantime you could use this:

Nobody here wanting to write a nice xmpp bot? There’s hubot but not really fancy

@sanders, just tried your bot - works pretty good! I planned to write my own implementation of polling bot, but it appears you already did it - thanks a lot. BTW is there a possibility to get some info thru bot (e.g. query current “away” status)? I guess I could trigger some script which would send me required piece with “notification”, but maybe there is more easy way?

Hmm, one more thing: seems like allowed_ids functionality isn’t yet implemented:

...
if (content_type == 'text') and (chat_id in allowed_chat_ids):
...

Also I tried to use hass template in reponse.text which is the most expected place for that, but no luck.

PS
Please don’t think I blame you, you did a great work with this bot, if you’ll have some spare time, cases above would be a great features from my standpoint.

Hi Vladimir,

To get the “away” status of your hass you should be doing that through a script like you describe. There is no other “easy” way.

I’m not sure what you mean by allowed_ids not being implemented. Doesn’t it work ? Is there an error ?

Also, I have an open pull request which will include this component by default in hass…
https://github.com/home-assistant/home-assistant/pull/6913

@sanders, by allowed_ids I mean the allowed user ID. You can try the following config:

- command: /status
  allowed_ids: 
  - johndoe
  script:
    service: script.turn_on
    entity_id: script.presence_report

And try to send /status to your Telegram bot - it will trigger the script even if you’re not johndoe

The next release of hass will have my plugin implemented as a new platform…
Have a look here:

https://github.com/home-assistant/home-assistant/pull/6913

So I will not be doing any further development on my custom telegram component.

@sanders, thanks for doing that!

You’re welcome!

Hi sanders, great work on the chatbot support! I’ve been waiting a long time for this :slight_smile:

I just discovered a problem though: it does not support negative chat_ids, like those of groups. The telegram notify component does support negative chat IDs, but the chatbot component doesn’t.

@zouden Ok. I will look into that.

@zouden Hi Zouden. Are there negative chat_ids other than group ids ? Can a group send a message which is to be received by the telegram bot ?

Hi Sander, I think there’s only two types of chat_ids: individual users (positive values) and groups (negative values).

I added @myidbot to a group and used the /getgroupid command and it gave me a negative number. When I used that in HASS’s telegram notify service, the group received the message. So I think it’s just treated like any other ID, so you just need to allow telepot to accept negative numbers.

1 Like

@zouden the notify service can post to a group (with negative id). But you cannot send a message from a group can you? Only an individual can post? I guess I am missing something…

@sanders oh I understand now, yes you’re right. A message from a user is always a message from a user, even if it’s sent to a group, so Telepot can get the message as long as it has my chat_id. I just tested that and it works.

However: it would still be nice (as an enhancement) to allow group IDs in addition to the individual chat_id. That way, if I want to allow a visitor to send commands via telegram, I can just add him to my household chat group (and not have to modify the configuration.yaml).

@zouden But wouldn’t that visitor be sending to the group using his own chat_id too ? I agree if a group can send a message than the telebot should accept this. But I am still wondering whether this will ever happen…