Merge pull request #2 from Henry-Pump/add-pressure-transmitter
Completes #1.
This commit is contained in:
@@ -106,6 +106,45 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 text-center box-me" id="pressure-transmitter-toggle">
|
||||||
|
<% if (channels['flowmonitor.psi_pressure_enabled'].value == "True"){ %>
|
||||||
|
<h2>Pressure Transmitter Enabled</h2>
|
||||||
|
<% } else { %>
|
||||||
|
<h2>Pressure Transmitter Disabled</h2>
|
||||||
|
<% } %>
|
||||||
|
<div data-valueupdate="psi_pressure_enabled" data-refreshonupdate=true>
|
||||||
|
<form>
|
||||||
|
<% if (channels['flowmonitor.psi_pressure_enabled'].value == "True"){ %>
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
data-confirm-message="Are you sure you want to do this?"
|
||||||
|
data-refreshpause="1"
|
||||||
|
data-command=""
|
||||||
|
data-staticsend="False"
|
||||||
|
data-channelId="<%= channels["flowmonitor.psi_pressure_enabled"].channelId %>"
|
||||||
|
data-techname="<%=channels["flowmonitor.psi_pressure_enabled"].techName %>"
|
||||||
|
data-name="<%= channels["flowmonitor.psi_pressure_enabled"].name%>"
|
||||||
|
data-nodechannelcurrentId="<%= channels["flowmonitor.psi_pressure_enabled"].nodechannelcurrentId %>"
|
||||||
|
id="<%= channels["flowmonitor.psi_pressure_enabled"].channelId %>"
|
||||||
|
class="btn btn-large btn-theme animated setstatic">Disable Pressure Transmitter</a>
|
||||||
|
<% } else { %>
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
data-confirm-message="Are you sure you want to do this?"
|
||||||
|
data-refreshpause="1"
|
||||||
|
data-command=""
|
||||||
|
data-staticsend="True"
|
||||||
|
data-channelId="<%= channels["flowmonitor.psi_pressure_enabled"].channelId %>"
|
||||||
|
data-techname="<%=channels["flowmonitor.psi_pressure_enabled"].techName %>"
|
||||||
|
data-name="<%= channels["flowmonitor.psi_pressure_enabled"].name%>"
|
||||||
|
data-nodechannelcurrentId="<%= channels["flowmonitor.psi_pressure_enabled"].nodechannelcurrentId %>"
|
||||||
|
id="<%= channels["flowmonitor.psi_pressure_enabled"].channelId %>"
|
||||||
|
class="btn btn-large btn-theme animated setstatic">Enable Pressure Transmitter</a>
|
||||||
|
<% } %>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,35 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<% if (channels["flowmonitor.psi_pressure_enabled"].value == "True") { %>
|
||||||
|
|
||||||
|
<div class='col-xs-6 col-offset-xs-3 text-center box-me'>
|
||||||
|
<h2>Pressure Transmitter</h2>
|
||||||
|
<div class="gauge-box">
|
||||||
|
<div data-labelheight="10"
|
||||||
|
style="height: 170px; background: transparent; margin: 0 auto;"
|
||||||
|
id="gauge-psi_pressure"
|
||||||
|
data-chart="solidgauge"
|
||||||
|
data-nodename="flowmonitor.psi_pressure"
|
||||||
|
data-units="BPD"
|
||||||
|
data-min="0"
|
||||||
|
data-max="5000"
|
||||||
|
data-decimalplaces="2"
|
||||||
|
data-colors="0.1:#DF5353,0.5:#DDDF0D,0.9:#55BF3B"
|
||||||
|
data-valuefontsize="18px">
|
||||||
|
</div>
|
||||||
|
<div class- "timestamp-box">
|
||||||
|
<a href="#" data-channelId="<%= channels['flowmonitor.psi_pressure'].channelId %>" class="data-table" title="Download Channel History">
|
||||||
|
<i class="fa fa-download"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<span data-timeupdate="psi_pressure">
|
||||||
|
<%= channels["flowmonitor.psi_pressure"].timestamp %>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% } %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row box-me">
|
<div class="row box-me">
|
||||||
@@ -133,6 +162,10 @@
|
|||||||
data-chart="chart"
|
data-chart="chart"
|
||||||
data-nodename1="flowmonitor.bpd_flow"
|
data-nodename1="flowmonitor.bpd_flow"
|
||||||
data-datalabel1="Flow Rate (BPD)"
|
data-datalabel1="Flow Rate (BPD)"
|
||||||
|
<% if (channels["flowmonitor.psi_pressure_enabled"].value === "True") { %>
|
||||||
|
data-nodename2="flowmonitor.psi_pressure"
|
||||||
|
data-datalabel2="Pressure (PSI)"
|
||||||
|
<% } %>
|
||||||
data-daysofhistory="2"
|
data-daysofhistory="2"
|
||||||
data-chartlabel="Last 48 Hours"
|
data-chartlabel="Last 48 Hours"
|
||||||
data-ylabel=""
|
data-ylabel=""
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
<div class="row row-flex">
|
<div class="row row-flex">
|
||||||
|
<div class="col-xs-12" style="text-align: center;">
|
||||||
|
<h1>Flowmeter</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col-md-6 box-me entry-top-level" id="setrawmin">
|
<div class="col-md-6 box-me entry-top-level" id="setrawmin">
|
||||||
<div style="margin-left:15px;">
|
<div style="margin-left:15px;">
|
||||||
<h2>Raw Min</h2>
|
<h2>Raw Min</h2>
|
||||||
@@ -172,6 +176,149 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row row-flex">
|
||||||
|
<div class="col-xs-12" style="text-align: center;">
|
||||||
|
<h1>Pressure Transmitter</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 box-me entry-top-level" id="setpressurerawmin">
|
||||||
|
<div style="margin-left:15px;">
|
||||||
|
<h2>Raw Min</h2>
|
||||||
|
<form class="form-inline">
|
||||||
|
<div class="form-group" style="margin-bottom:15px;">
|
||||||
|
<label
|
||||||
|
class="sr-only"
|
||||||
|
for="<%= channels["flowmonitor.setpressurerawmin"].channelId %>">Raw Min Value</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<input
|
||||||
|
class="form-control channel_value"
|
||||||
|
type="number"
|
||||||
|
step="any"
|
||||||
|
value="<%=channels['flowmonitor.setpressurerawmin'].value %>">
|
||||||
|
<div class="input-group-addon">V</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
data-confirm-message="Are you sure you want to do this?"
|
||||||
|
data-refreshpause="1"
|
||||||
|
data-command=""
|
||||||
|
data-staticsend=1.0
|
||||||
|
data-channelId="<%= channels["flowmonitor.setpressurerawmin"].channelId %>"
|
||||||
|
data-techname="<%=channels["flowmonitor.setpressurerawmin"].techName %>"
|
||||||
|
data-name="<%= channels["flowmonitor.setpressurerawmin"].name%>"
|
||||||
|
data-nodechannelcurrentId="<%= channels["flowmonitor.setpressurerawmin"].nodechannelcurrentId %>"
|
||||||
|
id="<%= channels["flowmonitor.setpressurerawmin"].channelId %>"
|
||||||
|
class="btn btn-large btn-theme animated setstatic material-icons">send</a>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 box-me entry-top-level" id="setpressurerawmax">
|
||||||
|
<div style="margin-left:15px;">
|
||||||
|
<h2>Raw Max</h2>
|
||||||
|
<form class="form-inline">
|
||||||
|
<div class="form-group" style="margin-bottom:15px;">
|
||||||
|
<label
|
||||||
|
class="sr-only"
|
||||||
|
for="<%= channels["flowmonitor.setpressurerawmax"].channelId %>">Raw Max Value</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<input
|
||||||
|
class="form-control channel_value"
|
||||||
|
type="number"
|
||||||
|
step="any"
|
||||||
|
value="<%=channels['flowmonitor.setpressurerawmax'].value %>">
|
||||||
|
<div class="input-group-addon">V</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
data-confirm-message="Are you sure you want to do this?"
|
||||||
|
data-refreshpause="1"
|
||||||
|
data-command=""
|
||||||
|
data-staticsend=1.0
|
||||||
|
data-channelId="<%= channels["flowmonitor.setpressurerawmax"].channelId %>"
|
||||||
|
data-techname="<%=channels["flowmonitor.setpressurerawmax"].techName %>"
|
||||||
|
data-name="<%= channels["flowmonitor.setpressurerawmax"].name%>"
|
||||||
|
data-nodechannelcurrentId="<%= channels["flowmonitor.setpressurerawmax"].nodechannelcurrentId %>"
|
||||||
|
id="<%= channels["flowmonitor.setpressurerawmax"].channelId %>"
|
||||||
|
class="btn btn-large btn-theme animated setstatic material-icons">send</a>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 box-me entry-top-level" id="setpressurepsimin">
|
||||||
|
<div style="margin-left:15px;">
|
||||||
|
<h2>PSI Min</h2>
|
||||||
|
<form class="form-inline">
|
||||||
|
<div class="form-group" style="margin-bottom:15px;">
|
||||||
|
<label
|
||||||
|
class="sr-only"
|
||||||
|
for="<%= channels["flowmonitor.setpressurepsimin"].channelId %>">PSI Min Value</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<input
|
||||||
|
class="form-control channel_value"
|
||||||
|
type="number"
|
||||||
|
step="any"
|
||||||
|
value="<%=channels['flowmonitor.setpressurepsimin'].value %>">
|
||||||
|
<div class="input-group-addon">PSI</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
data-confirm-message="Are you sure you want to do this?"
|
||||||
|
data-refreshpause="1"
|
||||||
|
data-command=""
|
||||||
|
data-staticsend=1.0
|
||||||
|
data-channelId="<%= channels["flowmonitor.setpressurepsimin"].channelId %>"
|
||||||
|
data-techname="<%=channels["flowmonitor.setpressurepsimin"].techName %>"
|
||||||
|
data-name="<%= channels["flowmonitor.setpressurepsimin"].name%>"
|
||||||
|
data-nodechannelcurrentId="<%= channels["flowmonitor.setpressurepsimin"].nodechannelcurrentId %>"
|
||||||
|
id="<%= channels["flowmonitor.setpressurepsimin"].channelId %>"
|
||||||
|
class="btn btn-large btn-theme animated setstatic material-icons">send</a>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 box-me entry-top-level" id="setpressurepsimax">
|
||||||
|
<div style="margin-left:15px;">
|
||||||
|
<h2>PSI Max</h2>
|
||||||
|
<form class="form-inline">
|
||||||
|
<div class="form-group" style="margin-bottom:15px;">
|
||||||
|
<label
|
||||||
|
class="sr-only"
|
||||||
|
for="<%= channels["flowmonitor.setpressurepsimax"].channelId %>">PSI Max Value</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<input
|
||||||
|
class="form-control channel_value"
|
||||||
|
type="number"
|
||||||
|
step="any"
|
||||||
|
value="<%=channels['flowmonitor.setpressurepsimax'].value %>">
|
||||||
|
<div class="input-group-addon">PSI</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
data-confirm-message="Are you sure you want to do this?"
|
||||||
|
data-refreshpause="1"
|
||||||
|
data-command=""
|
||||||
|
data-staticsend=1.0
|
||||||
|
data-channelId="<%= channels["flowmonitor.setpressurepsimax"].channelId %>"
|
||||||
|
data-techname="<%=channels["flowmonitor.setpressurepsimax"].techName %>"
|
||||||
|
data-name="<%= channels["flowmonitor.setpressurepsimax"].name%>"
|
||||||
|
data-nodechannelcurrentId="<%= channels["flowmonitor.setpressurepsimax"].nodechannelcurrentId %>"
|
||||||
|
id="<%= channels["flowmonitor.setpressurepsimax"].channelId %>"
|
||||||
|
class="btn btn-large btn-theme animated setstatic material-icons">send</a>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$('.channel_value').each(function(topLevel){
|
$('.channel_value').each(function(topLevel){
|
||||||
$(this).change(function(){
|
$(this).change(function(){
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
data-ylabel=""
|
data-ylabel=""
|
||||||
data-xlabel="Date"
|
data-xlabel="Date"
|
||||||
data-units=""
|
data-units=""
|
||||||
data-channelnames="flowmonitor.gal_total,flowmonitor.gal_total_yesterday,flowmonitor.bbl_total,flowmonitor.bbl_total_yesterday,flowmonitor.gpm_flow,flowmonitor.gal_total_thismonth,flowmonitor.gal_total_lastmonth,flowmonitor.bbl_total_thismonth,flowmonitor.bbl_total_lastmonth,flowmonitor.bpd_flow"></div>
|
data-channelnames="flowmonitor.gal_total,flowmonitor.gal_total_yesterday,flowmonitor.bbl_total,flowmonitor.bbl_total_yesterday,flowmonitor.gpm_flow,flowmonitor.gal_total_thismonth,flowmonitor.gal_total_lastmonth,flowmonitor.bbl_total_thismonth,flowmonitor.bbl_total_lastmonth,flowmonitor.bpd_flow<% if (channels['flowmonitor.psi_pressure_enabled'].value == 'True') { %>,flowmonitor.psi_pressure<% } %>"></div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.dynamic-chart-form {
|
.dynamic-chart-form {
|
||||||
|
|||||||
29
README.md
29
README.md
@@ -1,22 +1,15 @@
|
|||||||
# flow-monitor
|
# Max Water System Lite
|
||||||
|
|
||||||
## To set up sqlite database
|
## Wiring
|
||||||
```
|
|
||||||
sqlite3 flow-monitor.db
|
|
||||||
|
|
||||||
CREATE TABLE flow_data (
|
| Channel | Device |
|
||||||
id integer PRIMARY KEY,
|
| -------------- | -------------------- |
|
||||||
gal_totalizer_value float,
|
| Relay 1 | Starter Output |
|
||||||
bbl_totalizer_value float,
|
| Digital In 1 | Auto Switch |
|
||||||
last_measured_timestamp integer
|
| Digital In 2 | Start Button |
|
||||||
);
|
| Current Loop | Flowmeter |
|
||||||
|
| Analog Input 1 | Pressure Transmitter |
|
||||||
|
|
||||||
INSERT INTO flow_data (id, gal_totalizer_value, bbl_totalizer_value, last_measured_timestamp) VALUES (1, 0.0, 0.0, 0);
|
## Contributors
|
||||||
```
|
|
||||||
|
|
||||||
## To reset the sqlite database
|
- [Patrick McDonagh](https://github.com/patrickjmcd) - Owner
|
||||||
```
|
|
||||||
sqlite3 flow-monitor.db
|
|
||||||
|
|
||||||
UPDATE flow_data SET gal_totalizer_value=0.0, bbl_totalizer_value=0.0, last_measured_timestamp=0 WHERE id=1;
|
|
||||||
```
|
|
||||||
|
|||||||
14
config.txt
14
config.txt
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"files": {
|
"files": {
|
||||||
"file3": "persistence.py",
|
"file3": "persistence.py",
|
||||||
"file2": "utilities.py",
|
"file2": "utilities.py",
|
||||||
"file1": "flow-monitor.py"
|
"file1": "flow-monitor.py"
|
||||||
},
|
},
|
||||||
"deviceName": "flowmonitor",
|
"deviceName": "flowmonitor",
|
||||||
"driverId": "0140",
|
"driverId": "0180",
|
||||||
"releaseVersion": "10",
|
"releaseVersion": "11",
|
||||||
"driverFileName": "flow-monitor.py"
|
"driverFileName": "flow-monitor.py"
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
|
"version": 11,
|
||||||
|
"driverFilename": "flow-monitor.py",
|
||||||
"s3BucketName": "flow-monitor",
|
"s3BucketName": "flow-monitor",
|
||||||
|
"name": "flowmonitor",
|
||||||
"additionalDriverFiles": [
|
"additionalDriverFiles": [
|
||||||
"utilities.py",
|
"utilities.py",
|
||||||
"persistence.py"
|
"persistence.py"
|
||||||
],
|
]
|
||||||
"name": "flowmonitor",
|
|
||||||
"version": 9,
|
|
||||||
"driverFilename": "flow-monitor.py"
|
|
||||||
}
|
}
|
||||||
306
flow-monitor.py
306
flow-monitor.py
@@ -3,10 +3,30 @@ import threading
|
|||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
import logging
|
||||||
|
import sys
|
||||||
from device_base import deviceBase
|
from device_base import deviceBase
|
||||||
import persistence
|
import persistence
|
||||||
from utilities import get_public_ip_address
|
from utilities import get_public_ip_address
|
||||||
|
|
||||||
|
# LOGGING SETUP
|
||||||
|
from logging.handlers import RotatingFileHandler
|
||||||
|
|
||||||
|
log_formatter = logging.Formatter('%(asctime)s %(levelname)s %(funcName)s(%(lineno)d) %(message)s')
|
||||||
|
logFile = './flowmonitor.log'
|
||||||
|
my_handler = RotatingFileHandler(logFile, mode='a', maxBytes=500*1024, backupCount=2, encoding=None, delay=0)
|
||||||
|
my_handler.setFormatter(log_formatter)
|
||||||
|
my_handler.setLevel(logging.INFO)
|
||||||
|
logger = logging.getLogger('flowmonitor')
|
||||||
|
logger.setLevel(logging.INFO)
|
||||||
|
logger.addHandler(my_handler)
|
||||||
|
|
||||||
|
console_out = logging.StreamHandler(sys.stdout)
|
||||||
|
console_out.setFormatter(log_formatter)
|
||||||
|
logger.addHandler(console_out)
|
||||||
|
|
||||||
|
logger.info("flowmonitor startup")
|
||||||
|
|
||||||
CREATE_FLOWDATA_TABLE = """CREATE TABLE flow_data (
|
CREATE_FLOWDATA_TABLE = """CREATE TABLE flow_data (
|
||||||
id integer PRIMARY KEY,
|
id integer PRIMARY KEY,
|
||||||
gal_totalizer_value float,
|
gal_totalizer_value float,
|
||||||
@@ -39,30 +59,43 @@ UPDATE_FLOWDATA = """UPDATE flow_data SET
|
|||||||
bbl_monthly_totalizer=?,
|
bbl_monthly_totalizer=?,
|
||||||
last_measured_timestamp=? WHERE id=1"""
|
last_measured_timestamp=? WHERE id=1"""
|
||||||
|
|
||||||
CREATE_SCALINGDATA_TABLE = """CREATE TABLE scaling_data (
|
|
||||||
id integer PRIMARY KEY,
|
|
||||||
raw_min float,
|
|
||||||
raw_max float,
|
|
||||||
gpm_min float,
|
|
||||||
gpm_max float
|
|
||||||
);"""
|
|
||||||
|
|
||||||
INSERT_SCALINGDATA = """INSERT INTO scaling_data (
|
|
||||||
id,
|
|
||||||
raw_min,
|
|
||||||
raw_max,
|
|
||||||
gpm_min,
|
|
||||||
gpm_max) VALUES (1, ?, ?, ?, ?);"""
|
|
||||||
|
|
||||||
UPDATE_SCALINGDATA = """UPDATE scaling_data SET
|
|
||||||
raw_min=?,
|
|
||||||
raw_max=?,
|
|
||||||
gpm_min=?,
|
|
||||||
gpm_max=? WHERE id=1;"""
|
|
||||||
|
|
||||||
PERSIST = persistence.load()
|
PERSIST = persistence.load()
|
||||||
|
|
||||||
|
|
||||||
|
def migrate_from_sqlite_to_json_scaling():
|
||||||
|
"""Migrate data from SQLite db to JSON, if needed"""
|
||||||
|
global PERSIST
|
||||||
|
try:
|
||||||
|
PERSIST['flow_raw_min']
|
||||||
|
logger.info("Don't need to migrate from SQLite to JSON.")
|
||||||
|
return False
|
||||||
|
except (KeyError, TypeError):
|
||||||
|
logger.info("Migrating from SQLite to JSON.")
|
||||||
|
|
||||||
|
if not PERSIST:
|
||||||
|
PERSIST = {}
|
||||||
|
|
||||||
|
conn = sqlite3.connect('/root/python_firmware/drivers/flow-monitor.db')
|
||||||
|
cursor = conn.cursor()
|
||||||
|
try:
|
||||||
|
cursor.execute('SELECT * FROM scaling_data WHERE id = 1') # dummy query for checking database
|
||||||
|
stored_data = cursor.fetchone()
|
||||||
|
flow_raw_min = stored_data[1]
|
||||||
|
flow_raw_max = stored_data[2]
|
||||||
|
flow_gpm_min = stored_data[3]
|
||||||
|
flow_gpm_max = stored_data[4]
|
||||||
|
except (sqlite3.OperationalError, TypeError):
|
||||||
|
logger.info("No stored data in SQLite for scaling, we'll just use default values")
|
||||||
|
return False
|
||||||
|
|
||||||
|
PERSIST["flow_raw_min"] = flow_raw_min
|
||||||
|
PERSIST["flow_raw_max"] = flow_raw_max
|
||||||
|
PERSIST["flow_gpm_min"] = flow_gpm_min
|
||||||
|
PERSIST["flow_gpm_max"] = flow_gpm_max
|
||||||
|
persistence.store(PERSIST)
|
||||||
|
|
||||||
|
|
||||||
class ChannelSimple(object):
|
class ChannelSimple(object):
|
||||||
"""Simple Meshify channel structure."""
|
"""Simple Meshify channel structure."""
|
||||||
|
|
||||||
@@ -126,14 +159,20 @@ class start(threading.Thread, deviceBase):
|
|||||||
mcu=mcu, companyId=companyId, offset=offset,
|
mcu=mcu, companyId=companyId, offset=offset,
|
||||||
mqtt=mqtt, Nodes=Nodes)
|
mqtt=mqtt, Nodes=Nodes)
|
||||||
# Default Scaling Values for Flowmeter
|
# Default Scaling Values for Flowmeter
|
||||||
self.RAW_MIN = 3.89
|
self.flow_raw_min = 3.89
|
||||||
self.RAW_MAX = 19.54
|
self.flow_raw_max = 19.54
|
||||||
self.GPM_MIN = 0.0
|
self.flow_gpm_min = 0.0
|
||||||
self.GPM_MAX = 100.0
|
self.flow_gpm_max = 100.0
|
||||||
|
|
||||||
|
self.pressure_raw_min = 0.00
|
||||||
|
self.pressure_raw_max = 10.00
|
||||||
|
self.pressure_psi_min = 0.00
|
||||||
|
self.pressure_psi_max = 600.0
|
||||||
|
|
||||||
self.GPM_IGNORE_LIMIT = 1.0
|
self.GPM_IGNORE_LIMIT = 1.0
|
||||||
|
|
||||||
self.daemon = True
|
self.daemon = True
|
||||||
self.version = "10"
|
self.version = "11"
|
||||||
self.finished = threading.Event()
|
self.finished = threading.Event()
|
||||||
threading.Thread.start(self)
|
threading.Thread.start(self)
|
||||||
|
|
||||||
@@ -149,6 +188,7 @@ class start(threading.Thread, deviceBase):
|
|||||||
# Configuration Parameters
|
# Configuration Parameters
|
||||||
total_time_store_delta = 600 # seconds
|
total_time_store_delta = 600 # seconds
|
||||||
flow_time_store_delta = 600 # seconds
|
flow_time_store_delta = 600 # seconds
|
||||||
|
pressure_time_store_delta = 600 # seconds
|
||||||
gal_per_bbl = 42.0
|
gal_per_bbl = 42.0
|
||||||
startup_wait_seconds = 30
|
startup_wait_seconds = 30
|
||||||
ip_check_after = 3600 # check public IP address after an hour
|
ip_check_after = 3600 # check public IP address after an hour
|
||||||
@@ -169,13 +209,14 @@ class start(threading.Thread, deviceBase):
|
|||||||
bbltotalthismonth_ch = ChannelSimple('bbl_total_thismonth', galtotalthismonth_ch.senddelta_value/gal_per_bbl, total_time_store_delta)
|
bbltotalthismonth_ch = ChannelSimple('bbl_total_thismonth', galtotalthismonth_ch.senddelta_value/gal_per_bbl, total_time_store_delta)
|
||||||
gpmflow_ch = ChannelSimple('gpm_flow', 10.0, flow_time_store_delta)
|
gpmflow_ch = ChannelSimple('gpm_flow', 10.0, flow_time_store_delta)
|
||||||
bpdflow_ch = ChannelSimple('bpd_flow', gpmflow_ch.senddelta_value * 34.2857, flow_time_store_delta)
|
bpdflow_ch = ChannelSimple('bpd_flow', gpmflow_ch.senddelta_value * 34.2857, flow_time_store_delta)
|
||||||
|
psipressure_ch = ChannelSimple('psi_pressure', 10.0, pressure_time_store_delta)
|
||||||
runstatus_ch = ChannelSimple('run_status', 0.5, 600)
|
runstatus_ch = ChannelSimple('run_status', 0.5, 600)
|
||||||
|
|
||||||
# Startup timer.
|
# Startup timer.
|
||||||
# Waits for connection to Meshify before attempting to send data
|
# Waits for connection to Meshify before attempting to send data
|
||||||
wait_loops = 0
|
wait_loops = 0
|
||||||
while wait_loops < startup_wait_seconds:
|
while wait_loops < startup_wait_seconds:
|
||||||
print("Waiting to start flowmonitor driver in {} seconds".format(startup_wait_seconds - wait_loops))
|
logger.info("Waiting to start flowmonitor driver in {} seconds".format(startup_wait_seconds - wait_loops))
|
||||||
wait_loops += 1
|
wait_loops += 1
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
@@ -203,7 +244,7 @@ class start(threading.Thread, deviceBase):
|
|||||||
last_measured_timestamp = stored_data[5]
|
last_measured_timestamp = stored_data[5]
|
||||||
except sqlite3.OperationalError:
|
except sqlite3.OperationalError:
|
||||||
# Caught if the table does not exist in the database.
|
# Caught if the table does not exist in the database.
|
||||||
print("No table flow_data in the database. I'll create it now.")
|
logger.warning("No table flow_data in the database. I'll create it now.")
|
||||||
cursor.execute(CREATE_FLOWDATA_TABLE)
|
cursor.execute(CREATE_FLOWDATA_TABLE)
|
||||||
cursor.execute(INSERT_BLANK_FLOWDATA)
|
cursor.execute(INSERT_BLANK_FLOWDATA)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
@@ -211,32 +252,49 @@ class start(threading.Thread, deviceBase):
|
|||||||
# Reset the database if the correct size data is not in the database.
|
# Reset the database if the correct size data is not in the database.
|
||||||
self.flowmonitor_resetdatabase(None, None)
|
self.flowmonitor_resetdatabase(None, None)
|
||||||
|
|
||||||
|
# Load scaling data
|
||||||
|
migrate_from_sqlite_to_json_scaling()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cursor.execute('SELECT * FROM scaling_data WHERE id = 1') # dummy query for checking database
|
self.flow_raw_min = PERSIST["flow_raw_min"]
|
||||||
stored_data = cursor.fetchone()
|
self.flow_raw_max = PERSIST["flow_raw_max"]
|
||||||
self.RAW_MIN = stored_data[1]
|
self.flow_gpm_min = PERSIST["flow_gpm_min"]
|
||||||
self.RAW_MAX = stored_data[2]
|
self.flow_gpm_max = PERSIST["flow_gpm_max"]
|
||||||
self.GPM_MIN = stored_data[3]
|
except KeyError:
|
||||||
self.GPM_MAX = stored_data[4]
|
logger.warning("No flow scaling data exists in persist file. We'll add some now")
|
||||||
self.sendtodb("setrawmin", self.RAW_MIN, 0)
|
PERSIST["flow_raw_min"] = self.flow_raw_min
|
||||||
self.sendtodb("setrawmax", self.RAW_MAX, 0)
|
PERSIST["flow_raw_max"] = self.flow_raw_max
|
||||||
self.sendtodb("setgpmmin", self.GPM_MIN, 0)
|
PERSIST["flow_gpm_min"] = self.flow_gpm_min
|
||||||
self.sendtodb("setgpmmax", self.GPM_MAX, 0)
|
PERSIST["flow_gpm_max"] = self.flow_gpm_max
|
||||||
except (sqlite3.OperationalError, TypeError):
|
persistence.store(PERSIST)
|
||||||
# Caught if the table does not exist in the database.
|
|
||||||
print("No table scaling_data in the database. I'll create it now.")
|
self.sendtodb("setrawmin", self.flow_raw_min, 0)
|
||||||
cursor.execute(CREATE_SCALINGDATA_TABLE)
|
self.sendtodb("setrawmax", self.flow_raw_max, 0)
|
||||||
cursor.execute(INSERT_SCALINGDATA, (self.RAW_MIN, self.RAW_MAX, self.GPM_MIN, self.GPM_MAX))
|
self.sendtodb("setgpmmin", self.flow_gpm_min, 0)
|
||||||
self.sendtodb("setrawmin", self.RAW_MIN, 0)
|
self.sendtodb("setgpmmax", self.flow_gpm_max, 0)
|
||||||
self.sendtodb("setrawmax", self.RAW_MAX, 0)
|
|
||||||
self.sendtodb("setgpmmin", self.GPM_MIN, 0)
|
try:
|
||||||
self.sendtodb("setgpmmax", self.GPM_MAX, 0)
|
self.pressure_raw_min = PERSIST["pressure_raw_min"]
|
||||||
conn.commit()
|
self.pressure_raw_max = PERSIST["pressure_raw_max"]
|
||||||
|
self.pressure_psi_min = PERSIST["pressure_psi_min"]
|
||||||
|
self.pressure_psi_max = PERSIST["pressure_psi_max"]
|
||||||
|
except KeyError:
|
||||||
|
logger.warning("No flow scaling data exists in persist file. We'll add some now")
|
||||||
|
PERSIST["pressure_raw_min"] = self.pressure_raw_min
|
||||||
|
PERSIST["pressure_raw_max"] = self.pressure_raw_max
|
||||||
|
PERSIST["pressure_psi_min"] = self.pressure_psi_min
|
||||||
|
PERSIST["pressure_psi_max"] = self.pressure_psi_max
|
||||||
|
persistence.store(PERSIST)
|
||||||
|
|
||||||
|
self.sendtodb("setpressurerawmin", self.pressure_raw_min, 0)
|
||||||
|
self.sendtodb("setpressurerawmax", self.pressure_raw_max, 0)
|
||||||
|
self.sendtodb("setpressurepsimin", self.pressure_psi_min, 0)
|
||||||
|
self.sendtodb("setpressurepsimax", self.pressure_psi_max, 0)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.GPM_IGNORE_LIMIT = PERSIST['gpm_ignore_limit']
|
self.GPM_IGNORE_LIMIT = PERSIST['gpm_ignore_limit']
|
||||||
except Exception:
|
except Exception:
|
||||||
print("no persisted GPM Ignore Limit. Using default of {}".format(self.GPM_IGNORE_LIMIT))
|
logger.warning("no persisted GPM Ignore Limit. Using default of {}".format(self.GPM_IGNORE_LIMIT))
|
||||||
self.flowmonitor_setgpmignorelimit("gpm_ignore_limit", self.GPM_IGNORE_LIMIT)
|
self.flowmonitor_setgpmignorelimit("gpm_ignore_limit", self.GPM_IGNORE_LIMIT)
|
||||||
|
|
||||||
# on bootup, if the day has changed, clear the totalizers.
|
# on bootup, if the day has changed, clear the totalizers.
|
||||||
@@ -250,10 +308,30 @@ class start(threading.Thread, deviceBase):
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
mcu_status = self.mcu.getDict() # Gets a dictionary of the IO states
|
mcu_status = self.mcu.getDict() # Gets a dictionary of the IO states
|
||||||
|
# {
|
||||||
|
# 'bat': u'23.10',
|
||||||
|
# 'ver': u'Mar 16 2016 21:29:31',
|
||||||
|
# 'dout3': 'Off',
|
||||||
|
# 'temp': u'40.37',
|
||||||
|
# 'vin': u'24.6',
|
||||||
|
# 'pulse': u'0',
|
||||||
|
# 'dout4': 'Off',
|
||||||
|
# 'dout1': 'Off',
|
||||||
|
# 'din2': 'Off',
|
||||||
|
# 'din1': 'Off',
|
||||||
|
# 'dout2': 'On',
|
||||||
|
# 'cloop': u'0.0',
|
||||||
|
# 'analog4': u'0.0',
|
||||||
|
# 'analog3': u'0.0',
|
||||||
|
# 'analog2': u'0.0',
|
||||||
|
# 'analog1': u'0.0',
|
||||||
|
# 'relay1': 'Off'
|
||||||
|
# }
|
||||||
cloop_val = float(mcu_status['cloop'])
|
cloop_val = float(mcu_status['cloop'])
|
||||||
|
analog1_val = float(mcu_status['analog1'])
|
||||||
din1_val = 1 if mcu_status['din1'] == 'On' else 0 # Check DIGITAL INPUT 1 for run status
|
din1_val = 1 if mcu_status['din1'] == 'On' else 0 # Check DIGITAL INPUT 1 for run status
|
||||||
gpm_val = scale(cloop_val, self.RAW_MIN, self.RAW_MAX, self.GPM_MIN, self.GPM_MAX)
|
gpm_val = scale(cloop_val, self.flow_raw_min, self.flow_raw_max, self.flow_gpm_min, self.flow_gpm_max)
|
||||||
|
psi_val = scale(analog1_val, self.pressure_raw_min, self.pressure_raw_max, self.pressure_psi_min, self.pressure_psi_max)
|
||||||
if gpm_val < self.GPM_IGNORE_LIMIT:
|
if gpm_val < self.GPM_IGNORE_LIMIT:
|
||||||
gpm_val = 0
|
gpm_val = 0
|
||||||
|
|
||||||
@@ -278,8 +356,8 @@ class start(threading.Thread, deviceBase):
|
|||||||
cursor.execute(UPDATE_FLOWDATA, (gal_totalizer_value, bbl_totalizer_value, gal_monthly_totalizer, bbl_monthly_totalizer, last_measured_timestamp))
|
cursor.execute(UPDATE_FLOWDATA, (gal_totalizer_value, bbl_totalizer_value, gal_monthly_totalizer, bbl_monthly_totalizer, last_measured_timestamp))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
print('gpm: {}, bpd: {}, gal: {}, bbl:{}, month_gal:{}, month_bbl:{}'.format(
|
logger.info('gpm: {}, bpd: {}, psi: {}, gal: {}, bbl:{}, month_gal:{}, month_bbl:{}'.format(
|
||||||
gpm_val, bpd_val, gal_totalizer_value, bbl_totalizer_value, gal_monthly_totalizer, bbl_monthly_totalizer))
|
gpm_val, bpd_val, psi_val, gal_totalizer_value, bbl_totalizer_value, gal_monthly_totalizer, bbl_monthly_totalizer))
|
||||||
|
|
||||||
# Channel Checks:
|
# Channel Checks:
|
||||||
# check to see if the value needs to be sent to Meshify
|
# check to see if the value needs to be sent to Meshify
|
||||||
@@ -307,6 +385,10 @@ class start(threading.Thread, deviceBase):
|
|||||||
self.sendtodb(bpdflow_ch.meshify_name, bpd_val, 0)
|
self.sendtodb(bpdflow_ch.meshify_name, bpd_val, 0)
|
||||||
bpdflow_ch.update(bpd_val, now)
|
bpdflow_ch.update(bpd_val, now)
|
||||||
|
|
||||||
|
if psipressure_ch.check_if_send_needed(psi_val, now):
|
||||||
|
self.sendtodb(psipressure_ch.meshify_name, psi_val, 0)
|
||||||
|
psipressure_ch.update(psi_val, now)
|
||||||
|
|
||||||
if runstatus_ch.check_if_send_needed(din1_val, now):
|
if runstatus_ch.check_if_send_needed(din1_val, now):
|
||||||
self.sendtodb(runstatus_ch.meshify_name, din1_val, 0)
|
self.sendtodb(runstatus_ch.meshify_name, din1_val, 0)
|
||||||
runstatus_ch.update(din1_val, now)
|
runstatus_ch.update(din1_val, now)
|
||||||
@@ -358,7 +440,7 @@ class start(threading.Thread, deviceBase):
|
|||||||
self.flowmonitor_stopcmd(None, None)
|
self.flowmonitor_stopcmd(None, None)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("problem in the driver: {}".format(e))
|
logger.error("problem in the driver: {}".format(e))
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
def flowmonitor_startcmd(self, name, value):
|
def flowmonitor_startcmd(self, name, value):
|
||||||
@@ -381,9 +463,9 @@ class start(threading.Thread, deviceBase):
|
|||||||
cursor.execute(CREATE_FLOWDATA_TABLE)
|
cursor.execute(CREATE_FLOWDATA_TABLE)
|
||||||
cursor.execute(INSERT_BLANK_FLOWDATA)
|
cursor.execute(INSERT_BLANK_FLOWDATA)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
print("DATABASE HAS BEEN RESET!")
|
logger.info("DATABASE HAS BEEN RESET!")
|
||||||
except sqlite3.OperationalError:
|
except sqlite3.OperationalError:
|
||||||
print("No table flow_data in the database. I'll create it now.")
|
logger.warning("No table flow_data in the database. I'll create it now.")
|
||||||
cursor.execute(CREATE_FLOWDATA_TABLE)
|
cursor.execute(CREATE_FLOWDATA_TABLE)
|
||||||
cursor.execute(INSERT_BLANK_FLOWDATA)
|
cursor.execute(INSERT_BLANK_FLOWDATA)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
@@ -391,66 +473,90 @@ class start(threading.Thread, deviceBase):
|
|||||||
|
|
||||||
def flowmonitor_setrawmin(self, name, value):
|
def flowmonitor_setrawmin(self, name, value):
|
||||||
"""Set the raw min scaling value."""
|
"""Set the raw min scaling value."""
|
||||||
conn = sqlite3.connect('/root/python_firmware/drivers/flow-monitor.db')
|
|
||||||
cursor = conn.cursor()
|
|
||||||
try:
|
try:
|
||||||
self.RAW_MIN = float(value)
|
self.flow_raw_min = float(value)
|
||||||
cursor.execute(UPDATE_SCALINGDATA, (self.RAW_MIN, self.RAW_MAX, self.GPM_MIN, self.GPM_MAX))
|
self.sendtodb("setrawmin", self.flow_raw_min, 0)
|
||||||
self.sendtodb("setrawmin", self.RAW_MIN, 0)
|
PERSIST['flow_raw_min'] = self.flow_raw_min
|
||||||
conn.commit()
|
persistence.store(PERSIST)
|
||||||
except sqlite3.OperationalError:
|
except Exception as e:
|
||||||
print("No table flow_data in the database. I'll create it now.")
|
logger.error("Could not set self.flow_raw_min: {}".format(e))
|
||||||
cursor.execute(CREATE_SCALINGDATA_TABLE)
|
|
||||||
cursor.execute(INSERT_SCALINGDATA, (self.RAW_MIN, self.RAW_MAX, self.GPM_MIN, self.GPM_MAX))
|
|
||||||
conn.commit()
|
|
||||||
return(True)
|
return(True)
|
||||||
|
|
||||||
def flowmonitor_setrawmax(self, name, value):
|
def flowmonitor_setrawmax(self, name, value):
|
||||||
"""Set the raw max scaling value."""
|
"""Set the raw max scaling value."""
|
||||||
conn = sqlite3.connect('/root/python_firmware/drivers/flow-monitor.db')
|
|
||||||
cursor = conn.cursor()
|
|
||||||
try:
|
try:
|
||||||
self.RAW_MAX = float(value)
|
self.flow_raw_max = float(value)
|
||||||
self.sendtodb("setrawmax", self.RAW_MAX, 0)
|
self.sendtodb("setrawmax", self.flow_raw_max, 0)
|
||||||
cursor.execute(UPDATE_SCALINGDATA, (self.RAW_MIN, self.RAW_MAX, self.GPM_MIN, self.GPM_MAX))
|
PERSIST['flow_raw_max'] = self.flow_raw_max
|
||||||
conn.commit()
|
persistence.store(PERSIST)
|
||||||
except sqlite3.OperationalError:
|
except Exception as e:
|
||||||
print("No table flow_data in the database. I'll create it now.")
|
logger.error("Could not set self.flow_raw_max: {}".format(e))
|
||||||
cursor.execute(CREATE_SCALINGDATA_TABLE)
|
|
||||||
cursor.execute(INSERT_SCALINGDATA, (self.RAW_MIN, self.RAW_MAX, self.GPM_MIN, self.GPM_MAX))
|
|
||||||
conn.commit()
|
|
||||||
return(True)
|
return(True)
|
||||||
|
|
||||||
def flowmonitor_setgpmmin(self, name, value):
|
def flowmonitor_setgpmmin(self, name, value):
|
||||||
"""Set the gpm min scaling value."""
|
"""Set the gpm min scaling value."""
|
||||||
conn = sqlite3.connect('/root/python_firmware/drivers/flow-monitor.db')
|
|
||||||
cursor = conn.cursor()
|
|
||||||
try:
|
try:
|
||||||
self.GPM_MIN = float(value)
|
self.flow_gpm_min = float(value)
|
||||||
self.sendtodb("setgpmmin", self.GPM_MIN, 0)
|
self.sendtodb("setgpmmin", self.flow_gpm_min, 0)
|
||||||
cursor.execute(UPDATE_SCALINGDATA, (self.RAW_MIN, self.RAW_MAX, self.GPM_MIN, self.GPM_MAX))
|
PERSIST['flow_gpm_min'] = self.flow_gpm_min
|
||||||
conn.commit()
|
persistence.store(PERSIST)
|
||||||
except sqlite3.OperationalError:
|
except Exception as e:
|
||||||
print("No table flow_data in the database. I'll create it now.")
|
logger.error("Could not set self.flow_gpm_min: {}".format(e))
|
||||||
cursor.execute(CREATE_SCALINGDATA_TABLE)
|
|
||||||
cursor.execute(INSERT_SCALINGDATA, (self.RAW_MIN, self.RAW_MAX, self.GPM_MIN, self.GPM_MAX))
|
|
||||||
conn.commit()
|
|
||||||
return(True)
|
return(True)
|
||||||
|
|
||||||
def flowmonitor_setgpmmax(self, name, value):
|
def flowmonitor_setgpmmax(self, name, value):
|
||||||
"""Set the gpm max scaling value."""
|
"""Set the gpm max scaling value."""
|
||||||
conn = sqlite3.connect('/root/python_firmware/drivers/flow-monitor.db')
|
|
||||||
cursor = conn.cursor()
|
|
||||||
try:
|
try:
|
||||||
self.GPM_MAX = float(value)
|
self.flow_gpm_max = float(value)
|
||||||
self.sendtodb("setgpmmax", self.GPM_MAX, 0)
|
self.sendtodb("setgpmmax", self.flow_gpm_max, 0)
|
||||||
cursor.execute(UPDATE_SCALINGDATA, (self.RAW_MIN, self.RAW_MAX, self.GPM_MIN, self.GPM_MAX))
|
PERSIST['flow_gpm_max'] = self.flow_gpm_max
|
||||||
conn.commit()
|
persistence.store(PERSIST)
|
||||||
except sqlite3.OperationalError:
|
except Exception as e:
|
||||||
print("No table flow_data in the database. I'll create it now.")
|
logger.error("Could not set self.flow_gpm_max: {}".format(e))
|
||||||
cursor.execute(CREATE_SCALINGDATA_TABLE)
|
return(True)
|
||||||
cursor.execute(INSERT_SCALINGDATA, (self.RAW_MIN, self.RAW_MAX, self.GPM_MIN, self.GPM_MAX))
|
|
||||||
conn.commit()
|
def flowmonitor_setpressurerawmin(self, name, value):
|
||||||
|
"""Set the pressure raw min scaling value."""
|
||||||
|
try:
|
||||||
|
self.pressure_raw_min = float(value)
|
||||||
|
self.sendtodb("setpressurerawmin", self.pressure_raw_min, 0)
|
||||||
|
PERSIST['pressure_raw_min'] = self.pressure_raw_min
|
||||||
|
persistence.store(PERSIST)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("Could not set self.pressure_raw_min: {}".format(e))
|
||||||
|
return(True)
|
||||||
|
|
||||||
|
def flowmonitor_setpressurerawmax(self, name, value):
|
||||||
|
"""Set the pressure raw max scaling value."""
|
||||||
|
try:
|
||||||
|
self.pressure_raw_max = float(value)
|
||||||
|
self.sendtodb("setpressurerawmax", self.pressure_raw_max, 0)
|
||||||
|
PERSIST['pressure_raw_max'] = self.pressure_raw_max
|
||||||
|
persistence.store(PERSIST)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("Could not set self.pressure_raw_max: {}".format(e))
|
||||||
|
return(True)
|
||||||
|
|
||||||
|
def flowmonitor_setpressurepsimin(self, name, value):
|
||||||
|
"""Set the pressure psi min scaling value."""
|
||||||
|
try:
|
||||||
|
self.pressure_psi_min = float(value)
|
||||||
|
self.sendtodb("setpressurepsimin", self.pressure_psi_min, 0)
|
||||||
|
PERSIST['pressure_psi_min'] = self.pressure_psi_min
|
||||||
|
persistence.store(PERSIST)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("Could not set self.pressure_psi_min: {}".format(e))
|
||||||
|
return(True)
|
||||||
|
|
||||||
|
def flowmonitor_setpressurepsimax(self, name, value):
|
||||||
|
"""Set the pressure psi max scaling value."""
|
||||||
|
try:
|
||||||
|
self.pressure_psi_max = float(value)
|
||||||
|
self.sendtodb("setpressurepsimax", self.pressure_psi_max, 0)
|
||||||
|
PERSIST['pressure_psi_max'] = self.pressure_psi_max
|
||||||
|
persistence.store(PERSIST)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("Could not set self.pressure_psi_max: {}".format(e))
|
||||||
return(True)
|
return(True)
|
||||||
|
|
||||||
def flowmonitor_setgpmignorelimit(self, name, value):
|
def flowmonitor_setgpmignorelimit(self, name, value):
|
||||||
@@ -460,5 +566,5 @@ class start(threading.Thread, deviceBase):
|
|||||||
self.sendtodb("setgpmignorelimit", self.GPM_IGNORE_LIMIT, 0)
|
self.sendtodb("setgpmignorelimit", self.GPM_IGNORE_LIMIT, 0)
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Error during flowmonitor_setgpmignorelimit: {}".format(e))
|
logger.error("Error during flowmonitor_setgpmignorelimit: {}".format(e))
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user