diff --git a/get_telemetry.ipynb b/get_telemetry.ipynb new file mode 100644 index 0000000..ffa9505 --- /dev/null +++ b/get_telemetry.ipynb @@ -0,0 +1,561 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [], + "source": [ + "import requests\n", + "import json" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [], + "source": [ + "headers = {\"Content-Type\": \"application/json\", \"Accept\": \"application/json\"}\n", + "data = '{\"username\":\"nmelone@henry-pump.com\",\"password\":\"gzU6$26v42mU%3jDzTJf\"}'\n", + "url_base = \"https://hp.henrypump.cloud/api/\"\n", + "response = requests.post(url_base + 'auth/login', headers=headers,data=data)\n", + "token = json.loads(response.content.decode(\"UTF-8\"))\n", + "headers[\"X-Authorization\"] = \"Bearer \" + token['token']" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [], + "source": [ + "#Get Customers\n", + "customers = requests.get(url_base + \"customers?page=0&pageSize=10\", headers=headers)\n", + "customers = json.loads(customers.content.decode(\"UTF-8\"))" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " \"data\": [\n", + " {\n", + " \"id\": {\n", + " \"entityType\": \"DEVICE\",\n", + " \"id\": \"06b6a450-aadd-11ec-8eb3-41740343dd9f\"\n", + " },\n", + " \"createdTime\": 1648062681877,\n", + " \"additionalInfo\": {\n", + " \"gateway\": false,\n", + " \"overwriteActivityTime\": false,\n", + " \"description\": \"\"\n", + " },\n", + " \"tenantId\": {\n", + " \"entityType\": \"TENANT\",\n", + " \"id\": \"a610ad00-52e2-11ec-89c2-2f343e6c262d\"\n", + " },\n", + " \"customerId\": {\n", + " \"entityType\": \"CUSTOMER\",\n", + " \"id\": \"4b856c50-a0b6-11ec-a588-ad8278896f52\"\n", + " },\n", + " \"name\": \"BV-602\",\n", + " \"type\": \"advvfdipp\",\n", + " \"label\": \"BV-602\",\n", + " \"deviceProfileId\": {\n", + " \"entityType\": \"DEVICE_PROFILE\",\n", + " \"id\": \"4ea52d70-a0b7-11ec-8e7b-f34df8141ace\"\n", + " },\n", + " \"deviceData\": {\n", + " \"configuration\": {\n", + " \"type\": \"DEFAULT\"\n", + " },\n", + " \"transportConfiguration\": {\n", + " \"type\": \"DEFAULT\"\n", + " }\n", + " },\n", + " \"firmwareId\": null,\n", + " \"softwareId\": null,\n", + " \"ownerId\": {\n", + " \"entityType\": \"CUSTOMER\",\n", + " \"id\": \"4b856c50-a0b6-11ec-a588-ad8278896f52\"\n", + " }\n", + " },\n", + " {\n", + " \"id\": {\n", + " \"entityType\": \"DEVICE\",\n", + " \"id\": \"0731e280-d163-11ec-9d28-f57ea5aee126\"\n", + " },\n", + " \"createdTime\": 1652298379432,\n", + " \"additionalInfo\": {\n", + " \"gateway\": false,\n", + " \"overwriteActivityTime\": false,\n", + " \"description\": \"\"\n", + " },\n", + " \"tenantId\": {\n", + " \"entityType\": \"TENANT\",\n", + " \"id\": \"a610ad00-52e2-11ec-89c2-2f343e6c262d\"\n", + " },\n", + " \"customerId\": {\n", + " \"entityType\": \"CUSTOMER\",\n", + " \"id\": \"4b856c50-a0b6-11ec-a588-ad8278896f52\"\n", + " },\n", + " \"name\": \"BZ-201\",\n", + " \"type\": \"advvfdipp\",\n", + " \"label\": \"BZ-201\",\n", + " \"deviceProfileId\": {\n", + " \"entityType\": \"DEVICE_PROFILE\",\n", + " \"id\": \"4ea52d70-a0b7-11ec-8e7b-f34df8141ace\"\n", + " },\n", + " \"deviceData\": {\n", + " \"configuration\": {\n", + " \"type\": \"DEFAULT\"\n", + " },\n", + " \"transportConfiguration\": {\n", + " \"type\": \"DEFAULT\"\n", + " }\n", + " },\n", + " \"firmwareId\": null,\n", + " \"softwareId\": null,\n", + " \"ownerId\": {\n", + " \"entityType\": \"CUSTOMER\",\n", + " \"id\": \"4b856c50-a0b6-11ec-a588-ad8278896f52\"\n", + " }\n", + " },\n", + " {\n", + " \"id\": {\n", + " \"entityType\": \"DEVICE\",\n", + " \"id\": \"16af78d0-ccb8-11ec-b0e8-ff45c37940c6\"\n", + " },\n", + " \"createdTime\": 1651785156829,\n", + " \"additionalInfo\": {\n", + " \"gateway\": false,\n", + " \"overwriteActivityTime\": false,\n", + " \"description\": \"\"\n", + " },\n", + " \"tenantId\": {\n", + " \"entityType\": \"TENANT\",\n", + " \"id\": \"a610ad00-52e2-11ec-89c2-2f343e6c262d\"\n", + " },\n", + " \"customerId\": {\n", + " \"entityType\": \"CUSTOMER\",\n", + " \"id\": \"4b856c50-a0b6-11ec-a588-ad8278896f52\"\n", + " },\n", + " \"name\": \"BW-72\",\n", + " \"type\": \"advvfdipp\",\n", + " \"label\": \"BW-72\",\n", + " \"deviceProfileId\": {\n", + " \"entityType\": \"DEVICE_PROFILE\",\n", + " \"id\": \"4ea52d70-a0b7-11ec-8e7b-f34df8141ace\"\n", + " },\n", + " \"deviceData\": {\n", + " \"configuration\": {\n", + " \"type\": \"DEFAULT\"\n", + " },\n", + " \"transportConfiguration\": {\n", + " \"type\": \"DEFAULT\"\n", + " }\n", + " },\n", + " \"firmwareId\": null,\n", + " \"softwareId\": null,\n", + " \"ownerId\": {\n", + " \"entityType\": \"CUSTOMER\",\n", + " \"id\": \"4b856c50-a0b6-11ec-a588-ad8278896f52\"\n", + " }\n", + " },\n", + " {\n", + " \"id\": {\n", + " \"entityType\": \"DEVICE\",\n", + " \"id\": \"4ac91370-cca3-11ec-9cdb-5b8ff28e4445\"\n", + " },\n", + " \"createdTime\": 1651776224807,\n", + " \"additionalInfo\": {\n", + " \"gateway\": false,\n", + " \"overwriteActivityTime\": false,\n", + " \"description\": \"\"\n", + " },\n", + " \"tenantId\": {\n", + " \"entityType\": \"TENANT\",\n", + " \"id\": \"a610ad00-52e2-11ec-89c2-2f343e6c262d\"\n", + " },\n", + " \"customerId\": {\n", + " \"entityType\": \"CUSTOMER\",\n", + " \"id\": \"4b856c50-a0b6-11ec-a588-ad8278896f52\"\n", + " },\n", + " \"name\": \"BX-101\",\n", + " \"type\": \"advvfdipp\",\n", + " \"label\": \"BX-101\",\n", + " \"deviceProfileId\": {\n", + " \"entityType\": \"DEVICE_PROFILE\",\n", + " \"id\": \"4ea52d70-a0b7-11ec-8e7b-f34df8141ace\"\n", + " },\n", + " \"deviceData\": {\n", + " \"configuration\": {\n", + " \"type\": \"DEFAULT\"\n", + " },\n", + " \"transportConfiguration\": {\n", + " \"type\": \"DEFAULT\"\n", + " }\n", + " },\n", + " \"firmwareId\": null,\n", + " \"softwareId\": null,\n", + " \"ownerId\": {\n", + " \"entityType\": \"CUSTOMER\",\n", + " \"id\": \"4b856c50-a0b6-11ec-a588-ad8278896f52\"\n", + " }\n", + " },\n", + " {\n", + " \"id\": {\n", + " \"entityType\": \"DEVICE\",\n", + " \"id\": \"9a37c410-d144-11ec-a502-79978f9d7342\"\n", + " },\n", + " \"createdTime\": 1652285311697,\n", + " \"additionalInfo\": {\n", + " \"gateway\": false,\n", + " \"overwriteActivityTime\": false,\n", + " \"description\": \"\"\n", + " },\n", + " \"tenantId\": {\n", + " \"entityType\": \"TENANT\",\n", + " \"id\": \"a610ad00-52e2-11ec-89c2-2f343e6c262d\"\n", + " },\n", + " \"customerId\": {\n", + " \"entityType\": \"CUSTOMER\",\n", + " \"id\": \"4b856c50-a0b6-11ec-a588-ad8278896f52\"\n", + " },\n", + " \"name\": \"BW-041\",\n", + " \"type\": \"advvfdipp\",\n", + " \"label\": \"BW-041\",\n", + " \"deviceProfileId\": {\n", + " \"entityType\": \"DEVICE_PROFILE\",\n", + " \"id\": \"4ea52d70-a0b7-11ec-8e7b-f34df8141ace\"\n", + " },\n", + " \"deviceData\": {\n", + " \"configuration\": {\n", + " \"type\": \"DEFAULT\"\n", + " },\n", + " \"transportConfiguration\": {\n", + " \"type\": \"DEFAULT\"\n", + " }\n", + " },\n", + " \"firmwareId\": null,\n", + " \"softwareId\": null,\n", + " \"ownerId\": {\n", + " \"entityType\": \"CUSTOMER\",\n", + " \"id\": \"4b856c50-a0b6-11ec-a588-ad8278896f52\"\n", + " }\n", + " },\n", + " {\n", + " \"id\": {\n", + " \"entityType\": \"DEVICE\",\n", + " \"id\": \"c50ec0b0-d150-11ec-9a8d-d3ef2e0c0a7d\"\n", + " },\n", + " \"createdTime\": 1652290537531,\n", + " \"additionalInfo\": {\n", + " \"gateway\": false,\n", + " \"overwriteActivityTime\": false,\n", + " \"description\": \"\"\n", + " },\n", + " \"tenantId\": {\n", + " \"entityType\": \"TENANT\",\n", + " \"id\": \"a610ad00-52e2-11ec-89c2-2f343e6c262d\"\n", + " },\n", + " \"customerId\": {\n", + " \"entityType\": \"CUSTOMER\",\n", + " \"id\": \"4b856c50-a0b6-11ec-a588-ad8278896f52\"\n", + " },\n", + " \"name\": \"S-601\",\n", + " \"type\": \"advvfdipp\",\n", + " \"label\": \"S-601\",\n", + " \"deviceProfileId\": {\n", + " \"entityType\": \"DEVICE_PROFILE\",\n", + " \"id\": \"4ea52d70-a0b7-11ec-8e7b-f34df8141ace\"\n", + " },\n", + " \"deviceData\": {\n", + " \"configuration\": {\n", + " \"type\": \"DEFAULT\"\n", + " },\n", + " \"transportConfiguration\": {\n", + " \"type\": \"DEFAULT\"\n", + " }\n", + " },\n", + " \"firmwareId\": null,\n", + " \"softwareId\": null,\n", + " \"ownerId\": {\n", + " \"entityType\": \"CUSTOMER\",\n", + " \"id\": \"4b856c50-a0b6-11ec-a588-ad8278896f52\"\n", + " }\n", + " },\n", + " {\n", + " \"id\": {\n", + " \"entityType\": \"DEVICE\",\n", + " \"id\": \"d8433890-d147-11ec-8e7b-4d9a3bf70f9d\"\n", + " },\n", + " \"createdTime\": 1652286704281,\n", + " \"additionalInfo\": {\n", + " \"gateway\": false,\n", + " \"overwriteActivityTime\": false,\n", + " \"description\": \"\"\n", + " },\n", + " \"tenantId\": {\n", + " \"entityType\": \"TENANT\",\n", + " \"id\": \"a610ad00-52e2-11ec-89c2-2f343e6c262d\"\n", + " },\n", + " \"customerId\": {\n", + " \"entityType\": \"CUSTOMER\",\n", + " \"id\": \"4b856c50-a0b6-11ec-a588-ad8278896f52\"\n", + " },\n", + " \"name\": \"BY-501\",\n", + " \"type\": \"advvfdipp\",\n", + " \"label\": \"BY-501\",\n", + " \"deviceProfileId\": {\n", + " \"entityType\": \"DEVICE_PROFILE\",\n", + " \"id\": \"4ea52d70-a0b7-11ec-8e7b-f34df8141ace\"\n", + " },\n", + " \"deviceData\": {\n", + " \"configuration\": {\n", + " \"type\": \"DEFAULT\"\n", + " },\n", + " \"transportConfiguration\": {\n", + " \"type\": \"DEFAULT\"\n", + " }\n", + " },\n", + " \"firmwareId\": null,\n", + " \"softwareId\": null,\n", + " \"ownerId\": {\n", + " \"entityType\": \"CUSTOMER\",\n", + " \"id\": \"4b856c50-a0b6-11ec-a588-ad8278896f52\"\n", + " }\n", + " },\n", + " {\n", + " \"id\": {\n", + " \"entityType\": \"DEVICE\",\n", + " \"id\": \"e9b87630-aadc-11ec-8eb3-41740343dd9f\"\n", + " },\n", + " \"createdTime\": 1648062633235,\n", + " \"additionalInfo\": {\n", + " \"gateway\": false,\n", + " \"overwriteActivityTime\": false,\n", + " \"description\": \"\"\n", + " },\n", + " \"tenantId\": {\n", + " \"entityType\": \"TENANT\",\n", + " \"id\": \"a610ad00-52e2-11ec-89c2-2f343e6c262d\"\n", + " },\n", + " \"customerId\": {\n", + " \"entityType\": \"CUSTOMER\",\n", + " \"id\": \"4b856c50-a0b6-11ec-a588-ad8278896f52\"\n", + " },\n", + " \"name\": \"BP-601\",\n", + " \"type\": \"advvfdipp\",\n", + " \"label\": \"BP-601\",\n", + " \"deviceProfileId\": {\n", + " \"entityType\": \"DEVICE_PROFILE\",\n", + " \"id\": \"4ea52d70-a0b7-11ec-8e7b-f34df8141ace\"\n", + " },\n", + " \"deviceData\": {\n", + " \"configuration\": {\n", + " \"type\": \"DEFAULT\"\n", + " },\n", + " \"transportConfiguration\": {\n", + " \"type\": \"DEFAULT\"\n", + " }\n", + " },\n", + " \"firmwareId\": null,\n", + " \"softwareId\": null,\n", + " \"ownerId\": {\n", + " \"entityType\": \"CUSTOMER\",\n", + " \"id\": \"4b856c50-a0b6-11ec-a588-ad8278896f52\"\n", + " }\n", + " },\n", + " {\n", + " \"id\": {\n", + " \"entityType\": \"DEVICE\",\n", + " \"id\": \"ed19b7e0-d213-11ec-8c76-ad8278896f52\"\n", + " },\n", + " \"createdTime\": 1652374356574,\n", + " \"additionalInfo\": {\n", + " \"gateway\": false,\n", + " \"overwriteActivityTime\": false,\n", + " \"description\": \"\"\n", + " },\n", + " \"tenantId\": {\n", + " \"entityType\": \"TENANT\",\n", + " \"id\": \"a610ad00-52e2-11ec-89c2-2f343e6c262d\"\n", + " },\n", + " \"customerId\": {\n", + " \"entityType\": \"CUSTOMER\",\n", + " \"id\": \"4b856c50-a0b6-11ec-a588-ad8278896f52\"\n", + " },\n", + " \"name\": \"CF-501\",\n", + " \"type\": \"advvfdipp\",\n", + " \"label\": \"CF-501\",\n", + " \"deviceProfileId\": {\n", + " \"entityType\": \"DEVICE_PROFILE\",\n", + " \"id\": \"4ea52d70-a0b7-11ec-8e7b-f34df8141ace\"\n", + " },\n", + " \"deviceData\": {\n", + " \"configuration\": {\n", + " \"type\": \"DEFAULT\"\n", + " },\n", + " \"transportConfiguration\": {\n", + " \"type\": \"DEFAULT\"\n", + " }\n", + " },\n", + " \"firmwareId\": null,\n", + " \"softwareId\": null,\n", + " \"ownerId\": {\n", + " \"entityType\": \"CUSTOMER\",\n", + " \"id\": \"4b856c50-a0b6-11ec-a588-ad8278896f52\"\n", + " }\n", + " }\n", + " ],\n", + " \"totalPages\": 1,\n", + " \"totalElements\": 9,\n", + " \"hasNext\": false\n", + "}\n" + ] + } + ], + "source": [ + "#Get Devices\n", + "for customer in customers['data']:\n", + " if customer[\"name\"] == \"Faskens\":\n", + " cid = customer[\"id\"][\"id\"]\n", + "devices = requests.get(url_base + f\"customer/{cid}/devices?page=0&pageSize=10\", headers=headers)\n", + "devices = json.loads(devices.content.decode(\"UTF-8\"))\n", + "print(json.dumps(devices,indent=4))" + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[\n", + " \"flowrate\",\n", + " \"hartrevtotal\",\n", + " \"hartfwdtotal\",\n", + " \"hartnettotal\",\n", + " \"maxvfdfrequency\",\n", + " \"minvfdfrequency\",\n", + " \"controllerfault_program\",\n", + " \"controllerfault_io\",\n", + " \"vfd_fault\",\n", + " \"last_vfd_fault_code\",\n", + " \"sensorheight\",\n", + " \"temperaturestartuplimit\",\n", + " \"temperatureshutdownlimit\",\n", + " \"pressurestartuplimit\",\n", + " \"pressureshutdownlimit\",\n", + " \"alarmfluidlevel\",\n", + " \"tubingpressuresetpoint\",\n", + " \"manualfrequencysetpoint\",\n", + " \"fluidlevelsetpoint\",\n", + " \"flowsetpoint\",\n", + " \"stopcommand\",\n", + " \"startcommand\",\n", + " \"startpermissive\",\n", + " \"runpermissive\",\n", + " \"alarmlockout\",\n", + " \"alarmvfd\",\n", + " \"alarmtubingpressure\",\n", + " \"alarmintaketemperature\",\n", + " \"alarmintakepressure\",\n", + " \"alarmflowrate\",\n", + " \"energytotalyesterday\",\n", + " \"flowtotalyesterday\",\n", + " \"fluidspecificgravity\",\n", + " \"downholesensorstatus\",\n", + " \"vfdcurrent\",\n", + " \"energytotal\",\n", + " \"flowtotal\",\n", + " \"vfdfrequency\",\n", + " \"wellstatus\",\n", + " \"pidcontrolmode\",\n", + " \"tubingpressure\",\n", + " \"intaketemperature\",\n", + " \"intakepressure\",\n", + " \"fluidlevel\",\n", + " \"wellstatus_int\",\n", + " \"vfd_fault_int\",\n", + " \"last_vfd_fault_code_int\",\n", + " \"alarmfluidlevel_int\",\n", + " \"startpermissive_int\",\n", + " \"runpermissive_int\",\n", + " \"alarmlockout_int\",\n", + " \"alarmvfd_int\",\n", + " \"alarmtubingpressure_int\",\n", + " \"alarmintaketemperature_int\",\n", + " \"alarmintakepressure_int\",\n", + " \"alarmflowrate_int\",\n", + " \"downholesensorstatus_int\",\n", + " \"pidcontrolmode_int\",\n", + " \"resetalarms\",\n", + " \"flowrate_gpm\",\n", + " \"flowmeter_fault\",\n", + " \"flowmeter_fault_int\",\n", + " \"RuleNodeState_6e98a3f0-d6b3-11ec-b5bf-ff45c37940c6\",\n", + " \"sumFlowRate\"\n", + "]\n" + ] + } + ], + "source": [ + "#Get Keys\n", + "for device in devices['data']:\n", + " if device[\"name\"] == \"BV-602\":\n", + " did = device['id']['id']\n", + " eType = device['id']['entityType']\n", + "keys = requests.get(url_base + f\"plugins/telemetry/{eType}/{did}/keys/timeseries\", headers=headers)\n", + "keys = json.loads(keys.content.decode(\"UTF-8\"))\n", + "\n", + "print(json.dumps(keys,indent=4))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#Get Telemetry" + ] + } + ], + "metadata": { + "interpreter": { + "hash": "22238595996e71d7b27448e64f75d285aa95d1182295fdd30f75905446cf0091" + }, + "kernelspec": { + "display_name": "Python 3.9.12 ('webkit')", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.12" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +}