-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Notification function #24
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
80b05c9
New docker image for noisedetection
jeremyfritzen 8887c41
Update Dockerfile
jeremyfritzen 93ce976
Noise detection
jeremyfritzen 72b016a
noisedetection
jeremyfritzen fcc2a69
noisedetection
jeremyfritzen eb4ce5e
noisedetection
jeremyfritzen c27da8f
notif
jeremyfritzen b9855a6
notif
jeremyfritzen 3830fcc
notif
jeremyfritzen 217e403
notif
jeremyfritzen 27906e6
notif
jeremyfritzen 0c85473
notif
jeremyfritzen e00c4bf
notif
jeremyfritzen 6db904a
notif
jeremyfritzen bd6847c
notif
jeremyfritzen e7e717e
notif
jeremyfritzen 9ae5cb8
update temperature.py
jeremyfritzen ff7a4e4
Update temperature.py
jeremyfritzen 8ac965e
Update temperature.py
jeremyfritzen 231a004
Notification feature
jeremyfritzen 5e2e9c6
Updated INSTALLATION.md
jeremyfritzen eb11995
Update INSTALLATION.md
jeremyfritzen bff306c
Changed build instructions for notification container
jeremyfritzen 094a271
Updated restart policy
jeremyfritzen 3794989
Added motion sensor to Notification feature
jeremyfritzen b9ee637
Fixed temperature.py
jeremyfritzen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/* |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason to set restart to "no"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's actually a mistake, sorry.
I changed it for my tests because I didn't want containers to be restarted after a RPi reboot.