User Tools

Site Tools


access_via_api

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
access_via_api [2019/06/07 14:27] – [Getting current registers values] akuzmukaccess_via_api [2020/04/07 10:05] – [Getting graph data] emozolyak
Line 624: Line 624:
 To obtain entries from the register register, you must perform follwing GET request on a URL http://192.168.1.1/api/register-log. To obtain entries from the register register, you must perform follwing GET request on a URL http://192.168.1.1/api/register-log.
  
-In the request headers, it is necessary to pass the API key, the boundaries of the time interval of interest, and a list of register identifiers. X-WH-START and X-WH-END are transmitted in UnixTime format. The register ID is passed by a comma-separated list in the X-WH-REG-IDS header. For example:+In the request headers, it is necessary to pass the API key, the boundaries of the time interval of interest, and a list of register identifiers. X-WH-START and X-WH-END are transmitted in UnixTime format. The register ID is passed by a comma-separated list in the X-WH-REGISTERS header. For example:
  
   X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7   X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7
   X-WH-START: 1422595501   X-WH-START: 1422595501
   X-WH-END: 1422599101   X-WH-END: 1422599101
-  X-WH-REG-IDS: 8,10+  X-WH-REGISTERS: 8,10
      
 Also, in the headers, you must specify the desired data exchange format. Currently, only the JSONformat is supported. Also, in the headers, you must specify the desired data exchange format. Currently, only the JSONformat is supported.
Line 648: Line 648:
   X-WH-START: 1422595501   X-WH-START: 1422595501
   X-WH-END: 1422599101   X-WH-END: 1422599101
-  X-WH-REG-IDS: 8,10+  X-WH-REGISTERS: 8,10
  
 Reply example: Reply example:
Line 1296: Line 1296:
 |title |string |Image name| |title |string |Image name|
  
-===== Getting graph data =====+===== Getting meters log =====
  
-To get data from graph log, it is necessary to run following GET-query for URL http://192.168.1.1/api/graph-data/2. Here 2 - is the ID of the graph of interest.+There is an option to use some registers as totalizers of resources, like heat, water, electricity etcThen  each hour the register current values and hourly consumption values will be stored in the log
  
-Also, instead of specifying the graph ID, you can send the X-WH-REGS headerIt specifies, through the comma, the ID of the registers for which data is to be extractedExample:+To obtain entries from the meters, you must perform follwing GET request on a URL  
 +  http://192.168.1.1/api/meters-log
  
-  X-WH-REGS: 23,12,4 +In the request headers, it is necessary to pass the API key, the boundaries of the time interval of interest, and a list of register identifiers. X-WH-START and X-WH-END are transmitted in UnixTime format. The register ID is passed by a comma-separated list in the X-WH-REGISTERS header. For example:
- +
-In the request headers, you must pass the API key, the boundaries of the time interval of interest (X-WH-STARTX-WH-END) and the number of values ​​(X-WH-SLICES). X-WH-START and X-WH-END are transmitted in UnixTime format. For example:+
  
   X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7   X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7
-  X-WH-START: 1422797440 +  X-WH-START: 1422595501 
-  X-WH-END: 1422997405 +  X-WH-END: 1422599101 
-  X-WH-SLICES300 +  X-WH-REGISTERS8,10 ?? check this  
- +   
-X-WH-SLICES is the number of values. The time interval X-WH-START-X-WH-END will be divided into X-WH-SLICES of equal intervals and the system will take the most detailed values ​​for each of them.  +Also, in the headers, you must specify the desired data exchange format. Currently, only the JSONformat is supported.
-X-WH-SLICES should be chosen based on the necessary detail of the graph. Soif you need to build a graph 800 pixels wide, then it makes no sense to choose more than 800 values ​​from the log. And sometimes there will be enough 200-400 values ​​depending on the width of the line on the graph. +
- +
-To speed up the operation, the system can store the averaged values ​​of the registers for different intervals (1 minute, 2 minutes, 5 minutes, 15 minutes, 1 hour). In the configuration of each register, you can specify the required detail of the stored data. Depending on the selected time interval and the number of values, the system will attempt to take data from the most appropriate table of averaged values. or from the register register (if it is included for the specified register) +
- +
-Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.+
  
   Accept: application/json   Accept: application/json
   Content-Type: application/json   Content-Type: application/json
-   
-Example of getting data for graph #1: 
  
-  ***URL:** http://192.168.1.1/api/graph-data/1 +Example of querying records from the register log: 
-  ***Method:** GET + 
-  *Headers:+  ***URL**http://192.168.1.1/api/register-log 
 +  ***Method**GET 
 +  *Header:
  
   Accept: application/json   Accept: application/json
Line 1331: Line 1325:
   Accept-Encoding: gzip, deflate, sdch   Accept-Encoding: gzip, deflate, sdch
   X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7   X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7
-  X-WH-START: 1422854081 +  X-WH-START: 1422595501 
-  X-WH-END: 1422856235 +  X-WH-END: 1422599101 
-  X-WH-SLICES20+  X-WH-REGISTERS: 8,10 
 + 
 +Reply example:
  
