motion2telegram


Namemotion2telegram JSON
Version 1.2.0 PyPI version JSON
download
home_pageNone
SummaryNotify a Telegram user when the motion service detects motion
upload_time2024-06-20 11:51:15
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8.10
licenseNone
keywords motion python telegram motion-detection webcam raspberry-pi
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # motion2telegram

> Motion is a program that monitors the video signal from one or more cameras and is able to detect if a significant part of the picture has changed. I.e., it can detect motion.

Setup a Raspberry Pi with motion2telegram to

- send a picture to a Telegram user/group if motion is detected
- activate/deactivate motion detection by scanning for the prescence of your mobile phone(s) using bluetooth

Use motion2telegram to apply a pre-configured set of motion and systemd service configuration files and Python scripts to
setup your Raspberry Pi.

## Stack

- Raspberry Pi
    - 1 B+
    - 4 B
    - Zero W V1.1
- Raspberry Pi OS
    - Lite (32-bit) (Port of Debian Bookworm)
    - Lite (64-bit)
- Python 3.11.2
- Motion 4.5.1
- Logitech C270 HD WEBCAM

## Prerequisites

- A Raspberry Pi setup with a working network configuration and connected to the internet
- The Linux BlueZ Bluetooth stack
    - Installed by default in the latest Raspberry Pi OS
