Thomas Angielsky
Published © GPL3+

Telekom T-Concept X311 with Doorline at Raspberry

My 15-year-old T-Concept with door intercom is pretty far away from a smart solution. But with a Raspberry Pi it’s possible to pimp it up.

BeginnerFull instructions provided4 hours1,263
Telekom T-Concept X311 with Doorline at Raspberry

Things used in this project

Story

Read more

Code

smartgpio.py

Python
This is only an example. Add this lines in your own smarthome program.
#!/usr/bin/python
# coding=utf-8

 

import time
import datetime
import RPi.GPIO as GPIO
import smtplib,sys
import os
from os.path import basename
from email.header import Header
from email.mime.application import MIMEApplication
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

import picamera
import shutil

# pin setup, as GPIO numbers
pinKlingel=16      #pin16

GPIO.setwarnings(False)

GPIO.setmode(GPIO.BCM)

GPIO.setup(pinKlingel,GPIO.IN)

# procedures

def MailVersenden(betreff,txt):
    try:
        sfrom='Smarthome '
        sto='Thomas Angielsky' 
        msg = MIMEText(txt,'plain','utf-8')
        msg['From']=sfrom
        msg['To']=sto
        msg['From']=sfrom
        msg['subject']=Header(betreff,'utf-8')
        smtp=smtplib.SMTP('smtp.1und1.de')
        smtp.starttls()
        smtp.login('your@emailadress.com','your password')
        smtp.sendmail(sfrom,[sto],msg.as_string())
        smtp.quit()
    except:
        print('Error sending mail')

 

def MailVersendenMitFoto(betreff,txt):
    try:
        sfrom='Smarthome <name@mailadresse.de>'
        sto='Thomas Angielsky <name@mailadresse.de>'
        #Path to picture of the Picamera
        sfn='/home/pi/smarthome/bild.jpg'
        #create mail body
        stxt=txt+'\nTime: '+zeit.strftime('%d.%m.%Y %H:%M:%S')
        stxt=stxt+'\n\nPicture:'
        mime=MIMEMultipart()
        mime['from']=sfrom
        mime['to']=sto
        mime['subject']=Header(betreff,'utf-8')
        mime.attach(MIMEText(stxt,'plain','utf-8'))
        f=open(sfn,'rb')
        part=MIMEApplication(f.read(),Name=basename(sfn))
        f.close()
        part['Content-Disposition']='attachment' 
        filename='"'+basename(sfn)+'"'
        mime.attach(part)
        #SMTP server
        smtp=smtplib.SMTP('smtp.mailadresse.de')
        smtp.starttls()
        smtp.login('name@mailadresse','kenntwort')
        #Mail senden
        smtp.sendmail(sfrom,[sto],mime.as_string())
        smtp.quit()
    except:
        print('Error sending mail')
 



 

# main program

print("wait for signals...")
pressed16=False

try:

    while True:

        time.sleep(0.2)

        if GPIO.input(16)==False:
            #signal recognized, maybe a interference
            if pressed16==False:
               #new signal recognized 
               pressed16=True
               print("Signal at pin 16")
               #save timestamp
               time16=datetime.datetime.now()
            else:
                #lasts signal longer then 1 seconds?
                if datetime.datetime.now()-time16>datetime.timedelta(milliseconds=1000):
                    print("Door bell signal")
                    #further steps after door bell ring
                    time16=datetime.datetime.now()
                    pressed16=False

 

except KeyboardInterrupt:

      GPIO.cleanup()

      sys.exit()

Credits

Thomas Angielsky

Thomas Angielsky

18 projects • 36 followers
Mechanical engineer, maker, love woodwork, like Lazarus

Comments