I’m trying to get Device History, by trying a few examples provided in the reference
But the API returns empty data.
Is it some kind of a feature that needs to be enabled before it starts working? Or, perhaps, I’m missing something.
Here is my sample code:
#!/usr/bin/env python3
from balena import Balena
import datetime
import os
balena = Balena()
token=open(os.path.expanduser('~/.balena/token'),'rt').read()
balena.auth.login_with_token(token)
print(balena.auth.get_actor_id())
for app in balena.models.application.get_all():
print(app['app_name'], app['id'])
history = balena.models.device.history.get_all_by_application(app['id'], from_date=datetime.datetime.now() + datetime.timedelta(days=-100), to_date=datetime.datetime.now())
print(history)
Hi,
I was able to use your code snippet using the latest version of the python balena-sdk and I was able to bet results back without issues.
Can you try the following curl so that we can get a hint on whether this is an API or SDK issue?
Hi, I tested both the curl and your script using an application I know to have recent device history and got the expected populated response from both. Is it possible that a release was created for your application, but the device is pinned and therefore wasn’t updated to use the new release? Perhaps try updating the device’s release via the dashboard and try querying device history again.