Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

access to not-most-recent-data? #15

Open
ljwobker opened this issue Jul 24, 2024 · 1 comment
Open

access to not-most-recent-data? #15

ljwobker opened this issue Jul 24, 2024 · 1 comment

Comments

@ljwobker
Copy link

Apologies for what may be the world's dumbest question (i'm new to this...)

The provided example works great grabbing the most recent data from a device. I see in the REST API docs where it supports getting historical (non instant) data via the /devices/:macAddress endpoint...

is this something that's exposed here in this super-useful python API? Or do I need to hack it up myself to build a different request when I want something other than just the devices endpoint?

@avryhof
Copy link
Owner

avryhof commented Jul 24, 2024

So, I think the issue is that Ambient's own documentation on this is pretty bad, and I haven't done much to improve it here.

The parameter is endDate (or end_date when passed into device.get_data())

It then returns the most recent data up to that date, since data is collected in intervals.

The other tricky part is that you pass the date in as milliseconds since the epoch.... so you would calculate it in Python like round(time.time() * 1000)

So if I were to try and get data for 5:00PM on April 26th, I would use

my_end_date = round(datetime.datetime(year=2024, month=4, day=26, hour=17, minute=0, second=0).time() * 1000)
print(device.get_data(end_date=my_end_date))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants