Push API help? (date/time ranges)

For more advanced meter data users. Learn from others and ask questions about how to read meters, how to use the EKM Push Data, and how to display the meter data in useful ways.
Post Reply
jaholmes
Posts: 9
Joined: Sat Mar 21, 2015 9:38 pm

Push API help? (date/time ranges)

Post by jaholmes » Sat Mar 21, 2015 10:18 pm

Hello, EKM users!

I have a question, but let me introduce myself since this is my first post: My name is Aaron. I'm presently working on a way to quickly check my daily water usage from my phone (and possibly shut off my water remotely, but I'm calling that "extra credit" right now). I'm on a well system near the ocean, and have to be very careful in order to avoid seawater intrusion. Nearby wells have failed, making me very nervous!

Being a software developer by trade, this seemed like a fun opportunity for some spare-time coding. I'm having a bit of trouble with the Push API, though. Basically, I've been fiddling around with the Push API Builder and can't quite understanding how the counts and start/end dates interact. I'd also love to know exactly what the format of the UTC+ms numbers is.

When I use the API Builder, I find it funny that entering any start and end dates (e.g., setting both of them to today--21032015--or maybe one day apart) causes the query to return 0 results. Totally mystified there. Any ideas?

In the end, I'm basically hoping to quickly find out how many gallons I've used since midnight on the current day. Conceptually, this would involve getting the pulse counter reading closest to midnight, subtracting this from the latest reading, and multiplying by gallon/pulse to get the daily gallons. Getting the latest reading is pretty easy. Getting the reading closest to midnight is a bit less obvious. One thought--which errs on the side of pessimism--would be to query one value from a short span of time immediately preceding midnight. Would that work? If I use the UTC+ms or starttime/endtime values to construct a range that describes 11pm-12am and ask for 1 reading, will I get the value closest to midnight? Or should I? Again, I can't get this to work with API Builder, so I'm suspicious of my thinking.

Of course, I could query all values for the current day, pick the highest and lowest, and diff those, but that's a big query from which to distill a single number!

I'm a little lost.

If there's a paper that describes how all of these filters are used, their order of precedence, etc., that would be totally awesome!! :D

Kindest regards,
Aaron

EDIT: As an example, I'd expect the following URL to return an hour's worth of JSON-formatted data for pulse counter #1 for the hour 23:00:00 to 23:59:59 on the night of March 20th, 2015. But it returns nothing. (This is the Push API Builder meter, BTW, not my own.)

Code: Select all

http://io.ekmpush.com/readMeter/v4/meters/300000369/key/MTExOjExMQ/count/60/format/json/fields/Pulse_Cnt_1/start_date/20032015/end_date/20032015/start_time/230000/end_time/235959/

Jameson
Posts: 787
Joined: Fri Nov 04, 2011 7:42 pm
Location: Santa Cruz, CA
Contact:

Re: Push API help? (date/time ranges)

Post by Jameson » Mon Mar 23, 2015 10:29 am

Hello Aaron,

Thank you very much for joining our forum and for your introductions!

I would imagine that you were calling a time frame that was out of range for the time you were calling it. Meter 300000369 is set to a once per minute read rate, we store the latest 1000 reads, so in this case it would be 1000 minutes of data (if you want a longer time period of this kind of data, we can slow down your read rate of your meter, some customers prefer 1 read per hour so that they have 1000 hours of this kind of data). If you called from a time that did not contain data, then you would get an empty return. Also be aware that by default the data is timestamped in UTC time, so you would have to call in UTC time (or call using the filter that returns the meter reads in your local timezone).

If you look at this within the next few hours this link should work (I changed the date/time filter):

http://io.ekmpush.com/readMeter/v4/mete ... me/235959/
I'd also love to know exactly what the format of the UTC+ms numbers is.
The latest read as I am typing is: "Time_Stamp_UTC_ms":1427131455341, this is UTC time with 3 digits of milliseconds on the end. If you want just UTC time cut off the last 3 digits, so it is 1427131455.

If you send us an email I can offer you a beta way to see water usage per day (a separate API that we are not ready to unleash onto the world).

Thanks!
Jameson
EKM METERING
http://www.ekmmetering.com
831.425.7371

jaholmes
Posts: 9
Joined: Sat Mar 21, 2015 9:38 pm

Re: Push API help? (date/time ranges)

Post by jaholmes » Mon Mar 23, 2015 1:05 pm

Thanks very much for your reply, Jameson!

Ah! Well, good grief. I feel a little silly now. I suppose this answers the implied question of how much data is stored. :) Is the read interval of the Push field-programmable? I poked around a bit just now and didn't see that explained, but I apologize if I missed something obvious. From the wording of your reply, it sounds like the answer might be no.

I'll definitely email you later, as I'd love to try out the new API.

Thanks again!
Aaron

Jameson
Posts: 787
Joined: Fri Nov 04, 2011 7:42 pm
Location: Santa Cruz, CA
Contact:

Re: Push API help? (date/time ranges)

Post by Jameson » Mon Mar 23, 2015 2:21 pm

We can set your read rate for each of your meters (some to once a minute and others hourly), you Push will take up its new assignments within a minute and you would be off and running. Just let us know your Push key, and the read rates you would like for each of your meters and we will make the change.

Regards,
Jameson
EKM METERING
http://www.ekmmetering.com
831.425.7371

jaholmes
Posts: 9
Joined: Sat Mar 21, 2015 9:38 pm

Re: Push API help? (date/time ranges)

Post by jaholmes » Mon Mar 23, 2015 6:34 pm

Sounds great! Thanks again, Jameson! We'll be in touch. I'm still a few weeks away from being set up. I'm having a water softener and storage system installed, and will be sneaking in some extra bits along with that job. ;) (My contractor was very intrigued!)

Best,
Aaron

Post Reply