diff --git a/HTML/Alerts.html b/HTML/Alerts.html
new file mode 100644
index 0000000..2971cab
--- /dev/null
+++ b/HTML/Alerts.html
@@ -0,0 +1 @@
+Alerts
diff --git a/HTML/Configuration.html b/HTML/Configuration.html
new file mode 100644
index 0000000..dd8c5b3
--- /dev/null
+++ b/HTML/Configuration.html
@@ -0,0 +1,50 @@
+
+
+
diff --git a/HTML/NodeDetailHeader.html b/HTML/NodeDetailHeader.html
new file mode 100644
index 0000000..81fe159
--- /dev/null
+++ b/HTML/NodeDetailHeader.html
@@ -0,0 +1,15 @@
+
+
+
<%= node.vanityname %>
+
+
+ <% if(channels["flowmonitor.run_status"].value === 1) {%>
+ Running
+ <% } else { %>
+ Stopped
+ <% } %>
+
+
+
diff --git a/HTML/Overview.html b/HTML/Overview.html
new file mode 100644
index 0000000..6e95f8b
--- /dev/null
+++ b/HTML/Overview.html
@@ -0,0 +1,157 @@
+
+
+
GPM Flow
+
+
+
+
+
+ <%= channels["flowmonitor.gpm_flow"].timestamp %>
+
+
+
+
+
+
BPD Flow
+
+
+
+
+
+ <%= channels["flowmonitor.bpd_flow"].timestamp %>
+
+
+
+
+
+
Gallons Today
+
+
+
+
+
+ <%= channels["flowmonitor.gal_total"].timestamp %>
+
+
+
+
+
+
Gallons Yesterday
+
+
+
+
+
+ <%= channels["flowmonitor.gal_total_yesterday"].timestamp %>
+
+
+
+
+
+
Barrels Today
+
+
+
+
+
+ <%= channels["flowmonitor.bbl_total"].timestamp %>
+
+
+
+
+
+
Barrels Yesterday
+
+
+
+
+
+ <%= channels["flowmonitor.bbl_total_yesterday"].timestamp %>
+
+
+
+
diff --git a/HTML/Trends.html b/HTML/Trends.html
new file mode 100644
index 0000000..615982e
--- /dev/null
+++ b/HTML/Trends.html
@@ -0,0 +1,49 @@
+
+
+
+
+
diff --git a/flow-monitor.py b/flow-monitor.py
index 90f428c..3d7ceeb 100644
--- a/flow-monitor.py
+++ b/flow-monitor.py
@@ -74,10 +74,8 @@ class start(threading.Thread, deviceBase):
"""Register the driver."""
self.channels["status"]["last_value"] = ""
-
def run(self):
"""Run the driver."""
-
# Configuration Parameters
total_time_store_delta = 60 # seconds
flow_time_store_delta = 60 # seconds
@@ -98,6 +96,8 @@ class start(threading.Thread, deviceBase):
runstatus_ch = Channel('run_status', 0.5, 600)
+ date_reset = False
+
last_measured_timestamp = time.time()
conn = sqlite3.connect('/root/python_firmware/drivers/flow-monitor.db')
c = conn.cursor()
@@ -165,6 +165,19 @@ class start(threading.Thread, deviceBase):
self.sendtodb(runstatus_ch.meshify_name, din1_val, 0)
runstatus_ch.update(din1_val, now)
+ if time.localtime(now)[3] == 0 and not date_reset:
+ self.sendtodb('gal_total_yesterday', gal_totalizer_value, 0)
+ self.sendtodb('bbl_total_yesterday', bbl_totalizer_value, 0)
+ gal_totalizer_value = 0.0
+ bbl_totalizer_value = 0.0
+ c.execute('UPDATE flow_data SET gal_totalizer_value=?, bbl_totalizer_value=?, last_measured_timestamp=?',
+ (gal_totalizer_value, bbl_totalizer_value, last_measured_timestamp))
+ conn.commit()
+ date_reset = True
+
+ if time.localtime(now)[3] != 0 and date_reset:
+ date_reset = False
+
except Exception as e:
print("problem in the driver: {}".format(e))
time.sleep(5)
diff --git a/test_totalizer.py b/test_totalizer.py
index 917500f..603d8b2 100644
--- a/test_totalizer.py
+++ b/test_totalizer.py
@@ -52,8 +52,8 @@ def is_today(tstamp):
def loop():
"""Run the driver."""
# Configuration Parameters
- total_time_store_delta = 600 # seconds
- flow_time_store_delta = 600 # seconds
+ # total_time_store_delta = 600 # seconds
+ # flow_time_store_delta = 600 # seconds
raw_min = 3.89
raw_max = 19.54
@@ -63,13 +63,13 @@ def loop():
gal_per_bbl = 42.0
- galtotal_ch = Channel('gal_total', 100.0, total_time_store_delta)
- bbltotal_ch = Channel('bbl_total', galtotal_ch.senddelta_value/gal_per_bbl, total_time_store_delta)
-
- gpmflow_ch = Channel('gpm_flow', 10.0, flow_time_store_delta)
- bpdflow_ch = Channel('bpd_flow', gpmflow_ch.senddelta_value/gal_per_bbl, total_time_store_delta)
-
- runstatus_ch = Channel('run_status', 0.5, 600)
+ # galtotal_ch = Channel('gal_total', 100.0, total_time_store_delta)
+ # bbltotal_ch = Channel('bbl_total', galtotal_ch.senddelta_value/gal_per_bbl, total_time_store_delta)
+ #
+ # gpmflow_ch = Channel('gpm_flow', 10.0, flow_time_store_delta)
+ # bpdflow_ch = Channel('bpd_flow', gpmflow_ch.senddelta_value/gal_per_bbl, total_time_store_delta)
+ #
+ # runstatus_ch = Channel('run_status', 0.5, 600)
last_measured_timestamp = time.time()
conn = sqlite3.connect('flow-monitor.db')