Getting historical data


(Hsamson) #1

I’m trying to get the historical data of some sensors using the statesBetween() of the device class. But i get an error: ’ java.lang.IllegalArgumentException: Command ‘statesBetween’ is not supported. Supported commands: []’. The same holds true for the statesSince(), eventsSince() and eventsBetween() functions. The events() functions works, but i can’t specify a Date from which i need the data from. Are these functions implemented? Or are there some other way to get the data?


Vacation mode?
(Hsamson) #2

The SmartThings folks were very helpful in sorting out this problem (Thanks @dlieberman, @urman and especially @scottvlaminck). Here is how to get historical data from devices in case anybody is interested.

Following are the methods of the device class which could be used for it:

  • Device events between 2 dates: eventsBetween(Date startDate, Date endDate, [max: N])
  • States between 2 dates for a given attribute: statesBetween(String attributeName, Date startDate, Date endDate, [max: N])

Do remember to use the square brackets [] for the max argument. All hell broke loose just because of those missing brackets. And do provide the attributeName while using statesBetween method. There is a small mistake in the current documentation.


(Tim Slagle) #3

That’s awesome!! What are you doing with the data once you pull it?