-Response example: 
 <code> <code>
-[ +{ 
-  +  "1422598266": [ 
-    "8": "NaN;NaN;NaN", +    
-    "10": "NaN;NaN;NaN"+      "r": 8
-    "16": "NaN;NaN;NaN", +      "v": "6", 
-    "x": 1422861065000 +      "s": "-1" 
-  }, +    }, 
-  +    
-    "8": "NaN;NaN;NaN"+      "r": 10
-    "10": "NaN;NaN;NaN", +      "v": "", 
-    "16": "NaN;NaN;NaN", +      "s": "" 
-    "x": 1422861173000 +    } 
-  }+  ]
-  { +  "1422598271": [ 
-    "8": "NaN;NaN;NaN", +    
-    "10": "NaN;NaN;NaN", +      "r": 8
-    "16": "NaN;NaN;NaN", +      "v": "11", 
-    "x": 1422861281000 +      "s": "-1" 
-  }, +    }
-  { +    
-    "8": "NaN;NaN;NaN", +      "r": 10, 
-    "10": "NaN;NaN;NaN", +      "v": "", 
-    "16": "NaN;NaN;NaN", +      "s": "" 
-    "x": 1422861388000 +    } 
-  }, +  ]
-  { +  "1422598276":
-    "8": "0.000000;9.292714;19.000000", +    
-    "10": "NaN;NaN;NaN", +      "r": 8
-    "16": "0.000000;0.674894;1.000000", +      "v": "16", 
-    "x": 1422861496000 +      "s": "-1" 
-  }, +    }
-  { +    
-    "8": "0.000000;9.489933;19.000000", +      "r": 10, 
-    "10": "NaN;NaN;NaN", +      "v": "", 
-    "16": "0.000000;0.742101;1.000000", +      "s": "" 
-    "x": 1422861604000 +    } 
-  }, +  ]
-  +  "1422598280": [ 
-    "8": "0.000000;9.500000;19.000000"+    
-    "10": "NaN;NaN;NaN", +      "r": 8
-    "16": "0.000000;0.747650;1.176471", +      "v": "0", 
-    "x": 1422861711000 +      "s": "-1" 
-  }+    }
-  { +    
-    "8": "0.000000;9.500000;19.000000"+      "r": 10, 
-    "10": "NaN;NaN;NaN", +      "v": "", 
-    "16": "0.000000;0.748471;1.176471", +      "s": "" 
-    "x": 1422861819000 +    
-  }, +  ], 
-  +  "1422598285": 
-    "8": "0.000000;9.500000;19.000000"+    { 
-    "10": "NaN;NaN;NaN", +      "r": 8
-    "16": "0.000000;0.746659;1.176701", +      "v": "5", 
-    "x": 1422861927000 +      "s": "-1" 
-  }+    }, 
-  { +    
-    "8": "0.000000;9.500000;19.000000"+      "r": 10
-    "10": "NaN;NaN;NaN", +      "v": "", 
-    "16": "0.000000;0.755068;1.176932", +      "s": "" 
-    "x": 1422862034000 +    } 
-  }, +  ]
-  +  "1422598290":
-    "8": "0.000000;9.500000;19.000000"+    
-    "10": "NaN;NaN;NaN", +      "r": 8
-    "16": "0.000000;0.741844;1.000000", +      "v": "10", 
-    "x": 1422862142000 +      "s": "-1" 
-  }+    }, 
-  { +    
-    "8": "0.000000;9.500000;19.000000", +      "r": 10
-    "10": "NaN;NaN;NaN", +      "v": "", 
-    "16": "0.000000;0.740291;1.000000", +      "s": "" 
-    "x": 1422862250000 +    } 
-  }+  ]
-  { +  "1422598295":
-    "8": "0.000000;9.500000;19.000000"+    
-    "10": "NaN;NaN;NaN", +      "r": 8
-    "16": "0.000000;0.756320;1.176701", +      "v": "15", 
-    "x": 1422862358000 +      "s": "-1" 
-  }, +    }, 
-  +    
-    "8": "0.000000;9.500000;19.000000"+      "r": 10
-    "10": "NaN;NaN;NaN", +      "v": "", 
-    "16": "0.000000;0.746004;1.176471", +      "s": "" 
-    "x": 1422862465000 +    } 
-  }+  ]
-  { +  "1422598300": [ 
-    "8": "0.000000;9.500000;19.000000"+    
-    "10": "NaN;NaN;NaN", +      "r"8
-    "16": "0.000000;0.754233;1.176932", +      "v": "0", 
-    "x": 1422862573000 +      "s": "-1" 
-  }, +    }
-  +    
-    "8": "0.000000;9.500000;19.000000"+      "r": 10, 
-    "10": "NaN;NaN;NaN", +      "v": "", 
-    "16": "0.000000;0.740343;1.000000", +      "s": "" 
-    "x": 1422862681000 +    } 
-  }+  ]
-  { +  "1422598305":
-    "8": "0.000000;9.500000;19.000000"+    
-    "10": "NaN;NaN;NaN", +      "r": 8
-    "16": "0.000000;0.751393;1.176932", +      "v": "5", 
-    "x": 1422862788000 +      "s": "-1" 
-  }, +    }, 
-  +    
-    "8": "0.000000;9.500000;19.000000"+      "r": 10
-    "10": "NaN;NaN;NaN", +      "v": "", 
-    "16": "0.000000;0.750868;1.176932", +      "s": "" 
-    "x": 1422862896000 +    } 
-  }+  ]
-  { +  "1422598310":
-    "8": "0.000000;9.500000;19.000000", +    
-    "10": "NaN;NaN;NaN", +      "r": 8
-    "16": "0.000000;0.745956;1.176701", +      "v": "10", 
-    "x": 1422863004000 +      "s": "-1" 
-  }, +    }, 
-  { +    
-    "8": "0.000000;9.500000;19.000000", +      "r": 10
-    "10": "NaN;NaN;NaN", +      "v": "", 
-    "16": "0.000000;0.758306;1.176932", +      "s": "" 
-    "x": 1422863111000 +    } 
-  }, +  ]
-  { +  "1422598315":
-    "8": "0.000000;9.500000;19.000000", +    
-    "10": "NaN;NaN;NaN", +      "r": 8
-    "16": "0.000000;0.741780;1.000000", +      "v": "15", 
-    "x": 1422863219000 +      "s": "-1" 
-  }, +    }, 
-  { +    
-    "8": "0.000000;9.500000;19.000000", +      "r": 10
-    "10": "NaN;NaN;NaN", +      "v": "", 
-    "16": "0.000000;0.741780;1.000000", +      "s": "" 
-    "x": 1422863327000 +    } 
-  }, +  ]
-  { +  "1422598320": [ 
-    "8": "NaN;NaN;NaN", +    
-    "10": "NaN;NaN;NaN", +      "r": 8
-    "16": "NaN;NaN;NaN", +      "v": "0", 
-    "x": 1422863435000 +      "s": "-1" 
-  }, +    }
-  { +    
-    "8": "NaN;NaN;NaN", +      "r": 10, 
-    "10": "NaN;NaN;NaN", +      "v": "", 
-    "16": "NaN;NaN;NaN", +      "s": "" 
-    "x": 1422863542000 +    } 
-  }+  ]
 +  "1422598325": [ 
 +    
 +      "r": 8
 +      "v": "5", 
 +      "s": "-1" 
 +    }
 +    
 +      "r": 10, 
 +      "v": "", 
 +      "s": "" 
 +    } 
 +  ]
 +  "1422598330": [ 
 +    
 +      "r": 8
 +      "v": "10", 
 +      "s": "-1" 
 +    }
 +    
 +      "r": 10, 
 +      "v": "", 
 +      "s": "" 
 +    } 
 +  ]
 +  "1422598335": [ 
 +    
 +      "r": 8
 +      "v": "15", 
 +      "s": "-1" 
 +    }
 +    
 +      "r": 10, 
 +      "v": "", 
 +      "s": "" 
 +    } 
 +  ]
 +  "1422598340": [ 
 +    
 +      "r": 8
 +      "v": "0", 
 +      "s": "-1" 
 +    }
 +    
 +      "r": 10, 
 +      "v": "", 
 +      "s": "" 
 +    } 
 +  ]
 +  "1422598345": [ 
 +    
 +      "r": 8
 +      "v": "5", 
 +      "s": "-1" 
 +    }
 +    
 +      "r": 10, 
 +      "v": "", 
 +      "s": "" 
 +    } 
 +  ], 
 +  и т.д.
 ] ]
 </code> </code>
  
-The structure of the returned data is as followsAn array of objects is returned. Each object has an attribute 'x' - this is the timestamp of this entry. The time format is UnixTime multiplied by 1000 (the dimension is milliseconds).  +Returns the array, where the index is time in UnixTime formatElements of the array have another array of objects.   
-Also in this object there are attributes with values ​​for each register. The attribute name is the register ID. The attribute value is a string where the minimum, average and maximum value of the register on this interval is combined through a semicolon. For example, '0.000000; 0.755068; 1.176932' means that the register took values ​​from 0 to 1.176932, with its arithmetic mean being 0.755068. If in the given interval there is no data on the value of this registerthe system will return 'NaN; NaN; NaN'.+Each object has three properties: r, v, s.  
 + 
 +^r|is the register ID. For example, 10 | 
 +^v|is the value of the register at the specified time point or an empty string if there is no data for this register at this time. |  
 +^s|is the state of the register that matched it at the specified time: |   
 +| -1|Unknown | 
 +| 0|Disabled |  
 +| 1|Normal | 
 +| 2|Warning | 
 +| 3|Alert | 
 +'' (an empty string)|there is no register value|
  
 ===== Event list ===== ===== Event list =====
access_via_api.txt · Last modified: 2023/03/02 10:53 by emozolyak

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki