Compare commits
5 Commits
4cc057ea57
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 6a52a4ccb2 | |||
| 5dc4800ff4 | |||
| 3ea64ca768 | |||
| 1e87df0b7a | |||
| 7d5d68e29c |
@@ -2,8 +2,70 @@
|
|||||||
|
|
||||||
This script plays a fake dog bark through speakers to scare people away from your house.
|
This script plays a fake dog bark through speakers to scare people away from your house.
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
Set up the Pi:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo usermod -aG audio tanner
|
||||||
|
$ sudo apt update
|
||||||
|
$ sudo apt install python3 python3-pip python3-virtualenv libsdl2-mixer-2.0-0 supervisor
|
||||||
|
$ sudo bash -c 'echo 0 > /proc/sys/kernel/hung_task_timeout_secs'
|
||||||
|
```
|
||||||
|
|
||||||
|
Edit /etc/pulse/daemon.conf:
|
||||||
|
|
||||||
|
```text
|
||||||
|
default-fragments = 5
|
||||||
|
default-fragment-size-msec = 2
|
||||||
|
```
|
||||||
|
|
||||||
|
Install woof:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ git clone https://git.tannercollin.com/tanner/woof.git
|
||||||
|
$ cd woof/
|
||||||
|
$ virtualenv -p python3 env
|
||||||
|
$ . env/bin/activate
|
||||||
|
(env) $ pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
Run manually to test it:
|
||||||
|
```
|
||||||
|
$ . env/bin/activate
|
||||||
|
(env) $ python main.py
|
||||||
|
```
|
||||||
|
|
||||||
|
Ignore "(snd_pcm_recover) underrun occurred" errors.
|
||||||
|
|
||||||
|
To start automatically, create `/etc/supervisor/conf.d/woof.conf`:
|
||||||
|
|
||||||
|
```
|
||||||
|
[program:woof]
|
||||||
|
user=tanner
|
||||||
|
directory=/home/tanner/woof
|
||||||
|
command=/home/tanner/woof/env/bin/python -u main.py
|
||||||
|
stopasgroup=true
|
||||||
|
stopsignal=INT
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stderr_logfile=/dev/null
|
||||||
|
#stderr_logfile_maxbytes=10MB
|
||||||
|
stdout_logfile=/var/log/woof.log
|
||||||
|
stdout_logfile_maxbytes=10MB
|
||||||
|
```
|
||||||
|
|
||||||
|
Apply changes:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo supervisorctl reread; sudo supervisorctl reload
|
||||||
|
$ sudo supervisorctl status
|
||||||
|
$ tail -f /var/log/woof.log
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This program is free and open-source software licensed under the GNU Affero General Public License. Please see the `LICENSE` file for details.
|
This program is free and open-source software licensed under the GNU Affero General Public 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.
|
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.
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ async def play_sound(filename):
|
|||||||
|
|
||||||
async def barkbark(sound):
|
async def barkbark(sound):
|
||||||
global COOLDOWN
|
global COOLDOWN
|
||||||
if time.time() - COOLDOWN < 15.0:
|
if time.time() - COOLDOWN < 20.0:
|
||||||
logging.info('Cooldown skipping.')
|
logging.info('Cooldown skipping.')
|
||||||
return
|
return
|
||||||
COOLDOWN = time.time()
|
COOLDOWN = time.time()
|
||||||
@@ -84,7 +84,7 @@ async def process_mqtt(message):
|
|||||||
|
|
||||||
async def fetch_mqtt():
|
async def fetch_mqtt():
|
||||||
await asyncio.sleep(3)
|
await asyncio.sleep(3)
|
||||||
async with Client('192.168.0.100') as client:
|
async with Client('192.168.0.106') as client:
|
||||||
async with client.filtered_messages('iot/cameras') as messages:
|
async with client.filtered_messages('iot/cameras') as messages:
|
||||||
await client.subscribe('#')
|
await client.subscribe('#')
|
||||||
async for message in messages:
|
async for message in messages:
|
||||||
|
|||||||
Reference in New Issue
Block a user