Skip to content

Instantly share code, notes, and snippets.

@KroniK907
Last active July 1, 2018 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KroniK907/00ebdf3fdd7ec6bf5a3c3fba1968c01c to your computer and use it in GitHub Desktop.
Save KroniK907/00ebdf3fdd7ec6bf5a3c3fba1968c01c to your computer and use it in GitHub Desktop.
Raspberry Pi doorbell scripts
0 5 * * 1 shutdown -r now
import RPi.GPIO as GPIO
import time
import os
import threading
GPIO.setmode(GPIO.BCM)
GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_UP)
t = threading.Timer(10.0, reboot)
s = False
while True:
input_state = GPIO.input(7)
if (input_state == False and s == False):
t.start()
s = True
if (input_state == True and s == True):
s == False
t.cancel()
os.system("/home/pi/doorbell_send.sh")
time.sleep(2)
def reboot():
os.system("sudo shutdown -r now")
#!/bin/bash
DOOR="roof"
SERVER="192.168.1.61"
USER="pi"
SCRIPT="/home/pi/doorbells/doorbell_server.sh"
ssh $USER@$SERVER $SCRIPT $DOOR
exit 0
#!/bin/bash
DOOR=$1
case $DOOR in
ambulance_bay)
aplay /home/pi/doorbells/audio/ambulance_bay.wav
;;
office)
aplay /home/pi/doorbells/audio/office.wav
;;
kitchen)
aplay /home/pi/doorbells/audio/kitchen.wav
;;
sleeping_quarters)
aplay /home/pi/doorbells/audio/sleeping_quarters.wav
;;
turnout_room)
aplay /home/pi/doorbells/audio/turnout_room.wav
;;
aparatus_bay)
aplay /home/pi/doorbells/audio/aparatus_bay.wav
;;
roof)
aplay /home/pi/doorbells/audio/roof.wav
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment