http://www.domotiga.nl/projects/domotig ... otocol.txt
The only problem i need to solve is to read the history of power usage. I get some data back from the device, and i need to get a date from it. Here's how it's explained in maarten's code:
Code: Select all
275 The abshour format
276 Let's pick the first buffer address as example: 000036B1
277 The decimal value of this abshour value is 14001
278
279 This value was a real brain cracker, after comparing the values I figured out the following.
280 For illustration let's convert the next abshour value (000036B2) to decimal: 14002
281
282 Aha! It increases by one all the time, so there must be a constant in these values. Then I substracted this value as hours from the current date (as it states abshour I was figuring it had something to do with hoours) this brought me to the following date:
283
284 1-6-2007
285
286 So if you add the number of hours to that date you'll get the datetime of that buffer.
287 Example in python:
288
289 >>> import datetime
290 >>> timestart = datetime.datetime(2007, 6, 1, 2)
291 >>> dif = datetime.timedelta(hours=14001)
292 >>> datetime = timestart + dif
293 >>> datetime
294 datetime.datetime(2009, 1, 4, 11, 0)
295
296
297 So the date and time of this buffer request is:
298 4-1-2009 11:00
EDIT:
Maybe i figured it out. The hour number that i got has gotten me confused. When it reads the last buffered usage information, then i get an amount of hours that has occured before this buffer (and the amount of hours that has passed before the start of the measurements). When i subtract that.. then i get a base date on which i can calculate the dates of the other request. I'n the above example.. suppose it's 12-22-2009 12:00 AM at this moment, after I substract the total amount of hours i then know when the plugwise system started measusing and after that it easy to get the date for a buffer. (i just add the amount of hours i get to the start time).