-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* New docker image for noisedetection * Update Dockerfile * Noise detection * noisedetection * noisedetection * noisedetection * notif * notif * notif * notif * notif * notif * notif * notif * notif * notif * update temperature.py * Update temperature.py * Update temperature.py * Notification feature Added a Docker container for notification purpose (based on temperature only for the moment) * Updated INSTALLATION.md Updated the instructions for notification feature configuration * Update INSTALLATION.md Updated the "Notification function" instructions * Changed build instructions for notification container - Based notification image build on the ivadim/fruitnanny image - Changed the way the container will retrieve the temperature.py script (mounted volume instead of a COPY) * Updated restart policy * Added motion sensor to Notification feature - Created a "configuration" file for notification feature - Added "motion detection" to Notification feature (being notified when a motion is detected) * Fixed temperature.py - Fixed the type of temp_min and temp_max variables - Uncommented the loop
- Loading branch information
1 parent
6e1ccd8
commit c894bd3
Showing
6 changed files
with
139 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[NOTIFICATION] | ||
url: http://rpi-nanny.home/ | ||
Pushbullet_API_Key: abcdefgh | ||
|
||
[TEMPERATURE] | ||
temp_min: 20 | ||
temp_max: 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/python | ||
|
||
import time | ||
import board | ||
import digitalio | ||
from pushbullet import Pushbullet | ||
import configparser | ||
|
||
# parsing configuration file | ||
config = configparser.RawConfigParser() | ||
config.read('/opt/fruitnanny/bin/configuration') | ||
|
||
# set up motion sensor | ||
pir_sensor = digitalio.DigitalInOut(board.D23) | ||
pir_sensor.direction = digitalio.Direction.INPUT | ||
|
||
#set up identification and other variables | ||
pb = Pushbullet(config.get('NOTIFICATION','Pushbullet_API_Key')) | ||
monitor_url = config.get('NOTIFICATION','url') | ||
frequence_notification = 1200 | ||
|
||
while True: | ||
try: | ||
message = ("Rpi-Nanny : Motion detected!") | ||
print(pir_sensor.value) | ||
if pir_sensor.value: | ||
print("Motion detected") | ||
push = pb.push_link(message, monitor_url) | ||
time.sleep(frequence_notification) | ||
time.sleep(1) | ||
except RuntimeError as error: | ||
# Errors happen fairly often, DHT's are hard to read, just keep going | ||
print(error.args[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/python | ||
|
||
import time | ||
import adafruit_dht | ||
import board | ||
from pushbullet import Pushbullet | ||
import configparser | ||
|
||
# parsing configuration file | ||
config = configparser.RawConfigParser() | ||
config.read('/opt/fruitnanny/bin/configuration') | ||
|
||
# set up temperature sensor | ||
dhtDevice = adafruit_dht.DHT22(board.D24) | ||
|
||
#set up identification and other variables | ||
pb = Pushbullet(config.get('NOTIFICATION','Pushbullet_API_Key')) | ||
monitor_url = config.get('NOTIFICATION','url') | ||
frequence_notification = 1200 | ||
temp_min = float(config.get('TEMPERATURE','temp_min')) | ||
temp_max = float(config.get('TEMPERATURE','temp_max')) | ||
|
||
#print(temp_min) | ||
#print(temp_max) | ||
|
||
|
||
while True: | ||
try: | ||
# Print the values to the serial port | ||
temperature_c = dhtDevice.temperature | ||
message = ("Rpi-Nanny : {}°C !".format(temperature_c)) | ||
print(message) | ||
if temperature_c > temp_max or temperature_c < temp_min : | ||
#push = pb.push_note("Rpi-Nanny", message) | ||
push = pb.push_link(message, monitor_url) | ||
time.sleep(frequence_notification) | ||
except RuntimeError as error: | ||
# Errors happen fairly often, DHT's are hard to read, just keep going | ||
print(error.args[0]) | ||
|
||
time.sleep(5.0) | ||
|
||
#print(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM ivadim/fruitnanny-app | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y libgpiod2 \ | ||
&& pip3 install adafruit-circuitpython-lis3dh \ | ||
&& pip3 install adafruit-circuitpython-dht \ | ||
&& pip3 install pushbullet.py \ | ||
&& pip3 install configparser \ | ||
&& pip3 install adafruit-blinka \ | ||
&& apt-get --purge remove -y $buildDeps && apt-get --purge -y autoremove \ | ||
&& apt-get clean \ | ||
&& rm -rf /tmp/* \ | ||
&& rm -rf /var/lib/apt/lists/* |