Telegram MotionEye Integration
A stupid little project that takes pictures using a Raspberry Pi Zero
every x minutes (or upon a motion REST request) from a MotionEye OS camera and sends it to a Telegram Group.
...why?
So we can watch guinea pigs without having to completely expose a service or set up wireguard. Important stuff, written one bored afternoon.
How
Run
Easy:
- Acquire guinea pigs, kids, or other things that need watching and make sure they are happy
- Install MotionEye OS on a Raspberry PI and connect a camera; configure it so it sends motion detection is on and "Call a Web Hook" points to the server and port you're running this on (can be the same Raspberry, really)
- Customize the
config/sample.yaml
(see below) - Build and run:
go run *.go serve --config ./config/sample.yaml
Config
You will need a bot
, which you can get by chatting up @BotFather on Telegram.
Next, add that to a chanel.
Use your bot's bot_name
and api_key
from that chat.
Next, fire a request as such:
curl --location --request GET 'https://api.telegram.org/YOUR_BOT_KEY/getUpdates'
And grab the ID of the chanel you've added the bot to.
"my_chat_member": {
"chat": {
"id": INT64_ID,
"title": "ID",
"type": "group",
...
Build & Test
go test ./... -coverprofile coverage.out
go tool cover --html coverage.out
go build *.go
Docker
CONFIG_FILE=$(pwd)/config/sample.yaml
docker build . -t telegram-motioneye
docker run -d \
-p "$(cat $CONFIG_FILE | grep port | cut -d'"' -f2 | xargs)":6060 \
-v $(pwd)/config:/config \
telegram-motioneye \
/app/server serve --config /config/$(basename $CONFIG_FILE)