Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
fix notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
jangevaare committed Mar 10, 2018
1 parent da3c3d2 commit 7e6396d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_temp(address):
class OneWireAdvanced(SensorActive):
a_address = Property.Select("Sensor address", get_sensors())
b_bias = Property.Number("Sensor bias", True, 0.0)
c_update_interval = Property.Number("Update interval", True, 2.0)
c_update_interval = Property.Number("Update interval", True, 2.5)
d_low_filter = Property.Number("Low value filter threshold", True, 0.0)
e_high_filter = Property.Number("High value filter threshold", True, 100.0)
g_alert = Property.Select("Alert when values filtered?", ["True", "False"])
Expand All @@ -50,10 +50,10 @@ def execute(self):

# Error checking
if update_interval <= 0.0:
self.notify("OneWire Error", "Update interval must be positive", timeout=None, type="danger")
cbpi.notify("OneWire Error", "Update interval must be positive", timeout=None, type="danger")
raise ValueError("OneWire - Update interval must be positive")
elif low_filter >= high_filter:
self.notify("OneWire Error", "Low filter must be < high filter")
cbpi.notify("OneWire Error", "Low filter must be < high filter")
raise ValueError("OneWire - Low filter must be < high filter")
else:
while self.is_running():
Expand All @@ -67,12 +67,12 @@ def execute(self):
if low_filter < temp < high_filter:
self.data_received(temp)
elif alert:
self.notify("OneWire Warning", "%s reading of %s filtered" % (address, temp), time=update_interval*5, type="warning")
cbpi.notify("OneWire Warning", "%s reading of %s filtered" % (address, temp), time=update_interval*5, type="warning")
print("[%s] %s reading of %s filtered" % (waketime, address, temp))

# Sleep until update required again
if waketime <= time.time() + 0.25:
self.notify("OneWire Error", "Update interval is too short", timeout=None, type="danger")
cbpi.notify("OneWire Error", "Update interval is too short", timeout=None, type="danger")
raise ValueError("OneWire - Update interval is too short")
else:
self.sleep(waketime - time.time())

0 comments on commit 7e6396d

Please sign in to comment.