Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
facb075d3f | ||
|
|
a5b0b83883 | ||
|
|
7fe71bb2e9 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -97,3 +97,4 @@ ENV/
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
/.pytest_cache
|
||||
|
||||
6
.vscode/settings.json
vendored
Normal file
6
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"python.unitTest.promptToConfigure": false,
|
||||
"python.unitTest.pyTestEnabled": false,
|
||||
"python.unitTest.unittestEnabled": false,
|
||||
"python.unitTest.nosetestsEnabled": false
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
data-nodename="promagmbs.volume_flow"
|
||||
data-units="<%= channels['promagmbs.volume_flow_units'].value %>"
|
||||
data-min="0"
|
||||
data-max="20000"
|
||||
data-max="40000"
|
||||
data-decimalplaces="2"
|
||||
data-colors="0.1:#DF5353,0.5:#DDDF0D,0.9:#55BF3B"
|
||||
data-valuefontsize="18px">
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
"""Driver for promagmbs."""
|
||||
|
||||
import threading
|
||||
from device_base import deviceBase
|
||||
from utilities import get_public_ip_address
|
||||
import time
|
||||
|
||||
|
||||
_ = None
|
||||
|
||||
|
||||
class start(threading.Thread, deviceBase):
|
||||
"""Start class required by Meshify."""
|
||||
|
||||
def __init__(self, name=None, number=None, mac=None, Q=None, mcu=None, companyId=None, offset=None, mqtt=None, Nodes=None):
|
||||
"""Initialize the driver."""
|
||||
threading.Thread.__init__(self)
|
||||
deviceBase.__init__(self, name=name, number=number, mac=mac, Q=Q, mcu=mcu, companyId=companyId, offset=offset, mqtt=mqtt, Nodes=Nodes)
|
||||
|
||||
self.daemon = True
|
||||
self.version = "1"
|
||||
self.finished = threading.Event()
|
||||
self.forceSend = False
|
||||
threading.Thread.start(self)
|
||||
|
||||
# this is a required function for all drivers, its goal is to upload some piece of data
|
||||
# about your device so it can be seen on the web
|
||||
def register(self):
|
||||
"""Register the driver."""
|
||||
# self.sendtodb("log", "BOOM! Booted.", 0)
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
# pass
|
||||
"""Actually run the driver."""
|
||||
global persist
|
||||
wait_sec = 60
|
||||
for i in range(0, wait_sec):
|
||||
print("promagmbs driver will start in {} seconds".format(wait_sec - i))
|
||||
time.sleep(1)
|
||||
print("BOOM! Starting promagmbs driver...")
|
||||
|
||||
public_ip_address = get_public_ip_address()
|
||||
self.sendtodbDev(1, 'public_ip_address', public_ip_address, 0, 'promagmbs')
|
||||
|
||||
send_loops = 0
|
||||
watchdog_loops = 0
|
||||
watchdog_check_after = 5000
|
||||
while True:
|
||||
if self.forceSend:
|
||||
print "FORCE SEND: TRUE"
|
||||
|
||||
print("promagmbs driver still alive...")
|
||||
if self.forceSend:
|
||||
if send_loops > 2:
|
||||
print("Turning off forceSend")
|
||||
self.forceSend = False
|
||||
send_loops = 0
|
||||
else:
|
||||
send_loops += 1
|
||||
|
||||
watchdog_loops += 1
|
||||
if (watchdog_loops >= watchdog_check_after):
|
||||
test_public_ip = get_public_ip_address()
|
||||
if not test_public_ip == public_ip_address:
|
||||
self.sendtodbDev(1, 'public_ip_address', test_public_ip, 0, 'promagmbs')
|
||||
public_ip_address = test_public_ip
|
||||
watchdog_loops = 0
|
||||
time.sleep(10)
|
||||
|
||||
def promagmbs_sync(self, name, value):
|
||||
"""Sync all data from the driver."""
|
||||
self.forceSend = True
|
||||
self.sendtodb("log", "synced", 0)
|
||||
return True
|
||||
Reference in New Issue
Block a user