YI Hack Telegram Bot - MQTT notifications and Web Services

alt text

Table of Contents

Features

  • Authentication
    • User Authentication based on telegram unique username
    • Administrator access logs push
  • Authorization
    • Access Control List on single cameras for single user
  • MQTT
    • Notifications
      • Realtime motion detection images from MQTT
      • Realtime sound detection
      • Status notification
      • Baby crying notification
    • Switch MQTT messages on and off
  • Snapshot
    • Ask for last snapshot from cameras
  • Video
    • Ask for n-th last video from cameras
  • Audio
    • Text to Speech to cameras
    • Send Audio to cameras
  • Switch
    • Switch entities, like shelly relays

Features screenshots

  • Authentication

  • Authorization

    alt text

  • MQTT

    alt text

  • Snapshot

    alt text

  • Video

    alt text alt text

  • Audio

    alt text

Prerequisites

YI Cameras (Optional)

Install correct YI-Hack firmware for your camera:

Docker (Optional)

Install:

  • Docker
  • Docker compose

Broker MQTT (Optional)

  • Needed for motion detection images and messages

Bot Creation

  1. Create a Telegram Bot with BotFather
  2. Write down Token
  3. Copy commands from botCommands.txt and paste on BotFather commands for your bot

Installation

Preparing configuration

  • Create a config.yaml. See config-example.yaml
  • Bot mode of operation, choose one of:
    • (DEFAULT) Polling bot: The bot will ask to Telegram servers if there are new updates. No port to open
    • WebHook: The bot act in a passive way, very performant, but need to open port and generate certificates
      • uncomment telegram_bot.start_web_hook() in main.py
      • open port 88 on router.
      • Create a cert.pem and private.key with openssl. Place them in top folder. See WebHook guide

Docker Install (Recommended)

Very simple

docker-compose up -d --build   

Manual python Install

  1. Install python
  2. Create a virtual environment
  3. Install python modules
  pip3 install -r requirements.txt
  1. Run main.py
  (venv) python main.py

Performance

Bot performance depends on camera availability and MQTT delay.

Supported Devices

Services

  • MQTT: all devices with MQTT support
  • REST API: all devices with REST API support

Supported Cameras

All MQTT and REST API cameras.

Tested Models

  • YIHacks: cameras supported by Yi-Hack projects
  • Reolink: cameras with Rest API by Reolink

Supported Switches

All MQTT and REST API switches.

Tested Models

  • Shelly: relays

Donation

Donation