- [Motion](https://motion-project.github.io/motion_build.html) installed
- A [Telegram](https://telegram.org/) account
- A Telegram [bot token](https://core.telegram.org/bots/tutorial#obtain-your-bot-token)
- The bluetooth MAC address(es) of your mobile phone(s)
- Bluetooth enabled on your mobile phone(s)
- A user on Raspberry Pi OS to run the motion service. motion2telegram installation and motion service configuration is done in the context of this user. The user MUST be a member of the groups _motion_ and _video_
- A Python virtual environment

## Install with pip

Login with the user created to run the motion service. Create a directory, e.g. motion2telegram, and cd into it. From here on, you'll work in this directory. Create and activate a Python virtual environment and then

```bash
(venv) $ pip install motion2telegram
...
# Verify by version
(venv) $ motion2telegram -V
x.y.z
(venv) $
```

## Configuration

Create a `motion.env` file with the following command.

```bash
(venv) $ motion2telegram --init
```

This file is used by

- the motion service to retrieve
    - the Telegram bot token and
    - the recipient's chat id.
- the mobile phone scanner to retrieve 
    - bluetooth MAC address(es) and
    - the scan interval

Specify your Telegram chat id and bot token in the file `motion.env`

```bash
# motion.env
TELEGRAM_BOT_TOKEN=
TELEGRAM_CHAT_ID=
```

Specify the bluetooth MAC address(es) and time between scans in `motion.env`

```bash
BLUETOOTH_ADDRESSES_PHONES=
MOBILE_PHONE_SCAN_INTERVAL=300
```

Configure motion with

```bash
(venv) $ motion2telegram --configure
```

This will install preconfigured files using the environment variables set in `motion.env` and references to Python scripts to run.

- `/etc/motion/motion.conf`
- `/lib/systemd/system/motion.service.` and
- `/lib/systemd/system/mobile_phone_scan.service`

Motion is configured to write
- logs into `log/motion.log` and
- media files into `media/YYYYMMDD`

relative to the current directory. Media captured on the same date are grouped together in a `YYYYMMDD` directory.

The motion and mobile_phone_scan systemd services will reference the `motion.env` file in the current directory for the chat id, bot token, bluetooth MAC address(es) and scan interval. The command will stop, configure and bring the motion and mobile_phone_scan service back up. If you need it, motion's process-id is written to motion.pid in the directory you installed motion2telegram.

## Reference

- [Motion](https://motion-project.github.io/)
- [Telegram](https://telegram.org/)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "motion2telegram",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8.10",
    "maintainer_email": null,
    "keywords": "motion, python, telegram, motion-detection, webcam, raspberry-pi",
    "author": null,
    "author_email": "p4irin <p4irin.github.io@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/cb/f1/5763daf12c6fe20023f5112f54c9f0918321b9f9fed0ddab61d9df6a20e7/motion2telegram-1.2.0.tar.gz",
    "platform": null,
    "description": "# motion2telegram\n\n> Motion is a program that monitors the video signal from one or more cameras and is able to detect if a significant part of the picture has changed. I.e., it can detect motion.\n\nSetup a Raspberry Pi with motion2telegram to\n\n- send a picture to a Telegram user/group if motion is detected\n- activate/deactivate motion detection by scanning for the prescence of your mobile phone(s) using bluetooth\n\nUse motion2telegram to apply a pre-configured set of motion and systemd service configuration files and Python scripts to\nsetup your Raspberry Pi.\n\n## Stack\n\n- Raspberry Pi\n    - 1 B+\n    - 4 B\n    - Zero W V1.1\n- Raspberry Pi OS\n    - Lite (32-bit) (Port of Debian Bookworm)\n    - Lite (64-bit)\n- Python 3.11.2\n- Motion 4.5.1\n- Logitech C270 HD WEBCAM\n\n## Prerequisites\n\n- A Raspberry Pi setup with a working network configuration and connected to the internet\n- The Linux BlueZ Bluetooth stack\n    - Installed by default in the latest Raspberry Pi OS\n- [Motion](https://motion-project.github.io/motion_build.html) installed\n- A [Telegram](https://telegram.org/) account\n- A Telegram [bot token](https://core.telegram.org/bots/tutorial#obtain-your-bot-token)\n- The bluetooth MAC address(es) of your mobile phone(s)\n- Bluetooth enabled on your mobile phone(s)\n- A user on Raspberry Pi OS to run the motion service. motion2telegram installation and motion service configuration is done in the context of this user. The user MUST be a member of the groups _motion_ and _video_\n- A Python virtual environment\n\n## Install with pip\n\nLogin with the user created to run the motion service. Create a directory, e.g. motion2telegram, and cd into it. From here on, you'll work in this directory. Create and activate a Python virtual environment and then\n\n```bash\n(venv) $ pip install motion2telegram\n...\n# Verify by version\n(venv) $ motion2telegram -V\nx.y.z\n(venv) $\n```\n\n## Configuration\n\nCreate a `motion.env` file with the following command.\n\n```bash\n(venv) $ motion2telegram --init\n```\n\nThis file is used by\n\n- the motion service to retrieve\n    - the Telegram bot token and\n    - the recipient's chat id.\n- the mobile phone scanner to retrieve \n    - bluetooth MAC address(es) and\n    - the scan interval\n\nSpecify your Telegram chat id and bot token in the file `motion.env`\n\n```bash\n# motion.env\nTELEGRAM_BOT_TOKEN=\nTELEGRAM_CHAT_ID=\n```\n\nSpecify the bluetooth MAC address(es) and time between scans in `motion.env`\n\n```bash\nBLUETOOTH_ADDRESSES_PHONES=\nMOBILE_PHONE_SCAN_INTERVAL=300\n```\n\nConfigure motion with\n\n```bash\n(venv) $ motion2telegram --configure\n```\n\nThis will install preconfigured files using the environment variables set in `motion.env` and references to Python scripts to run.\n\n- `/etc/motion/motion.conf`\n- `/lib/systemd/system/motion.service.` and\n- `/lib/systemd/system/mobile_phone_scan.service`\n\nMotion is configured to write\n- logs into `log/motion.log` and\n- media files into `media/YYYYMMDD`\n\nrelative to the current directory. Media captured on the same date are grouped together in a `YYYYMMDD` directory.\n\nThe motion and mobile_phone_scan systemd services will reference the `motion.env` file in the current directory for the chat id, bot token, bluetooth MAC address(es) and scan interval. The command will stop, configure and bring the motion and mobile_phone_scan service back up. If you need it, motion's process-id is written to motion.pid in the directory you installed motion2telegram.\n\n## Reference\n\n- [Motion](https://motion-project.github.io/)\n- [Telegram](https://telegram.org/)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Notify a Telegram user when the motion service detects motion",
    "version": "1.2.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/p4irin/motion2telegram/issues",
        "Homepage": "https://github.com/p4irin/motion2telegram"
    },
    "split_keywords": [
        "motion",
        " python",
        " telegram",
        " motion-detection",
        " webcam",
        " raspberry-pi"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ffafe8fc1217aeab14b2596cf34fba5bc8bfccfc5b3afbe090f96fb596e8957d",
                "md5": "2f72be5251a2fb2aa019fcc2e317a8d2",
                "sha256": "2827acd910b2f0cae2d65b4b24d2f82b1aee6a54d17250ad724a05cabedc5a36"
            },
            "downloads": -1,
            "filename": "motion2telegram-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2f72be5251a2fb2aa019fcc2e317a8d2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.10",
            "size": 9612,
            "upload_time": "2024-06-20T11:51:12",
            "upload_time_iso_8601": "2024-06-20T11:51:12.758517Z",
            "url": "https://files.pythonhosted.org/packages/ff/af/e8fc1217aeab14b2596cf34fba5bc8bfccfc5b3afbe090f96fb596e8957d/motion2telegram-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cbf15763daf12c6fe20023f5112f54c9f0918321b9f9fed0ddab61d9df6a20e7",
                "md5": "fceadbf913dbf15a46fa65b3dab209f6",
                "sha256": "f4c79f07f4dbd714a9ca33a7df30c0f8f7ac0eb099eec8b87941b9aa803cc1f7"
            },
            "downloads": -1,
            "filename": "motion2telegram-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "fceadbf913dbf15a46fa65b3dab209f6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.10",
            "size": 10059,
            "upload_time": "2024-06-20T11:51:15",
            "upload_time_iso_8601": "2024-06-20T11:51:15.061156Z",
            "url": "https://files.pythonhosted.org/packages/cb/f1/5763daf12c6fe20023f5112f54c9f0918321b9f9fed0ddab61d9df6a20e7/motion2telegram-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-20 11:51:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "p4irin",
    "github_project": "motion2telegram",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "motion2telegram"
}
        
Elapsed time: 0.31629s