added flowmeterskid and started reports

This commit is contained in:
Nico Melone
2023-08-01 15:41:29 -05:00
parent 58415dfdd7
commit 70b2f7c763
32 changed files with 20292 additions and 28 deletions

View File

@@ -33,12 +33,17 @@ class ThingsBoardAPI():
return devices.json()
def getDeviceKeys(self, devices,target_device):
for d in devices['data']:
if d["name"] == target_device:
did = d['id']['id']
eType = d['id']['entityType']
keys = requests.get(self.url_base + f"plugins/telemetry/{eType}/{did}/keys/timeseries", headers=self.headers)
return eType, did, keys.json()
try:
for d in devices['data']:
#print(d["name"])
if d["name"] == target_device:
did = d['id']['id']
eType = d['id']['entityType']
keys = requests.get(self.url_base + f"plugins/telemetry/{eType}/{did}/keys/timeseries", headers=self.headers)
return eType, did, keys.json(), None
return None,None,None,"Device Not Found"
except Exception as e:
return (None, None, None, e)
def getTelemetry(self, startTs, endTs, keys, eType, did):
telemetry = requests.get(self.url_base + f"plugins/telemetry/{eType}/{did}/values/timeseries?startTs={startTs}&endTs={endTs}&keys={keys}", headers=self.headers)