I can't retrieve more than 50 events from a device

The documentation says that the device’s events() method returns the events from the last 7 days, but I can’t get it to return more than 50 events.

The documentation also says that if you don’t specify a max option, it will only return 10 events, but if I set the max to anything over 50, it still only returns 50 events.

I’m trying to just retrieve the last event with a source containing “DEVICE”, but that’s not possible with a lot of my devices because they’ve since had more than 50 events from other sources.

I’m hoping I’m doing something wrong and there really isn’t a 50 event limit, but if there is, you need to update the documentation because you can’t get the last 7 days of events like it says you can. @Jim @slagle

Looks like you’re not doing anything wrong - something is broken :cry:

I was able to retrieve 1,000 events just fine just yesterday (I am using this to show historical data in my solar DTH) - as of today I get a maximum of 50 events returned.

I sure hope that this is an unintended side effect of a recent hot fix that was pushed since the documentation still states that it is possible to get up to 1,000 events.

Hopefully @Jim will be able to clear this up soon…

Tagging @jody.albritton

It still is possible to retrieve more than 50 items - you just have to send multiple queries, adjusting the date/time for statesSince() or statesBetween() based on the values returned from the previous query and merge the results.

I would believe that sending 20 queries to get 1,000 events in batches of 50 rather than one single query would be more taxing on the cloud which leads me to think (or rather hope) that this is not an intended change.

Reproducible and internal ticket raised. Sorry guys.

5 Likes

Thanks for the confirmation - I hope that this will also create a unit test so that this regression can be avoided in the future?

1 Like

Definitely not a cloud dev, but yes, that is normally the process.

1 Like

It turns out that the documentation was right, you can get the events for all 7 days which explains why they didn’t include a limit on the number of events like they did with state methods.

I just ran a test using the method you mentioned and I was able to pull 8,870 events off of one of my devices. With the current bug it took 178 requests instead of 9, but at least I know it’s still possible.

1 Like

Any update on this? It seems as if these calls are currently still limited to at most 50 results…

If this is a change that is here to stay it would be nice to update the documentation accordingly so that people are aware of this and can update their code accordingly…

1 Like

I haven’t heard anything so I ended using eventsBetween within a loop.

1 Like

While I have no problem implementing that (I already have in a place where I need more than 1000 events), I’d rather not do that unless necessary - it will tax the cloud and not help performance…

I’m just searching for the most recent event with the source “device” so normally it finds something in the first couple of requests, but it will try up to 25 times if it can’t find anything.

The way I see it, we reported the problem and they acknowledged it, if a month later it’s still not fixed and the only workaround we have taxes the cloud, that’s on them, not us.

I’ll research this tomorrow and get back to you all with the results.

2 Likes

Any update on this? “Tomorrow” passed about 12 days ago now…

In the meantime I had to resort to putting all my eventsBetween() queries into loops that exit only once I have all the data I actually need - the approach works regardless of any future changes/limitations on results but probably is not the best approach as far as pressure on the cloud/DB is concerned…

@slagle since we’re coming up on almost a month - did you manage to look into this as promised? If so, what was the result? Is this a bug that will get fixed or is this the new normal and we have to code around it?

2 Likes

Still talking to people about it. It hasn’t been forgotten. Sorry it’s taking so long.

I just ran into this too while testing one of my apps.
I couldn’t retrieve more than 50 events at a time.