Totally lost trying to get historic events

I have had the same problem for nearly a year now :slight_smile:

Our company asked me to write some code to generate reports on all of a client’s smartthings device telemetry. I did this by reading the capability status of the devices on a loop via{{deviceID}}/status and recording in a dB, then graphing that.
The API only provides the latest status of the device, though. This is insufficient as the status changes too often for the loop to catch all statuses before they change, e.g. a quickly open and then closed medicine cabinet door.

I asked the community before how to get historic events for a device or for all devices in a locations or preferably in an account and I was told I should “subscribe” to the events and was pointed at GitHub

However I could never figure out how to actually do this, and had to move onto something else. I am back to this issue now and I have tried to find documentation and all links to now point to the “We’ve moved” landing page which is a dead end, i.e. doesn’t seem to forward you onto the moved document.

My questions are as follow:

  1. Does the API allow me to get the statuses of a device for the last x mins?
    If not (and it doesn’t look like it), why ever not? I can see the events of a device in the smartthings account when I sign in so the data exists. Why can’t I query it via api?

  2. Is there a step by step tutorial on how to get device data sent to my end point via subscription as the events occur? I’m sure there is I just can’t find it. Can these subscriptions be created dynamically?

  3. When I researched before I found (but cannot find again) statements that claimed there is a limit on how many subscriptions I can create. I think it was 20 devices. I need to be sure that if I go down the route of subscriptions I don’t end up hitting a limit. My client might have 50 devices. It could be that I can subscribe to a capability rather than a device, might that be possible?

I would appreciate any help with this.


Tagging @nayelyz

1 Like

There is certainly a history endpoint in the API for device events but for whatever reason, which may well include it not being intended for end user use yet, it hasn’t been documented for the end users. The basic format is:{{locationId}}&deviceId={{deviceId}}

There are several other parameters that limit what is returned but I don’t really know the format (although you can see it in the returned paging URLs).

1 Like

Wow. This is exactly what I was looking for. Thank you so much!