API to getSmartDeviceDataPointsByID

7 comments started 2023-10-13 last 2023-10-17
Cloud Portal
#1 Icarus

Regarding API GET requests of the form /smart-device/{smartDevice_uuid}/data

I am trying to use the givenergy api efficiently to return recent smart plug data.

While I can sucessfully do pagination of data and get a series of responses of pageSize until I find the date/time range I am interested in, I do not seem to be able to specify a simple date range on a request.

I can determine how many pages there are and the total number of datapoints by accessing the meta data in the first api response.
However when my desired date range spans more than one page the client logic becomes unnecessarily complex because a simple date range does not appear to be implemented.

Perhaps there is another way?

#2 hoggy

Icarus Not that's published there isn't. I did try similar methods they use elsewhere but no joy:
{smartDevice_uuid}/data/{date}&page=1
.{smartDevice_uuid}/data?start_time={2........}&end_time={2........}&page=1

@Mickey (GivEnergy) may be able to assist.

#3 Icarus

hoggy Thanks!

#4 Icarus

For those Agile users happy with CLI and running java on Raspberry Pi / Windows / anywhere you have a JRE installed…

Some code I use to monitor the GE Smart Plug energy monitoring datapoints using a local cache for efficiency

https://github.com/V999TEC/GivEnergyPlugs

#5 hoggy

Icarus can I infer from that you've had a success sorting by date now or still having to page through piles of timestamp data points?

#6 Icarus

Have had a conversation with Jordan in GE support regarding the limitation in the REST API and response was quote: "There's not a way to do this currently, but I have asked the devs and they are considering adding it in" unquote.

I passed on the link to my client-side work-around, previously referenced above, as a way of handling a range of dates.
My strategy in the java code is to cache datapoints in a flat file such as uuid.tmp
I store oldest first, so recent data can always be appended to the file.
The API returns the datapoints in reverse chronological order (so Page 1 has latest, Page N is older etc).
So all I do is read page by page until the increasingly older datapoints are equal or before the most recent timestamp I have in the file cache.
The cache just gets extended by the recent data.

Subsequent calls are much quicker.
However this is not really a substitute for having a date/time range built into the REST API.
But the github example is satisfactory for my purposes.

I do wonder about the retention of datapoints in the GE Cloud.
Having my local cache of the historical data defends against the potential "triming" of the available data via the API in the future.

I only have a couple of handfulls of GE Smart Plugs but (particularly for the devices that have intermitant pattern of power drain) there is already a lot of data accumulated, since it seems to me, each time the power level changes an event is generated and pushed to the cloud as a new datapoint.

#7 hoggy

Icarus retention wise I've been feeding 2 EV chargers power data (an Ohme and an Indra) to the same endpoints way before the plugs were even thought of and its still all there 2+ years on....