updated configs

This commit is contained in:
Nico Melone
2022-03-09 15:34:08 -06:00
parent 4fcc83760d
commit 9b3296a04b
19 changed files with 521 additions and 49 deletions

BIN
plcfreshwater/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -8,7 +8,7 @@
"file4": "Tags.py"
},
"deviceName": "plcfreshwater",
"releaseVersion": "14",
"releaseVersion": "16",
"driverFileName": "plcfreshwater.py",
"driverId": "0100"
}

View File

@@ -1,4 +1,5 @@
"""Driver for plcfreshwater"""
import logging
import threading
import json
import time
@@ -53,7 +54,7 @@ class start(threading.Thread, deviceBase):
mqtt=mqtt, Nodes=Nodes)
self.daemon = True
self.version = "14"
self.version = "16"
self.finished = threading.Event()
self.force_send = False
self.public_ip_address = ""
@@ -81,7 +82,7 @@ class start(threading.Thread, deviceBase):
print("plcfreshwater driver will start in {} seconds".format(WAIT_FOR_CONNECTION_SECONDS - i))
time.sleep(1)
global TOPIC_MAC, PLC_IP_ADDRESS, log, write_tag, PERSIST
global TOPIC_MAC, PLC_IP_ADDRESS, log, write_tag, read_tag, PERSIST
TOPIC_MAC = self.mac
@@ -204,14 +205,17 @@ class start(threading.Thread, deviceBase):
self.totals_counter = 0
if self.totals_counter >= 3:
self.fix_totals()
log.info("Would've run fix_totals!!!!")
self.totals_counter = 0
def fix_totals(self):
Daily_Holding = PERSIST["Daily Holding"] - PERSIST["Monthly Holding"]
resp = write_tag(self.plcip, "Lifetime_Flow_Meter_Gal", PERSIST["Lifetime"] - PERSIST["Monthly Holding"], plc_type="Micro800")
new_lifetime = PERSIST["Lifetime"] - PERSIST["Monthly Holding"]
resp = write_tag(self.plcip, "Lifetime_Flow_Meter_Gal", new_lifetime, plc_type="Micro800")
if resp == True:
PERSIST["Daily Holding"] = Daily_Holding
PERSIST["Monthly Holding"] = 0.0
PERSIST["Lifetime"] = new_lifetime
persistence.store(PERSIST, 'totalizers_{}.json'.format(self.mac))
log.info("RESETTING TOTALIZERS!!!")
@@ -254,7 +258,6 @@ class start(threading.Thread, deviceBase):
try:
if val - PERSIST["Lifetime"] > 0:
self.totalizing = True
PERSIST['Lifetime'] = val
else:
self.totalizing = False
except: