Button + Telegram

A project log for Smart Intercom

Real-Time system that allow to pass only authorized/invited people, using Face-Recognition or NFC cards.

EvgheniiEvghenii 08/01/2017 at 07:040 Comments
import RPi.GPIO as GPIO
from subprocess import call
from datetime import datetime
import time
import os
shutdownPin = 29
shutdownMinSeconds = 5
debounceSeconds = 0.01
GPIO.setup(shutdownPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
buttonPressedTime = None
def buttonStateChanged(pin):
    global buttonPressedTime
    if not (GPIO.input(pin)):
        if buttonPressedTime is None:
            buttonPressedTime =
        if buttonPressedTime is not None:
            elapsed = ( - buttonPressedTime).total_seconds()
            buttonPressedTime = None
            if elapsed >= shutdownMinSeconds:
                call(['shutdown', '-r', 'now'], shell=True)
            elif elapsed >= debounceSeconds:
		os.system("sh /home/pi/ FaceRec /var/www/html/last.jpg > log.out 2> /dev/null")
                os.system("sshpass -p password ssh root@ -p1337 notify-send -i /usr/share/icons/gnome/32x32/actions/ring2.png Smart-Intercom Guest_at_the_door")        
GPIO.add_event_detect(shutdownPin, GPIO.BOTH, callback=buttonStateChanged)
while True:

Added pushbutton to Smart Intercom.

It sends you last photo to telegram bot and sends notification to Ubuntu Desktop PC.