SkillAgentSearch skills...

OpenSesamePi

Get notified any time your door is opened or closed: connect a reed switch to your door, wire the leads into the Raspberry Pi's' GPIO pins to complete the circuit, and get email alerts.

Install / Use

/learn @Banrai/OpenSesamePi
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

OpenSesamePi

About

Get notified any time your door is opened and closed.

Connect a reed switch to your door, wire the leads into the Raspberry Pi's' GPIO pins to complete the circuit, and get email alerts.

Installation

Physical

  1. Create a circuit connecting the reed switch leads to the Pi's GPIO pins

In addition to the switch itself, you will need a single 330 ohm resistor, as shown here:

![Circuit schematic](schematic/RPi Reed Switch.png?raw=true "Circuit schematic")

Be sure to look at the [interactive schematic](schematic/RPi Reed Switch.fzz) using the Fritzing desktop application.

Breadboard test

Test on a breadboard before soldering things together.

  1. Install the reed switch on the door (make sure the door opens cleanly with the switch in place)

Reed switch on door

  1. Final assembly, with resistor connected and plugged in to the GPIO pins on the Pi:

Final assembly

In addition to running OpenSesamePi, this particular Pi is doing double duty as a PiScan implementation.

Software

  1. Login to the Pi and install this Software:
git clone git@github.com:Banrai/OpenSesamePi.git
  1. Configure the Pi to send email:
sudo apt-get update
sudo apt-get -y install ssmtp mailutils

Then edit the <tt>SSMTP</tt> configuration file:

sudo vi /etc/ssmtp/ssmtp.conf

You need these lines defined at a minimum, replacing the gmail coordinates with your own (you can of course use any other SMTP mailserver of your choice):

root=postmaster
mailhub=smtp.gmail.com:587
hostname=raspberrypi
AuthUser=YourGMailUserName@gmail.com
AuthPass=YourGMailPassword
UseSTARTTLS=YES

<i>Note:</i> if you do use gmail, you will also need to update the Allow less secure apps setting for this method to work.

  1. Define the list of email addresses that should get the opened/closed alerts

Create a new file called <tt>local_settings.py</tt> in the same folder where you cloned this repo (by default, it will be the <tt>/home/pi/OpenSesamePi/</tt> folder), add a line like this, and save the file:

NOTIFY_LIST = ['me@myemail.com', 'myroommate@theiremail.com']

Each of the email addresses defined here will get an email alert when the DoorChecker script is triggered.

This file overrides the <tt>NOTIFY_LIST</tt> defined in the generic settings.py file.

  1. Have the DoorChecker script start automatically, every time the Pi does:
sudo crontab -e

Then add this line at the bottom, and save the file:

@reboot python /home/pi/OpenSesamePi/DoorChecker.py &

Extensibility

At the moment, the DoorChecker script's notification action is to send email, but that can be extended to triggering an alarm, taking a camera snapshot, etc.

Just change the implementation of the notify(door_state) function to something more elaborate.

Acknowledgements

View on GitHub
GitHub Stars8
CategoryDevelopment
Updated2y ago
Forks3

Languages

Python

Security Score

55/100

Audited on Sep 12, 2023

No findings