HASS TeleBot (Telegram Bot)

So there was a thread in the Feature Requests forum to create a bot for Telegram that would allow querying HASS from inside Telegram, and also controlling it.

To that end I’ve created the HASS TeleBot as a base on which to build.

Currently it doesn’t do much apart from allow you to set a list of entities you care about and want to see the states of, and commands to allow the controlling of the Manual Alarm Control Panel component.

But it’s a good base on which to start! Feel free to suggest additions, discuss how it could be improved, or submit pull requests :smiley: It’s my first public project so please go easy on me!

Thanks to @koen01 for his initial POC, some of which survives :thumbsup:

7 Likes

Currently I’m figuring out how to parse the domain and service list from the API so I can present that via the bot.

Have added a /domains command which lists the available HASS domains, and /browsedomains which returns the list as keyboard buttons. This could be the start of dynamically navigating the available services.

First off: Great work!
I’m not on a machine where I can in an easy way create a PR but you should add a requirements.txt to ease the installation of requirements (like teleport)

Cheers :slight_smile:

1 Like

Ahh good idea! Added that issue to Github and will take a look to see how it’s done.

https://github.com/GussyH/hass-telebot/issues/3

1 Like

Cool project! A slightly different approach would be to turn it into a custom notify platform in home assistant and use the internal core API instead. That would make it easier to create a PR if/when you want to merge it upstream with home assistant.

1 Like

Yes definitely. I was thinking at some stage of perhaps merging it into the main Telegram component. But for now I just want to explore what’s possible and work on functionality without getting into the hard process of contributing to HASS itself.

Added configurable list of favourite entities and a command to display the current state of those in the list (/favstates).

1 Like

I have an xmpp bot, that I would like to tie in, is yours xmpp or telegram via the api ?

Telegram API using the telepot library

Ah, thanks, I am trying to make it where it can log into slack/hangouts, and others at the sime time. I have an xmpp bot written in python that works well. I just have to tie it in.

1 Like

Location support now added :wink:

If an entity has location data and is ‘not home’ than a map will be displayed when that entity is displayed using the /favstates command.

Well things move fast! My bot has been picked up by of the core HASS devs, and looks like we might be building this as a new bot component for HASS :slight_smile: More news later…

4 Likes

@soul
Any news on this?

I’m still using my own bot, but looking forward to using the new and improved carnation :slight_smile:

i’m was hinking about trying to add support for grabbing screenshots of the camera devices and get them sent as a picture by the bot. (or triggering a notify with url grab).

Hi Soul,

Ran into this thread. Interesting. Any news on the core devs picking this up ?

First of all thank you for sharing your work. However, it has been more than 4 months and I still don’t see any news on this. Any idea how is the progress?

@Soul

I am trying to follow you guide at https://github.com/GussyH/hass-telebot

However there are few things I am not sure.

  1. Do I install this on the same system with the HASS or different system?
  2. I installed my HASS using pip3, NOT pip3.5. Can I run this instead sudo pip3 install -r requirements.txt?
  3. Which folder do I install this?
  4. devices = ['alarm_control_panel.ha_alarm']. Where do I put this?
  5. How do I make it auto run on boot?

Thanks.

  1. I think it dose not mater because you are makeing a call to an API ( HA API ) via host name ( or domain or IP) ha_url

2)yes. The 3 and 3.5 will use the same setup :slight_smile:
3) I personally have putt it one directory above the HA because i have collect all my other scripts there.
4) no clue i didnt use it :confused:
5) look here https://stackoverflow.com/questions/8339555/how-to-run-a-script-at-the-start-up-of-ubuntu
is more less universal on all the Linux systems … i personally have made a bash script and am calling it from /etc/rc.local

script:
tmux new -d -s my-Sensors '/path/to/folder/; ./hass-telebot.py hass-telebot.cfg'

more info on tmux https://tmux.github.io/

Thanks. Will try it out later and will let you know the result

hi @mak,

These are the steps that I have taken…

cd
git clone --depth=1 https://github.com/GussyH/hass-telebot.git
cd hass-telebot
sudo pip3 install -r requirements.txt
./hass-telebot.py hass-telebot.cfg

However, it came up with this error…

-bash: ./hass-telebot.py: /srv/telebot/bin/python3.5: bad interpreter: No such file or directory

I believe I need to edit the first line in hass-telebot.py but I am not sure what is the correct path. Do you have any suggestion?

By the way, I installed this on Raspberry Pi 3 which is also running my HASS.

try call the interpreter … for example i use

python3 hass-telebot.py hass-telebot.cfg

i currently have a complicated setup and i was getting many error like yours and i decide to call the interpreter of the file rather than letting the file do it.

p.s. i also having problems with the ssl at the moment .
i have a local CA and the python refuse to use the Linux trusted CA’s (i have add mine there ). if any one have any suggestions… :slight_smile:

p.s.2 if you want to call the file as an executable you can edit the file and replace the first line with this #!/usr/bin/python3

more info for what this is here scripts - Why does Python in Linux require the line #!/usr/bin/python? - Ask Ubuntu and here python - Purpose of #!/usr/bin/python3 shebang - Stack Overflow

2 Likes