parent
59fcd694b6
commit
f2a9b94cf6
1 changed files with 101 additions and 0 deletions
@ -0,0 +1,101 @@ |
|||||||
|
# Doorbell Ding Dong Ring Ring Doorbell |
||||||
|
|
||||||
|
A doorbell chime controller for my house. Runs on a Raspberry Pi and talks to wifi Unifi G4 Doorbells. |
||||||
|
|
||||||
|
## Setup |
||||||
|
|
||||||
|
### Misc |
||||||
|
|
||||||
|
Set up user account, add user to `sudo`, `adm`, `gpio` groups. |
||||||
|
|
||||||
|
Set up wifi: |
||||||
|
|
||||||
|
```text |
||||||
|
$ sudo raspi-config |
||||||
|
- System Options -> Wireless LAN -> Canada |
||||||
|
- Enter wifi credentials |
||||||
|
- Reboot |
||||||
|
``` |
||||||
|
|
||||||
|
For the watchdog to work, we need write access to `/dev/watchdog/`. |
||||||
|
|
||||||
|
Configure `/etc/udev/rules.d/60-watchdog.rules`: |
||||||
|
|
||||||
|
```text |
||||||
|
KERNEL=="watchdog", MODE="0666" |
||||||
|
``` |
||||||
|
|
||||||
|
### Script |
||||||
|
|
||||||
|
Install dependencies: |
||||||
|
|
||||||
|
```text |
||||||
|
$ sudo apt update |
||||||
|
$ sudo apt install python3 python3-pip python-virtualenv python3-virtualenv supervisor |
||||||
|
``` |
||||||
|
|
||||||
|
**Make sure you have at least Python 3.9 installed.** |
||||||
|
|
||||||
|
Clone this repo: |
||||||
|
|
||||||
|
```text |
||||||
|
$ cd |
||||||
|
$ git clone https://tanner@git.tannercollin.com/tanner/doorbelldingdongringringdoorbell.git |
||||||
|
$ cd doorbelldingdongringringdoorbell/ |
||||||
|
$ virtualenv -p python3 env |
||||||
|
$ source env/bin/activate |
||||||
|
(env) $ pip install -r requirements.txt |
||||||
|
``` |
||||||
|
|
||||||
|
Edit settings for your setup: |
||||||
|
|
||||||
|
```text |
||||||
|
$ cp settings.py.example settings.py |
||||||
|
$ vim settings.py |
||||||
|
``` |
||||||
|
|
||||||
|
Now you can run the script to test: |
||||||
|
|
||||||
|
```text |
||||||
|
$ source env/bin/activate |
||||||
|
(env) $ DEBUG=true python main.py # no watchdog |
||||||
|
(env) $ python main.py # uses watchdog |
||||||
|
``` |
||||||
|
|
||||||
|
The watchdog will activate if a doorbell is pressed. It will reboot the Pi if the script stops. |
||||||
|
|
||||||
|
## Process management |
||||||
|
|
||||||
|
The script is kept alive with [supervisor](https://pypi.org/project/supervisor/). |
||||||
|
|
||||||
|
Configure `/etc/supervisor/conf.d/doorbell.conf`: |
||||||
|
|
||||||
|
```text |
||||||
|
[program:doorbell] |
||||||
|
user=tanner |
||||||
|
directory=/home/tanner/doorbelldingdongringringdoorbell |
||||||
|
command=/home/tanner/doorbelldingdongringringdoorbell/env/bin/python -u main.py |
||||||
|
stopasgroup=true |
||||||
|
stopsignal=INT |
||||||
|
autostart=true |
||||||
|
autorestart=true |
||||||
|
stderr_logfile=/var/log/doorbell.log |
||||||
|
stderr_logfile_maxbytes=10MB |
||||||
|
stdout_logfile=/var/log/doorbell.log |
||||||
|
stdout_logfile_maxbytes=10MB |
||||||
|
``` |
||||||
|
|
||||||
|
Then run: |
||||||
|
|
||||||
|
```text |
||||||
|
$ sudo supervisorctl reread; sudo supervisorctl reload |
||||||
|
``` |
||||||
|
|
||||||
|
Script logs to /var/log/doorbell.log. Remove `-u` from the above command when you're done testing to save SD card writes. |
||||||
|
|
||||||
|
## License |
||||||
|
|
||||||
|
This program is free and open-source software licensed under the MIT License. Please see the `LICENSE` file for details. |
||||||
|
|
||||||
|
That means you have the right to study, change, and distribute the software and source code to anyone and for any purpose. You deserve these rights. |
||||||
|
|
Loading…
Reference in new issue