diff --git a/advvfdipp_reports.py b/advvfdipp_reports.py
new file mode 100644
index 0000000..7719278
--- /dev/null
+++ b/advvfdipp_reports.py
@@ -0,0 +1,146 @@
+"""Prepare and send daily reports for Advanced VFD IPP devices in Meshify."""
+import meshify
+import json
+from os import getenv
+from sys import exit
+from smtplib import SMTP
+from datetime import datetime
+from email.mime.multipart import MIMEMultipart
+from email.mime.text import MIMEText
+
+VALUES_TO_INCLUDE = {
+ 'flowtotalyesterday': 'Flow Total (Yesterday)',
+ 'pidcontrolmode': 'PID Control Mode',
+ 'wellstatus': 'Well Status',
+ 'downholesensorstatus': 'DH Sensor Status',
+ 'fluidlevel': 'Fluid Level',
+ 'intaketemperature': 'Intake Temperature',
+ 'intakepressure': 'Intake Pressure',
+ 'energytotalyesterday': 'Energy Total (Yesterday)',
+ 'tubingpressure': 'Tubing Pressure',
+ 'flowrate': 'Flow Rate'
+}
+
+SMTP_EMAIL = getenv("SMTP_EMAIL")
+SMTP_PASSWORD = getenv("SMTP_PASSWORD")
+
+def join_company_info(obj_with_companyId, company_lookup_obj):
+ """Add company information to an object with companyId property."""
+ obj_with_companyId['company'] = company_lookup_obj[obj_with_companyId['companyId']]
+ return obj_with_companyId
+
+
+def filter_object_parameters(ob, list_of_parameters):
+ """Return an object of just the list of paramters."""
+ new_ob = {}
+ for par in list_of_parameters:
+ try:
+ new_ob[par] = ob[par]
+ except KeyError:
+ new_ob[par] = None
+ return new_ob
+
+
+def group_by_company(devices):
+ """Group a list of devices by company."""
+ grouped = {}
+ for dev in devices:
+ try:
+ grouped[dev['company']['name']].append(dev)
+ except KeyError:
+ grouped[dev['company']['name']] = [dev]
+ return grouped
+
+
+def main(sendEmail=False):
+ """Get the data and optionally send an email."""
+ if sendEmail:
+ if not SMTP_EMAIL or not SMTP_PASSWORD:
+ print("Be sure to set the SMTP email and password as environment variables SMTP_EMAIL and SMTP_PASSWORD")
+ exit()
+
+ devicetypes = meshify.query_meshify_api("devicetypes")
+ advvfdipp_devicetype = meshify.find_by_name("advvfdipp", devicetypes)
+
+ companies = meshify.query_meshify_api("companies")
+ company_lookup = {}
+ for x in companies:
+ company_lookup[x['id']] = x
+
+ devices = meshify.query_meshify_api("devices")
+ advvfdipp_devices = filter(lambda x: x['deviceTypeId'] == advvfdipp_devicetype['id'], devices)
+ advvfdipp_devices = [join_company_info(x, company_lookup) for x in advvfdipp_devices]
+
+ for i in range(0, len(advvfdipp_devices)):
+ advvfdipp_devices[i]['values'] = filter_object_parameters(
+ meshify.query_meshify_api("devices/{}/values".format(advvfdipp_devices[i]['id'])), VALUES_TO_INCLUDE)
+ advvfdipp_devices = group_by_company(advvfdipp_devices)
+
+ totals = {}
+ for comp in advvfdipp_devices:
+ total = {}
+ average = {}
+ for v in VALUES_TO_INCLUDE:
+ total[v] = 0.0
+ average[v] = 0.0
+ for dev in advvfdipp_devices[comp]:
+ for v in VALUES_TO_INCLUDE:
+ try:
+ total[v] += float(dev['values'][v]['value'])
+ except ValueError:
+ print("Can't make a total for {}".format(v))
+ totals[comp] = total
+
+ for comp in advvfdipp_devices:
+ total = []
+ average = []
+
+ header = "Well Name,"
+ table_header = "| Well Name | "
+ for v in VALUES_TO_INCLUDE:
+ header += "{},".format(VALUES_TO_INCLUDE[v])
+ table_header += "{} | ".format(VALUES_TO_INCLUDE[v])
+ header = header[:-1] + "\n"
+ table_header += "
"
+
+ values = ""
+ table_body = "
"
+ for dev in advvfdipp_devices[comp]:
+ values += dev['vanityName'] + ","
+ table_body += "| {} | ".format(dev['vanityName'])
+ for v in VALUES_TO_INCLUDE:
+ values += dev['values'][v]['value'] + ","
+ table_body += "{} | ".format(dev['values'][v]['value'])
+ values = values[:-1] + "\n"
+ table_body += "
"
+ table_body += ""
+
+ table = "".format(table_header, table_body)
+
+ part1 = MIMEText(header + values, "plain")
+ part2 = MIMEText(table, "html")
+
+ now = datetime.now()
+ datestr = now.strftime("%a %b %d, %Y")
+ msg = MIMEMultipart('alternative')
+ msg['Subject'] = "{} SAMPLE Daily Report for {}".format(comp, datestr)
+ msg.attach(part1)
+ msg.attach(part2)
+
+ if sendEmail:
+ s = SMTP(host="secure.emailsrvr.com", port=25)
+ s.login(SMTP_EMAIL, SMTP_PASSWORD)
+ s.sendmail(from_addr="alerts@henry-pump.com", to_addrs=["pmcdonagh@henry-pump.com"], msg=msg.as_string())
+ else:
+ print(msg)
+
+ with open('{}.csv'.format(comp), 'wb') as csvfile:
+ csvfile.write(header + values)
+
+ advvfdipp_devices["totals"] = totals
+ with open("currentAdvVFDIPP.json", 'wb') as jsonfile:
+ json.dump(advvfdipp_devices, jsonfile, indent=4)
+
+
+if __name__ == '__main__':
+ main(sendEmail=False)
diff --git a/currentAdvVFDIPP.json b/currentAdvVFDIPP.json
new file mode 100644
index 0000000..c2a95c5
--- /dev/null
+++ b/currentAdvVFDIPP.json
@@ -0,0 +1,1656 @@
+{
+ "Henry Resources Water": [
+ {
+ "macAddress": "c4:93:00:05:dd:f0:01:99",
+ "companyId": 896,
+ "company": {
+ "tenantId": 194,
+ "id": 896,
+ "addressId": 7243,
+ "name": "Henry Resources Water"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493228329,
+ "value": "18.3004570007"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493215031,
+ "value": "1830.1751709"
+ },
+ "intakepressure": {
+ "timestamp": 1493226903,
+ "value": "10.7999992371"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1491285425,
+ "value": "1441.30664063"
+ },
+ "fluidlevel": {
+ "timestamp": 1493225082,
+ "value": "39.8676605225"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493227050,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493227050,
+ "value": "80.6999969482"
+ },
+ "flowrate": {
+ "timestamp": 1493225560,
+ "value": "50.2718429565"
+ },
+ "wellstatus": {
+ "timestamp": 1493226383,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493227062,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 4339,
+ "techname": "advvfdipp_[c4:93:00:05:dd:f0:01:99]",
+ "vanityName": "Gwendolyn SR #6",
+ "id": 3932727
+ },
+ {
+ "macAddress": "c4:93:00:03:7e:ec:01:99",
+ "companyId": 896,
+ "company": {
+ "tenantId": 194,
+ "id": 896,
+ "addressId": 7243,
+ "name": "Henry Resources Water"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493228346,
+ "value": "9.10575771332"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493228346,
+ "value": "2290.24389648"
+ },
+ "intakepressure": {
+ "timestamp": 1493228346,
+ "value": "16.2999992371"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1491428432,
+ "value": ""
+ },
+ "fluidlevel": {
+ "timestamp": 1493228346,
+ "value": "51.5317459106"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493228346,
+ "value": "Manual"
+ },
+ "intaketemperature": {
+ "timestamp": 1493228346,
+ "value": "79.3000030518"
+ },
+ "flowrate": {
+ "timestamp": 1493228346,
+ "value": "64.0742950439"
+ },
+ "wellstatus": {
+ "timestamp": 1493228346,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493228347,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 4425,
+ "techname": "advvfdipp_[c4:93:00:03:7e:ec:01:99]",
+ "vanityName": "Gwendolyn SR #1",
+ "id": 3933310
+ },
+ {
+ "macAddress": "c4:93:00:03:7c:dc:01:99",
+ "companyId": 896,
+ "company": {
+ "tenantId": 194,
+ "id": 896,
+ "addressId": 7243,
+ "name": "Henry Resources Water"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493228242,
+ "value": "28.399477005"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493221644,
+ "value": "380.793273926"
+ },
+ "intakepressure": {
+ "timestamp": 1493226274,
+ "value": "28.7999992371"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1491436293,
+ "value": ""
+ },
+ "fluidlevel": {
+ "timestamp": 1493228398,
+ "value": "80.5440216064"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493225265,
+ "value": "Manual"
+ },
+ "intaketemperature": {
+ "timestamp": 1493226918,
+ "value": "81.6999969482"
+ },
+ "flowrate": {
+ "timestamp": 1493226517,
+ "value": "50.8343048096"
+ },
+ "wellstatus": {
+ "timestamp": 1493227466,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493227138,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 4426,
+ "techname": "advvfdipp_[c4:93:00:03:7c:dc:01:99]",
+ "vanityName": "Gwendolyn SR #6",
+ "id": 3933315
+ },
+ {
+ "macAddress": "c4:93:00:03:56:ea:01:99",
+ "companyId": 896,
+ "company": {
+ "tenantId": 194,
+ "id": 896,
+ "addressId": 7243,
+ "name": "Henry Resources Water"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493225463,
+ "value": "22.7454776764"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493224080,
+ "value": "1695.83007813"
+ },
+ "intakepressure": {
+ "timestamp": 1493226485,
+ "value": "77.9000015259"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1493209687,
+ "value": "488.068847656"
+ },
+ "fluidlevel": {
+ "timestamp": 1493226824,
+ "value": "194.369522095"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493228496,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493227441,
+ "value": "79.3000030518"
+ },
+ "flowrate": {
+ "timestamp": 1493228478,
+ "value": "66.3237991333"
+ },
+ "wellstatus": {
+ "timestamp": 1493227613,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493227441,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 4484,
+ "techname": "advvfdipp_[c4:93:00:03:56:ea:01:99]",
+ "vanityName": "Gwendolyn SR #4",
+ "id": 3933631
+ },
+ {
+ "macAddress": "c4:93:00:03:7e:d7:01:99",
+ "companyId": 896,
+ "company": {
+ "tenantId": 194,
+ "id": 896,
+ "addressId": 7243,
+ "name": "Henry Resources Water"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493226989,
+ "value": "13.7696962357"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493221576,
+ "value": "1449.1282959"
+ },
+ "intakepressure": {
+ "timestamp": 1493227934,
+ "value": "10.7999992371"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1492099972,
+ "value": ""
+ },
+ "fluidlevel": {
+ "timestamp": 1493228626,
+ "value": "40.0979156494"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493227503,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493228101,
+ "value": "78.6999969482"
+ },
+ "flowrate": {
+ "timestamp": 1493225992,
+ "value": "40.3088912964"
+ },
+ "wellstatus": {
+ "timestamp": 1493226081,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493228095,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 4485,
+ "techname": "advvfdipp_[c4:93:00:03:7e:d7:01:99]",
+ "vanityName": "Gwendolyn SR #10",
+ "id": 3933634
+ },
+ {
+ "macAddress": "c4:93:00:06:71:77:01:99",
+ "companyId": 896,
+ "company": {
+ "tenantId": 194,
+ "id": 896,
+ "addressId": 7243,
+ "name": "Henry Resources Water"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493226946,
+ "value": "9.37933540344"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493216326,
+ "value": "1996.01477051"
+ },
+ "intakepressure": {
+ "timestamp": 1493227005,
+ "value": "10.8999996185"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1493201938,
+ "value": "437.344238281"
+ },
+ "fluidlevel": {
+ "timestamp": 1493225544,
+ "value": "39.8676605225"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493225705,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493225711,
+ "value": "75.9000015259"
+ },
+ "flowrate": {
+ "timestamp": 1493228173,
+ "value": "54.5472297668"
+ },
+ "wellstatus": {
+ "timestamp": 1493226521,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493225688,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 4487,
+ "techname": "advvfdipp_[c4:93:00:06:71:77:01:99]",
+ "vanityName": "Gwendolyn SR #2",
+ "id": 3933639
+ },
+ {
+ "macAddress": "c4:93:00:08:d4:46:01:99",
+ "companyId": 896,
+ "company": {
+ "tenantId": 194,
+ "id": 896,
+ "addressId": 7243,
+ "name": "Henry Resources Water"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493225587,
+ "value": "19.5471019745"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493216458,
+ "value": "3073.87158203"
+ },
+ "intakepressure": {
+ "timestamp": 1493225587,
+ "value": "56.3000030518"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1493131921,
+ "value": ""
+ },
+ "fluidlevel": {
+ "timestamp": 1493225587,
+ "value": "144.63420105"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493225587,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493225587,
+ "value": "77.5999984741"
+ },
+ "flowrate": {
+ "timestamp": 1493225587,
+ "value": "88.4156951904"
+ },
+ "wellstatus": {
+ "timestamp": 1493225587,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493225599,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 4550,
+ "techname": "advvfdipp_[c4:93:00:08:d4:46:01:99]",
+ "vanityName": "Gwendolyn SR #3",
+ "id": 3934920
+ },
+ {
+ "macAddress": "c4:93:00:03:56:7e:01:99",
+ "companyId": 896,
+ "company": {
+ "tenantId": 194,
+ "id": 896,
+ "addressId": 7243,
+ "name": "Henry Resources Water"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493228127,
+ "value": "45.1984825134"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493226761,
+ "value": "2747.64379883"
+ },
+ "intakepressure": {
+ "timestamp": 1493226125,
+ "value": "24.2999992371"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1493132439,
+ "value": ""
+ },
+ "fluidlevel": {
+ "timestamp": 1493226125,
+ "value": "70.9522323608"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493228061,
+ "value": "Manual"
+ },
+ "intaketemperature": {
+ "timestamp": 1493226125,
+ "value": "79.3000030518"
+ },
+ "flowrate": {
+ "timestamp": 1493228145,
+ "value": "78.4337463379"
+ },
+ "wellstatus": {
+ "timestamp": 1493226125,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493226119,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 4551,
+ "techname": "advvfdipp_[c4:93:00:03:56:7e:01:99]",
+ "vanityName": "Gwendolyn SR #5",
+ "id": 3934926
+ },
+ {
+ "macAddress": "c4:93:00:03:69:dd:01:99",
+ "companyId": 896,
+ "company": {
+ "tenantId": 194,
+ "id": 896,
+ "addressId": 7243,
+ "name": "Henry Resources Water"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493225588,
+ "value": "11.5071105957"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493227758,
+ "value": "1645.53125"
+ },
+ "intakepressure": {
+ "timestamp": 1493228316,
+ "value": "10.7999992371"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1493132686,
+ "value": ""
+ },
+ "fluidlevel": {
+ "timestamp": 1493225543,
+ "value": "40.0979156494"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493227980,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493226360,
+ "value": "76.5999984741"
+ },
+ "flowrate": {
+ "timestamp": 1493225194,
+ "value": "47.5720214844"
+ },
+ "wellstatus": {
+ "timestamp": 1493227859,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493226366,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 4552,
+ "techname": "advvfdipp_[c4:93:00:03:69:dd:01:99]",
+ "vanityName": "Gwendolyn SR #8",
+ "id": 3934934
+ }
+ ],
+ "CrownQuest": [
+ {
+ "macAddress": "c4:93:00:03:57:35:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493227473,
+ "value": "19.9847984314"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493215576,
+ "value": "3601.93945313"
+ },
+ "intakepressure": {
+ "timestamp": 1493227081,
+ "value": "8.0"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1493215581,
+ "value": "8388.14257813"
+ },
+ "fluidlevel": {
+ "timestamp": 1493227076,
+ "value": "33.4204864502"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493226542,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493226552,
+ "value": "79.6999969482"
+ },
+ "flowrate": {
+ "timestamp": 1493226903,
+ "value": "104.830314636"
+ },
+ "wellstatus": {
+ "timestamp": 1493226180,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493226603,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 3345,
+ "techname": "advvfdipp_[c4:93:00:03:57:35:01:99]",
+ "vanityName": "LimeQuest 5 SR 5",
+ "id": 3932667
+ },
+ {
+ "macAddress": "c4:93:00:03:69:ce:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493226439,
+ "value": "7.86413383484"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493222502,
+ "value": "1334.34094238"
+ },
+ "intakepressure": {
+ "timestamp": 1493226481,
+ "value": "10.8999996185"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1493222502,
+ "value": "783.25"
+ },
+ "fluidlevel": {
+ "timestamp": 1493226596,
+ "value": "40.0979156494"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493225557,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493228028,
+ "value": "82.0999984741"
+ },
+ "flowrate": {
+ "timestamp": 1493228565,
+ "value": "38.2334442139"
+ },
+ "wellstatus": {
+ "timestamp": 1493226590,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493228017,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 3407,
+ "techname": "advvfdipp_[c4:93:00:03:69:ce:01:99]",
+ "vanityName": "Nail Hole 37 SR #1",
+ "id": 3926921
+ },
+ {
+ "macAddress": "c4:93:00:03:7c:ee:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1492292290,
+ "value": "22.5845012665"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1492284069,
+ "value": "1069.93994141"
+ },
+ "intakepressure": {
+ "timestamp": 1492292692,
+ "value": "66.5"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1492284069,
+ "value": "452.55078125"
+ },
+ "fluidlevel": {
+ "timestamp": 1492293576,
+ "value": "168.35055542"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1492292279,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1492292279,
+ "value": "81.0999984741"
+ },
+ "flowrate": {
+ "timestamp": 1492293464,
+ "value": "0.0"
+ },
+ "wellstatus": {
+ "timestamp": 1492293558,
+ "value": "Alarmed"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1492292297,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 3409,
+ "techname": "advvfdipp_[c4:93:00:03:7c:ee:01:99]",
+ "vanityName": "Nail Hole 37 SR #2",
+ "id": 3926913
+ },
+ {
+ "macAddress": "c4:93:00:05:dd:a2:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493227931,
+ "value": "23.7576370239"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493218756,
+ "value": "1877.75866699"
+ },
+ "intakepressure": {
+ "timestamp": 1493227931,
+ "value": "10.8999996185"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1493218756,
+ "value": "702.53125"
+ },
+ "fluidlevel": {
+ "timestamp": 1493227931,
+ "value": "40.0979156494"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493227931,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493227931,
+ "value": "81.4000015259"
+ },
+ "flowrate": {
+ "timestamp": 1493226062,
+ "value": "54.7539215088"
+ },
+ "wellstatus": {
+ "timestamp": 1493227931,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493227913,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 3659,
+ "techname": "advvfdipp_[c4:93:00:05:dd:a2:01:99]",
+ "vanityName": "Nail Ranch 2 SR #2",
+ "id": 3924718
+ },
+ {
+ "macAddress": "c4:93:00:03:54:c5:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493227296,
+ "value": "23.7407226563"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493215820,
+ "value": "2608.20019531"
+ },
+ "intakepressure": {
+ "timestamp": 1493226721,
+ "value": "10.8999996185"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1493215820,
+ "value": "741.765625"
+ },
+ "fluidlevel": {
+ "timestamp": 1493226721,
+ "value": "40.0979156494"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493226721,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493226684,
+ "value": "81.0999984741"
+ },
+ "flowrate": {
+ "timestamp": 1493228607,
+ "value": "78.3786315918"
+ },
+ "wellstatus": {
+ "timestamp": 1493226721,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493226697,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 3759,
+ "techname": "advvfdipp_[c4:93:00:03:54:c5:01:99]",
+ "vanityName": "Nail Ranch 38 SR 2 IPP",
+ "id": 3925838
+ },
+ {
+ "macAddress": "c4:93:00:03:69:c8:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493226903,
+ "value": "16.1084403992"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493221696,
+ "value": "1439.98950195"
+ },
+ "intakepressure": {
+ "timestamp": 1493226730,
+ "value": "10.8999996185"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1493221696,
+ "value": "595.5546875"
+ },
+ "fluidlevel": {
+ "timestamp": 1493226736,
+ "value": "40.0979156494"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493226724,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493226736,
+ "value": "85.9000015259"
+ },
+ "flowrate": {
+ "timestamp": 1493227340,
+ "value": "42.2457504272"
+ },
+ "wellstatus": {
+ "timestamp": 1493226724,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493228051,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 3782,
+ "techname": "advvfdipp_[c4:93:00:03:69:c8:01:99]",
+ "vanityName": "Nail Ranch 25 SR #1",
+ "id": 3925937
+ },
+ {
+ "macAddress": "c4:93:00:03:57:38:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493227569,
+ "value": "13.9165878296"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493218415,
+ "value": "1408.33862305"
+ },
+ "intakepressure": {
+ "timestamp": 1493226994,
+ "value": "986.0"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1493218420,
+ "value": "551.84375"
+ },
+ "fluidlevel": {
+ "timestamp": 1491690455,
+ "value": "898.262451172"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493226453,
+ "value": "Manual"
+ },
+ "intaketemperature": {
+ "timestamp": 1493226280,
+ "value": "81.6999969482"
+ },
+ "flowrate": {
+ "timestamp": 1493226632,
+ "value": "40.7289619446"
+ },
+ "wellstatus": {
+ "timestamp": 1493226275,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493226147,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 3826,
+ "techname": "advvfdipp_[c4:93:00:03:57:38:01:99]",
+ "vanityName": "Nail Ranch 2 SR #1",
+ "id": 3926319
+ },
+ {
+ "macAddress": "c4:93:00:05:dd:ed:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493228356,
+ "value": "19.9137744904"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493215258,
+ "value": "1950.67431641"
+ },
+ "intakepressure": {
+ "timestamp": 1493228356,
+ "value": "10.8999996185"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1493215258,
+ "value": "642.7890625"
+ },
+ "fluidlevel": {
+ "timestamp": 1493228356,
+ "value": "40.0979156494"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493228356,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493228350,
+ "value": "81.6999969482"
+ },
+ "flowrate": {
+ "timestamp": 1493228368,
+ "value": "56.6236877441"
+ },
+ "wellstatus": {
+ "timestamp": 1493228350,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493228362,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 3861,
+ "techname": "advvfdipp_[c4:93:00:05:dd:ed:01:99]",
+ "vanityName": "Nail Ranch 28 SR #3",
+ "id": 3926715
+ },
+ {
+ "macAddress": "c4:93:00:05:de:3e:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493225725,
+ "value": "42.3703536987"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493219707,
+ "value": "3312.11645508"
+ },
+ "intakepressure": {
+ "timestamp": 1493225701,
+ "value": "986.0"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1493219707,
+ "value": "935.9375"
+ },
+ "fluidlevel": {
+ "timestamp": 1479894628,
+ "value": "26.743062973"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493225695,
+ "value": "Manual"
+ },
+ "intaketemperature": {
+ "timestamp": 1493225926,
+ "value": "0.0"
+ },
+ "flowrate": {
+ "timestamp": 1493225707,
+ "value": "95.7372894287"
+ },
+ "wellstatus": {
+ "timestamp": 1493225713,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493227963,
+ "value": "Cannot Decode"
+ }
+ },
+ "gatewayId": 3934,
+ "techname": "advvfdipp_[c4:93:00:05:de:3e:01:99]",
+ "vanityName": "Nail Ranch 12 SR #1",
+ "id": 3927557
+ },
+ {
+ "macAddress": "c4:93:00:03:56:7b:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493227310,
+ "value": "38.9572639465"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493216242,
+ "value": "3567.66772461"
+ },
+ "intakepressure": {
+ "timestamp": 1493228093,
+ "value": "50.8000030518"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1493216242,
+ "value": "1188.328125"
+ },
+ "fluidlevel": {
+ "timestamp": 1493228033,
+ "value": "131.970123291"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493228039,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493228039,
+ "value": "81.4000015259"
+ },
+ "flowrate": {
+ "timestamp": 1493228093,
+ "value": "104.219367981"
+ },
+ "wellstatus": {
+ "timestamp": 1493228039,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493228093,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 3958,
+ "techname": "advvfdipp_[c4:93:00:03:56:7b:01:99]",
+ "vanityName": "Nail Ranch 38 SR #1",
+ "id": 3927840
+ },
+ {
+ "macAddress": "c4:93:00:03:6b:12:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493228121,
+ "value": "10.622549057"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493224642,
+ "value": "1546.71081543"
+ },
+ "intakepressure": {
+ "timestamp": 1493228591,
+ "value": "10.8999996185"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1493224642,
+ "value": "776.5546875"
+ },
+ "fluidlevel": {
+ "timestamp": 1493228591,
+ "value": "40.0979156494"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493228578,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493228578,
+ "value": "82.8000030518"
+ },
+ "flowrate": {
+ "timestamp": 1493228578,
+ "value": "45.2123947144"
+ },
+ "wellstatus": {
+ "timestamp": 1493228578,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493228560,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 3995,
+ "techname": "advvfdipp_[c4:93:00:03:6b:12:01:99]",
+ "vanityName": "Nail Ranch 3 SR #1",
+ "id": 3927991
+ },
+ {
+ "macAddress": "c4:93:00:03:7f:b2:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493227324,
+ "value": "22.1607379913"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493216500,
+ "value": "1326.73144531"
+ },
+ "intakepressure": {
+ "timestamp": 1493228448,
+ "value": "10.8999996185"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1483348927,
+ "value": "1884.15185547"
+ },
+ "fluidlevel": {
+ "timestamp": 1493228448,
+ "value": "40.0979156494"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493228478,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493228484,
+ "value": "83.0999984741"
+ },
+ "flowrate": {
+ "timestamp": 1493228448,
+ "value": "38.7622947693"
+ },
+ "wellstatus": {
+ "timestamp": 1493228478,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493228513,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 4039,
+ "techname": "advvfdipp_[c4:93:00:03:7f:b2:01:99]",
+ "vanityName": "Nail Ranch 28 SR #1",
+ "id": 3930142
+ },
+ {
+ "macAddress": "c4:93:00:05:85:1f:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493226634,
+ "value": "14.8771743774"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493226355,
+ "value": "1634.46203613"
+ },
+ "intakepressure": {
+ "timestamp": 1493226657,
+ "value": "10.7999992371"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1487779773,
+ "value": "1949.76513672"
+ },
+ "fluidlevel": {
+ "timestamp": 1493226663,
+ "value": "39.8676605225"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493226657,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493226657,
+ "value": "82.4000015259"
+ },
+ "flowrate": {
+ "timestamp": 1493226663,
+ "value": "47.5450019836"
+ },
+ "wellstatus": {
+ "timestamp": 1493226657,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493226657,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 4054,
+ "techname": "advvfdipp_[c4:93:00:05:85:1f:01:99]",
+ "vanityName": "Nail Ranch 28 SR #2",
+ "id": 3930348
+ },
+ {
+ "macAddress": "c4:93:00:03:69:e9:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493203701,
+ "value": "19.9834194183"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493223551,
+ "value": "1974.85717773"
+ },
+ "intakepressure": {
+ "timestamp": 1493226081,
+ "value": "108.800003052"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1491221954,
+ "value": "1378.55078125"
+ },
+ "fluidlevel": {
+ "timestamp": 1493226880,
+ "value": "265.748901367"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493228407,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493228407,
+ "value": "72.8000030518"
+ },
+ "flowrate": {
+ "timestamp": 1493203864,
+ "value": "72.7837219238"
+ },
+ "wellstatus": {
+ "timestamp": 1493228407,
+ "value": "Stopped"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493228408,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 4324,
+ "techname": "advvfdipp_[c4:93:00:03:69:e9:01:99]",
+ "vanityName": "LimeQuest 5 SR 1",
+ "id": 3932638
+ },
+ {
+ "macAddress": "c4:93:00:03:54:f2:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493226211,
+ "value": "36.7368278503"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493215962,
+ "value": "4558.32763672"
+ },
+ "intakepressure": {
+ "timestamp": 1493225271,
+ "value": "10.7999992371"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1491490190,
+ "value": "1835.22363281"
+ },
+ "fluidlevel": {
+ "timestamp": 1493227828,
+ "value": "39.8676605225"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493226745,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493226755,
+ "value": "75.5999984741"
+ },
+ "flowrate": {
+ "timestamp": 1493227290,
+ "value": "131.806396484"
+ },
+ "wellstatus": {
+ "timestamp": 1493226201,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493226807,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 4327,
+ "techname": "advvfdipp_[c4:93:00:03:54:f2:01:99]",
+ "vanityName": "LimeQuest 10 SR #1",
+ "id": 3932648
+ },
+ {
+ "macAddress": "c4:93:00:03:7e:cb:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493227560,
+ "value": "43.8650894165"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493217356,
+ "value": "5444.55371094"
+ },
+ "intakepressure": {
+ "timestamp": 1493227578,
+ "value": "41.4000015259"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1490360530,
+ "value": "1475.54248047"
+ },
+ "fluidlevel": {
+ "timestamp": 1493227525,
+ "value": "110.326026917"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493227578,
+ "value": "Manual"
+ },
+ "intaketemperature": {
+ "timestamp": 1493227554,
+ "value": "77.5999984741"
+ },
+ "flowrate": {
+ "timestamp": 1493226670,
+ "value": "156.223434448"
+ },
+ "wellstatus": {
+ "timestamp": 1493227554,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493227543,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 4328,
+ "techname": "advvfdipp_[c4:93:00:03:7e:cb:01:99]",
+ "vanityName": "LimeQuest 6 SR 1",
+ "id": 3932655
+ },
+ {
+ "macAddress": "c4:93:00:03:57:a7:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493227629,
+ "value": "18.746049881"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493225889,
+ "value": "1788.61547852"
+ },
+ "intakepressure": {
+ "timestamp": 1493226977,
+ "value": "10.8999996185"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1492693102,
+ "value": "1504.23876953"
+ },
+ "fluidlevel": {
+ "timestamp": 1493226067,
+ "value": "40.0979156494"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493228055,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493228043,
+ "value": "75.1999969482"
+ },
+ "flowrate": {
+ "timestamp": 1493227707,
+ "value": "52.0197410583"
+ },
+ "wellstatus": {
+ "timestamp": 1493226436,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493228043,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 4331,
+ "techname": "advvfdipp_[c4:93:00:03:57:a7:01:99]",
+ "vanityName": "LimeQuest 5 SR 3",
+ "id": 3932670
+ },
+ {
+ "macAddress": "c4:93:00:03:7f:70:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493227744,
+ "value": "10.5503034592"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493220617,
+ "value": "2154.27099609"
+ },
+ "intakepressure": {
+ "timestamp": 1493227902,
+ "value": "10.8999996185"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1492601565,
+ "value": "1456.04833984"
+ },
+ "fluidlevel": {
+ "timestamp": 1493227897,
+ "value": "40.0979156494"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493226264,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493225909,
+ "value": "76.3000030518"
+ },
+ "flowrate": {
+ "timestamp": 1493225893,
+ "value": "63.5497550964"
+ },
+ "wellstatus": {
+ "timestamp": 1493226452,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493225959,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 4334,
+ "techname": "advvfdipp_[c4:93:00:03:7f:70:01:99]",
+ "vanityName": "LimeQuest 5 SR 2",
+ "id": 3932677
+ },
+ {
+ "macAddress": "c4:93:00:03:65:00:01:99",
+ "companyId": 628,
+ "company": {
+ "tenantId": 194,
+ "id": 628,
+ "addressId": 5389,
+ "name": "CrownQuest"
+ },
+ "tenantId": 194,
+ "deviceTypeId": 272,
+ "values": {
+ "tubingpressure": {
+ "timestamp": 1493228289,
+ "value": "14.357298851"
+ },
+ "flowtotalyesterday": {
+ "timestamp": 1493228402,
+ "value": "1374.38232422"
+ },
+ "intakepressure": {
+ "timestamp": 1493228242,
+ "value": "10.7000007629"
+ },
+ "energytotalyesterday": {
+ "timestamp": 1489612223,
+ "value": ""
+ },
+ "fluidlevel": {
+ "timestamp": 1493228306,
+ "value": "40.0979156494"
+ },
+ "pidcontrolmode": {
+ "timestamp": 1493228142,
+ "value": "Fluid Level"
+ },
+ "intaketemperature": {
+ "timestamp": 1493227905,
+ "value": "77.3000030518"
+ },
+ "flowrate": {
+ "timestamp": 1493228672,
+ "value": "37.401222229"
+ },
+ "wellstatus": {
+ "timestamp": 1493227893,
+ "value": "Running"
+ },
+ "downholesensorstatus": {
+ "timestamp": 1493227923,
+ "value": "OK"
+ }
+ },
+ "gatewayId": 4336,
+ "techname": "advvfdipp_[c4:93:00:03:65:00:01:99]",
+ "vanityName": "LimeQuest 5 SR 7",
+ "id": 3932686
+ }
+ ],
+ "totals": {
+ "Henry Resources Water": {
+ "tubingpressure": 177.95289611816,
+ "flowtotalyesterday": 17109.232116706,
+ "intakepressure": 246.89999961879997,
+ "energytotalyesterday": 2366.7197265669997,
+ "fluidlevel": 701.9628753666,
+ "pidcontrolmode": 0.0,
+ "intaketemperature": 709.0999984741,
+ "flowrate": 540.7818260192,
+ "wellstatus": 0.0,
+ "downholesensorstatus": 0.0
+ },
+ "CrownQuest": {
+ "tubingpressure": 421.09766387933996,
+ "flowtotalyesterday": 43973.877441410004,
+ "intakepressure": 2377.9000034333,
+ "energytotalyesterday": 27242.76904297,
+ "fluidlevel": 2115.5360851292,
+ "pidcontrolmode": 0.0,
+ "intaketemperature": 1439.1999969482001,
+ "flowrate": 1261.0553321829002,
+ "wellstatus": 0.0,
+ "downholesensorstatus": 0.0
+ }
+ }
+}
\ No newline at end of file
diff --git a/getAllDevices.py b/getAllDevices.py
new file mode 100644
index 0000000..75f5bfb
--- /dev/null
+++ b/getAllDevices.py
@@ -0,0 +1,18 @@
+"""Get all gateways from the Meshify API."""
+import meshify
+
+
+def main():
+ """Run the main function."""
+ gateways = meshify.query_meshify_api("gateways")
+ with open("gateways.json", 'wb') as jsonfile:
+ json.dump(gateways, jsonfile, indent=4, sort_keys=True)
+ csv_string = "Gateway,ipaddress,url\n"
+ for g in gateways:
+ csv_string += "{},,\n".format(g['name'])
+
+ with open("gateways.csv", 'wb') as csvfile:
+ csvfile.write(csv_string)
+
+if __name__ == '__main__':
+ main()
diff --git a/henryPetroleumMeshifyAPI.py b/henryPetroleumMeshifyAPI.py
index b559576..cfdd7bd 100644
--- a/henryPetroleumMeshifyAPI.py
+++ b/henryPetroleumMeshifyAPI.py
@@ -3,11 +3,7 @@ import json
from os import getenv
from sys import exit, argv
from datetime import datetime
-
-MESHIFY_BASE_URL = "https://henrypump.meshify.com/api/v3/"
-MESHIFY_USERNAME = getenv("MESHIFY_USERNAME")
-MESHIFY_PASSWORD = getenv("MESHIFY_PASSWORD")
-MESHIFY_AUTH = requests.auth.HTTPBasicAuth(MESHIFY_USERNAME, MESHIFY_PASSWORD)
+import meshify
SQL_SERVER = getenv("HP_SQL_SERVER")
SQL_USER = getenv("HP_SQL_USER")
@@ -17,19 +13,6 @@ SQL_DB = "POCCLoud"
SQL_TABLE = "Production"
-def find_by_name(name, list_of_stuff):
- for x in list_of_stuff:
- if x['name'] == name:
- return x
- return False
-
-
-def query_meshify_api(endpoint):
- q_url = MESHIFY_BASE_URL + endpoint
- q_req = requests.get(q_url, auth=MESHIFY_AUTH)
- return json.loads(q_req.text) if q_req.status_code == 200 else []
-
-
def main(test_mode=False):
if not MESHIFY_USERNAME or not MESHIFY_PASSWORD:
print("Be sure to set the meshify username and password as environment variables MESHIFY_USERNAME and MESHIFY_PASSWORD")
@@ -42,21 +25,21 @@ def main(test_mode=False):
if not test_mode:
import pymssql
- devicetypes = query_meshify_api("devicetypes")
- companies = query_meshify_api("companies")
- henrypetroleum_company = find_by_name("Henry Petroleum", companies)
- devices = query_meshify_api("devices")
- gateways = query_meshify_api("gateways")
+ devicetypes = meshify.query_meshify_api("devicetypes")
+ companies = meshify.query_meshify_api("companies")
+ henrypetroleum_company = meshify.find_by_name("Henry Petroleum", companies)
+ devices = meshify.query_meshify_api("devices")
+ gateways = meshify.query_meshify_api("gateways")
- abbflow_devicetype = find_by_name("abbflow", devicetypes)
+ abbflow_devicetype = meshify.find_by_name("abbflow", devicetypes)
abbflow_devices = list(filter(lambda x: x['deviceTypeId'] == abbflow_devicetype['id'] and x['companyId'] == henrypetroleum_company['id'], devices))
- abbflowchannels = query_meshify_api("devicetypes/{}/channels".format(abbflow_devicetype['id']))
+ abbflowchannels = meshify.query_meshify_api("devicetypes/{}/channels".format(abbflow_devicetype['id']))
- abbflow_yesterdaytotal_channel = find_by_name("yesterday_volume", abbflowchannels)
+ abbflow_yesterdaytotal_channel = meshify.find_by_name("yesterday_volume", abbflowchannels)
query_params = []
for abbflow_dev in abbflow_devices:
- abbflowdevvalues = query_meshify_api("devices/{}/values".format(abbflow_dev['id']))
+ abbflowdevvalues = meshify.query_meshify_api("devices/{}/values".format(abbflow_dev['id']))
try:
yest_volume = float(abbflowdevvalues['yesterday_volume']['value'])
gateway_id = abbflow_dev['gatewayId']
diff --git a/meshify.py b/meshify.py
new file mode 100644
index 0000000..17a96b0
--- /dev/null
+++ b/meshify.py
@@ -0,0 +1,29 @@
+"""Query Meshify for data."""
+import requests
+import json
+from os import getenv
+from sys import exit
+
+MESHIFY_BASE_URL = "https://henrypump.meshify.com/api/v3/"
+MESHIFY_USERNAME = getenv("MESHIFY_USERNAME")
+MESHIFY_PASSWORD = getenv("MESHIFY_PASSWORD")
+MESHIFY_AUTH = requests.auth.HTTPBasicAuth(MESHIFY_USERNAME, MESHIFY_PASSWORD)
+
+if not MESHIFY_USERNAME or not MESHIFY_PASSWORD:
+ print("Be sure to set the meshify username and password as environment variables MESHIFY_USERNAME and MESHIFY_PASSWORD")
+ exit()
+
+
+def find_by_name(name, list_of_stuff):
+ """Find an object in a list of stuff by its name parameter."""
+ for x in list_of_stuff:
+ if x['name'] == name:
+ return x
+ return False
+
+
+def query_meshify_api(endpoint):
+ """Make a query to the meshify API."""
+ q_url = MESHIFY_BASE_URL + endpoint
+ q_req = requests.get(q_url, auth=MESHIFY_AUTH)
+ return json.loads(q_req.text) if q_req.status_code == 200 else []