from tb_rest_client.rest_client_pe import * from tb_rest_client.rest import ApiException from tb_rest_client.api_client import * import json from datetime import datetime as dt def convertDateTimeToMS(datestring): date = dt.strptime(datestring,"%d %b %Y, %H:%M:%S") return int(date.timestamp() * 1000) url = "https://hp.henrypump.cloud" username = "example@example.com" password = "password123" with RestClientPE(base_url=url) as rest_client: try: rest_client.login(username=username, password=password) cid = "0d4427e0-18ae-11ed-8e6d-5b69d1f90f37" #This is the Customer ID for Henry Resources and doesn't need changed devices = rest_client.get_customer_devices(customer_id=cid, page=0, page_size=100) #print(json.dumps(device.to_dict(),indent=4)) #print(devices) for device in #devices.data: eType = device.id.entity_type eid = device.id.id name = device.name start = convertDateTimeToMS("01 Jan 2024, 00:00:00") #The date time for when the data should start end = int(dt.now().timestamp() * 1000) #automatically sets to now #print(eType, eid, name) keys = rest_client.get_timeseries_keys_v1(eType,eid) telemetry = rest_client.get_timeseries(entity_type=eType, entity_id=eid , keys=",".join(keys), start_ts=start, end_ts=end, limit=10000) print([telemetry]) except ApiException as e: print(e)