Getting time series historical data with devices_v2_timeseries()

I am trying to get historical data from my Arduino IoT Cloud device for several parameters, but I am not getting any time series data.

api2 = iot.DevicesV2Api(client)
DEVICE_ID = '7bb6a71e-8995-46cf-9ebc-b424a52e207d'
prop_id = '5fc50011-5844-4d8a-aba2-1de79b19238e'
date="2023-07-07T10:00:00Z"
try:
    resp=api2.devices_v2_timeseries(DEVICE_ID, prop_id,limit=2,start=date)
    print('resp ', resp)
except ApiException as e:
    print("Got an exception: {}".format(e))

I get this response:
resp {'id': '7bb6a71e-8995-46cf-9ebc-b424a52e207d',
'last_evaluated_key': None,
'name': '5fc50011-5844-4d8a-aba2-1de79b19238e',
'values': []}

But I know that there is data as I get the latest value with a request using the properties_V2_list:

api = iot.PropertiesV2Api(client)
resp = api.properties_v2_list(thing_id)
print('thing_id resp ',resp)

Response is:
'href': '/iot/v1/things/f31dbcb6-1ca2-4008-8683-a472157798d3/properties/5fc50011-5844-4d8a-aba2-1de79b19238e',
'id': '5fc50011-5844-4d8a-aba2-1de79b19238e',
'last_value': 25.489999771118164,
'max_value': None,
'min_value': None,
'name': 'Node1_Temperature',
'permission': 'READ_ONLY',
'persist': True,
'sync_id': None,
'tag': 6.0,
'thing_id': 'f31dbcb6-1ca2-4008-8683-a472157798d3',
'thing_name': '... monitor',
'type': 'FLOAT',
'update_parameter': 100.0,
'update_strategy': 'TIMED',
'updated_at': datetime.datetime(2023, 5, 4, 0, 56, 11, 451640, tzinfo=tzutc()),
'value_updated_at': datetime.datetime(2023, 8, 2, 22, 53, 42, 45000, tzinfo=tzutc()),
'variable_name': 'node1_Temperature'}, {'created_at': datetime.datetime(2023, 5, 4, 0, 53, 58, 225674, tzinfo=tzutc()),
'deleted_at': None,

Why is it that I am not getting the historical values using the devices_v2_timeseries()?

Hi there,

I don't mean to hijack your thread, but I can confirm that I'm seeing the same "bug" as you - in that I'm not getting any historical values (the returned list is empty).

Not sure if Arduino is able to help?

edit:
I'm wondering if we should be using propertiesV2Timeseries
Arduino IoT Cloud API instead?

Hi there, I managed to get the time series data

try:
    resp = properties_api.properties_v2_timeseries(id=thing_id, pid=prop_id, desc=True, _from='2023-09-01T00:00:00Z')
    print(resp)
except ApiException as e:
    print("Got an exception: {}".format(e))

Hey, I notice you don't need to wrap your path parameters in a dictionary. When I use any of the functions i need to pass them as a dict as follows:

try:
    resp = properties_api.properties_v2_timeseries(path_params={"id":THING_ID, "pid":PROP_ID}, query_params={"from": "2023-09-22T19:25:23.425Z"})
    print(resp)
except ApiException as e:
    print("Got an exception: {}".format(e))

Have you had to switch to the dictionary format?

I'm having issues where I can list out Things, but when trying to get historical data, it comes back as not found. So I'm trying to debug that and noticed these differences between our codes.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.