Telegram chat-bot for HA control and notifications

I think this can be interesting project - I have made a chat-bot to control HA and check different information via Telegram. What it currently does:

  • turns off or on the water inlet valve on button press (if I need to) and also checks valve state and water leak sensor state
  • checks air quality, temperature, and radiation level and different devices status (media system, NAS, PC, UPS voltage and status, etc.) when I ask for information
  • on button press, makes a snapshot from the door camera and sends it to me.
  • informs me about automatic water turn off and on when everybody leaves the house or someone comes back, sends me notifications about plant watering, electricity shut off or water leak, air quality, and other important events.

How I configured everything:

  1. I created telegram chatbot via standard Telegram tools (bot father)
  2. I set up Home Assistant to send notifications via this chat-bot using “broadcast” platform on different automation and important events
    configuration.yaml:
telegram_bot:
  - platform: broadcast
    api_key: <your chat-bot API key from Bot Father>
    allowed_chat_ids:
      - <your chatID>
notify:
  - name: leha
    platform: telegram
    chat_id: <your chatID>

  1. I did not want to allow access to my HA from external internet but I needed access to HA API for chat-bot to work, so:
  • I set up the Nginx Proxy Manager add-on in Hass.io.
  • I set up DDNS on my Asus router and configured port forwarding to Nginx proxy manager IP and port.
  • In Nginx Proxy Manager I configured access to /api/ only with the use of SSL
  1. Then I created a chat-bot on pipe.bot platform (free account). It uses API to get information from HA and to send commands to turn on and off things.
  2. In the chatbot, I’ve created the “settings” menu where you can set and store API token as a user variable, you can get API token from “profile” menu (Long-Lived Access Token)

Here is the result:
16102019140645

I’ve created an English example “map” for https://pipe.bot/ chatbot platform for Home Assistant, it is here:
https://coggle.it/diagram/XabkxrS0BqnzJ5Tz/t/🏠-ha-bot-example
To use it you have to create chat-bot, chat with it once to get sys.uid variable of your chat so you can set it to work only with you, so nobody else can access it, and change entity names and hostname.

Sorry for not very good English, there can be lots of mistakes in this post and in the translated example “map” :slight_smile:

I will try to answer any questions about this project.

1 Like