Skip to content
This repository was archived by the owner on Dec 9, 2022. It is now read-only.

Commit 721a645

Browse files
Norbergtekkub
authored andcommitted
updated README and humidityChecker got updated
humidityChecker now have consitency check even when dearlarming and not just when alarming eg. five conistent readings i row is needed to trigger ether of alarma and dealarm
1 parent c2e2509 commit 721a645

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

README

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,14 @@ Where ATTRS{interface} is the same as found with:
1717
sudo udevadm info -a -p /sys/class/tty/ttyUSB0 | grep interface
1818

1919
Then replug the device and /dev/arduino should appear.
20+
21+
22+
HUGE Database:
23+
Over time the database will grow resulting in slower and slower sql queries
24+
therefore its good to sometime clean out old results, eg. only leaving one
25+
value per hour for values more than one month old eg with:
26+
select * from sensors where date < '2010-04-01' and time not like '__:00';
27+
28+
then followed by:
29+
vacuum;
30+
to clean up unused space

humidityChecker.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,20 @@ def main():
7777
while 1:
7878
readings = check()
7979
for name, value in readings.items():
80-
if thresholdGuard[name][1] == -1:
81-
dealarm(name, value)
82-
thresholdGuard[name][1] = 0 #deactive alarm
83-
elif thresholdGuard[name][0] > value:
80+
if thresholdGuard[name][0] < value and \
81+
thresholdGuard[name][1] < 0:
82+
thresholdGuard[name][1] -= 1
83+
print name, value, "detrigged"
84+
elif thresholdGuard[name][0] > value and \
85+
thresholdGuard[name][1] >= 0:
8486
thresholdGuard[name][1] += 1
8587
print name, value, "trigged"
86-
else:
87-
thresholdGuard[name][1] = 0
8888
if thresholdGuard[name][1] >= thresholdLimit:
8989
alarm(name, value)
9090
thresholdGuard[name][1] = -1 #active alarm
91+
elif thresholdGuard[name][1] <= -thresholdLimit:
92+
dealarm(name, value)
93+
thresholdGuard[name][1] = 0 #deactive alarm
9194
print ".",
9295
time.sleep(30) # sleep 30 seconds
9396

0 commit comments

Comments
 (0)