Github repo: Link
What does it do?
- Senses when your door was opened
- Sends a chat message in a rocket chat channel of your coice (own servers supported)
- Tells you how long the door was opened
- Tells you how much time has passed since the door was last closed so you know how long you were out or in
Requirements
- Raspberry Pi
- Reed Switch
- 1x 10k ohm resistor
- Channel ID of the channel your bot is going to post the message
Build it yourself - It's pretty easy
Step 1: Connect the Reed switch to the Raspberry Pi
Connect the reed switch acording to these schematics:
The reed switch is activated by a magnet. You can glue the magnet to the door and put the sensor on the frame like this:
The reed switch only lets through the current when the magnet is close. If the door opens, the script will detect that and send a chat message
You don't need a bread board or something like that, you can just solder the resistor to the reed switch directly and connect it to the Pi. The resistor is under the black shrink tube:
Step 2: Install php and the "gpio" command
apt-get install wiringpi php5-cli
echo 'w1-gpio' >> /etc/modules
modprobe w1-gpio
Step 3: Get the script
wget https://raw.githubusercontent.com/geek-at/raspberry_doorbot/master/door_chatbot.php
Step 4:
Edit the settings in the door_chatbot.php
file and add your channel, server and login credentials
Final step: Run script on startup
crontab -e
insert this at the end of the crontab
@reboot php /path/to/your/door_chatbot.php >> /var/log/doorbot.log
And then start once (or reboot)
nohup php /path/to/your/door_chatbot.php >> /var/log/doorbot.log &
Should be working now
Things to consider
- You can enable notifications on that bot channel so you get notified when your door is opened
- Don't let your bot post on public channels or you might just make the front page on PleaseRobMe
- Make a private channel
- If you host your own rocket.chat instance, use HTTPS. It's free with let'sencrypt
Comment using SSH! Info