diff --git a/.DS_Store b/.DS_Store index 9826451..6752808 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/meshifyDrivers/.DS_Store b/meshifyDrivers/.DS_Store index 8585a00..df7e13a 100644 Binary files a/meshifyDrivers/.DS_Store and b/meshifyDrivers/.DS_Store differ diff --git a/meshifyDrivers/mainHPRPI/config.txt b/meshifyDrivers/mainHPRPI/config.txt index 0b7e563..262e682 100644 --- a/meshifyDrivers/mainHPRPI/config.txt +++ b/meshifyDrivers/mainHPRPI/config.txt @@ -1,14 +1,12 @@ { - -"driverFileName":"mainMeshify.py", -"deviceName":"mainMeshify", -"driverId":"0000", -"releaseVersion":"16", -"files": { - "file1":"mainMeshify.py", - "file2":"main.py", - "file3":"device_base.py", - "file4":"meshifyData.py" + "driverFileName": "mainMeshify.py", + "deviceName": "mainMeshify", + "driverId": "0000", + "releaseVersion": "17", + "files": { + "file1": "mainMeshify.py", + "file2": "main.py", + "file3": "device_base.py", + "file4": "meshifyData.py" } - } \ No newline at end of file diff --git a/meshifyDrivers/mainHPRPI/device_base.py b/meshifyDrivers/mainHPRPI/device_base.py index 9745b1a..91e5914 100644 --- a/meshifyDrivers/mainHPRPI/device_base.py +++ b/meshifyDrivers/mainHPRPI/device_base.py @@ -143,6 +143,11 @@ class deviceBase(): topic = 'v1/devices/me/telemetry' print(topic, payload) self.q.put([topic, payload, 0]) + + def sendToTBAttributes(self, payload): + topic = 'v1/devices/me/attributes' + print(topic, payload) + self.q.put([topic, payload, 0]) def sendtodbCH(self, ch, channel, value, timestamp): diff --git a/meshifyDrivers/mainHPRPI/main.py b/meshifyDrivers/mainHPRPI/main.py index 388ffed..800d3d0 100644 --- a/meshifyDrivers/mainHPRPI/main.py +++ b/meshifyDrivers/mainHPRPI/main.py @@ -82,7 +82,7 @@ class main(): self.dst = "" # queue for sets to the mesh network will handeled through a queue in this main driver self.meshQ = Queue.Queue() - version = "16" # 6 - mistification # 5 - updated for SAT data and generic sets. 4 - devices changed to drivers for dia + version = "17" # 6 - mistification # 5 - updated for SAT data and generic sets. 4 - devices changed to drivers for dia # self.sendtodb("version", version, 0) thread.start_new_thread(self.registerThread, ()) @@ -1171,10 +1171,11 @@ class meshifyMain(): print("error understanding the mqtt message") def on_message(self, mosq, obj, msg): - print("!!!!!!! ON MESSAGE !!!!!!!") - print(msg.topic) - print(msg.payload) + try: + print("!!!!!!! ON MESSAGE !!!!!!!") + print(msg.topic) + print(msg.payload) if "rpc" in msg.topic: payload = {} payload["msgId"] = msg.topic.split("/")[-1] diff --git a/meshifyDrivers/mainHPRPI/mainMeshify.py b/meshifyDrivers/mainHPRPI/mainMeshify.py index 3ff7bc1..c378a73 100644 --- a/meshifyDrivers/mainHPRPI/mainMeshify.py +++ b/meshifyDrivers/mainHPRPI/mainMeshify.py @@ -27,7 +27,7 @@ class start(threading.Thread): print self.deviceName mac2 = mac.replace(":", "") self.mac = mac2.upper() - self.version = "16" #mistification #added Nodes in v5 + self.version = "17" #mistification #added Nodes in v5 self.finished = threading.Event() threading.Thread.start(self) diff --git a/meshifyDrivers/sync_to_aws.sh b/meshifyDrivers/sync_to_aws.sh new file mode 100755 index 0000000..c1d926a --- /dev/null +++ b/meshifyDrivers/sync_to_aws.sh @@ -0,0 +1,2 @@ +cd /Users/nico/Documents/GitHub/ThingsBoard/meshifyDrivers +aws s3 sync . s3://hp-thingsboard --acl public-read --exclude "*.DS_Store*" --exclude ".ipynb_checkpoints/" --exclude "*.zip*" --exclude "*.sh*" diff --git a/meshifyDrivers/sync_to_aws_dryrun.sh b/meshifyDrivers/sync_to_aws_dryrun.sh new file mode 100755 index 0000000..b5e8a9e --- /dev/null +++ b/meshifyDrivers/sync_to_aws_dryrun.sh @@ -0,0 +1,2 @@ +cd /Users/nico/Documents/GitHub/ThingsBoard/meshifyDrivers +aws s3 sync . s3://hp-thingsboard --acl public-read --exclude "*.DS_Store*" --exclude ".ipynb_checkpoints/" --exclude "*.zip*" --exclude "*.sh*" --dryrun diff --git a/meshifyDrivers/sync_to_local.sh b/meshifyDrivers/sync_to_local.sh new file mode 100755 index 0000000..444a295 --- /dev/null +++ b/meshifyDrivers/sync_to_local.sh @@ -0,0 +1,2 @@ +cd /Users/nico/Documents/GitHub/ThingsBoard/meshifyDrivers +aws s3 sync s3://hp-thingsboard . --exclude "*.DS_Store*" --exclude ".ipynb_checkpoints/" --exclude "*.zip*" --exclude "*.sh*" \ No newline at end of file diff --git a/meshifyDrivers/sync_to_local_dryrun.sh b/meshifyDrivers/sync_to_local_dryrun.sh new file mode 100755 index 0000000..9196b6c --- /dev/null +++ b/meshifyDrivers/sync_to_local_dryrun.sh @@ -0,0 +1,2 @@ +cd /Users/nico/Documents/GitHub/ThingsBoard/meshifyDrivers +aws s3 sync s3://hp-thingsboard . --exclude "*.DS_Store*" --exclude ".ipynb_checkpoints/" --exclude "*.zip*" --exclude "*.sh*" --dryrun \ No newline at end of file diff --git a/meshifyDrivers/tankalarms/config.txt b/meshifyDrivers/tankalarms/config.txt index 20519a9..9201ca0 100644 --- a/meshifyDrivers/tankalarms/config.txt +++ b/meshifyDrivers/tankalarms/config.txt @@ -8,7 +8,7 @@ "file4": "Tags.py" }, "deviceName": "tankalarms", - "releaseVersion": "3", + "releaseVersion": "4", "driverFileName": "tankalarms.py", "driverId": "0100" } \ No newline at end of file diff --git a/meshifyDrivers/tankalarms/tankalarms.py b/meshifyDrivers/tankalarms/tankalarms.py index 0ea5086..89b911f 100644 --- a/meshifyDrivers/tankalarms/tankalarms.py +++ b/meshifyDrivers/tankalarms/tankalarms.py @@ -17,7 +17,7 @@ _ = None log.info("tankalarms startup") # GLOBAL VARIABLES -WAIT_FOR_CONNECTION_SECONDS = 20 +WAIT_FOR_CONNECTION_SECONDS = 5 IP_CHECK_PERIOD = 60 @@ -39,7 +39,7 @@ class start(threading.Thread, deviceBase): mqtt=mqtt, Nodes=Nodes) self.daemon = True - self.version = "3" + self.version = "4" self.finished = threading.Event() self.force_send = False self.public_ip_address = "" @@ -73,7 +73,10 @@ class start(threading.Thread, deviceBase): if self.force_send: log.warning("FORCE SEND: TRUE") if int(time.time()) % 600 == 0 or self.force_send: - payload = {"ts": round(time.time()/600)*600*1000, "values": {}} + if self.force_send: + payload = {"ts": time.time()*1000, "values": {}} + else: + payload = {"ts": round(time.time()/600)*600*1000, "values": {}} for chan in CHANNELS: val = chan.read() payload["values"][chan.mesh_name] = val @@ -91,11 +94,7 @@ class start(threading.Thread, deviceBase): self.force_send = False send_loops = 0 else: - send_loops += 1 - - - - + send_loops += 1 except Exception as e: log.error(e) @@ -156,6 +155,7 @@ class start(threading.Thread, deviceBase): log.info("Result of tankalarms_alarmreset {}, {}, {}".format(name, value, write_res)) if write_res is None: write_res = "Error writing to PLC..." + self.sync("sync", 1) return write_res return False