i try to send the image from a usb webcam to a telegram group if motion is detected. the motion works, but i cant get it to send it to my group. so im working on to send a text instead. (with the picture i can figure out, but first i need to get the text working)
code:
import RPi.GPIO as GPIO
import time
from telethon import TelegramClient
SENSOR_PIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(SENSOR_PIN, GPIO.IN)
#Telegram settings
api_id='xxxxx'
api_hash='xxxxx'
phone='xxxx'
#Kamera Gruppe
chatid = -xxxxx
client = TelegramClient(phone, api_id, api_hash)
async def mein_callback(channel):
print('motion detected!')
await client.send_message(chatid, 'motion detected')
try:
GPIO.add_event_detect(SENSOR_PIN , GPIO.RISING, callback=mein_callback)
while True:
time.sleep(100)
except KeyboardInterrupt:
print ("Beende...")
GPIO.cleanup()
error:
sys:1: RuntimeWarning: coroutine 'mein_callback' was never awaited RuntimeWarning: Enable tracemalloc to get the object allocation traceback