ezeio2:apiref:subscribe

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
ezeio2:apiref:subscribe [2021-01-27 00:12] andrehezeio2:apiref:subscribe [2021-01-28 23:49] (current) andreh
Line 1: Line 1:
 ==== subscribe ==== ==== subscribe ====
  
-Request a websocket data stream, and commands to manage the data stream+Request a websocket data stream, and commands to manage the data stream.
  
 === Description === === Description ===
Line 11: Line 11:
  
 Subsequent calls using the subscribe command are used to manage the data stream. Subsequent calls using the subscribe command are used to manage the data stream.
 +
 +<WRAP center round important 60%>
 +This functionality requires firmware 21012701 or later in the device.
 +</WRAP>
 +
  
 === Parameters === === Parameters ===
Line 104: Line 109:
  
 The data received will have a ''type'', describing what kind of data this is: The data received will have a ''type'', describing what kind of data this is:
-| LOGDATA | The field data is from the 'fast log'. The interval is determined by the log interval setting on each field. | +''LOGDATA'' | The field data is from the 'fast log'. The interval is determined by the log interval setting on each field. | 
-| STATUS | The field data is from the 'status log'. The interval is fixed to 10 minutes. |+''STATUS'' | The field data is from the 'status log'. The interval is fixed to 10 minutes. |
  
 Note that the ezeio normally buffers data before the data is uploaded to the cloud servers, so the data may be delayed with up to 20 minutes  Note that the ezeio normally buffers data before the data is uploaded to the cloud servers, so the data may be delayed with up to 20 minutes 
  
 The STATUS updates will be sent every 10 minutes even if a faster subscription is active. The STATUS updates will be sent every 10 minutes even if a faster subscription is active.
 +
 +This is an example of what a ''STATUS'' update looks like (whitespace added for readability):
 +<code javascript>
 +{
 +  "channel": "export:123",
 +  "data": {
 +    "type": "STATUS",
 +    "serial": "ABC-123",
 +    "time": "2021-01-31T14:20:00Z",
 +    "fields": [
 +      {
 +        "1": 73.4
 +      },
 +      {
 +        "2": 8.112
 +      }
 +    ]
 +  }
 +}
 +</code>
 +Note that the fields array will include all configured fields for this unit - regardless of their log setting. All fields are always logged every 10 minutes.
 +
 +A ''LOGDATA'' update has the following format (whitespace added for readability):
 +<code javascript>
 +{
 +  "channel": "export:123",
 +  "data": {
 +    "type": "LOGDATA",
 +    "serial": "ABC-123",
 +    "time": "2021-01-31T14:21:15Z",
 +    "timeout": 0,
 +    "fields": [
 +      {
 +        "2": 9.021
 +      }
 +    ]
 +  }
 +}
 +</code>
 +Note that this message only includes the fields that are configured for fast logging (interval less than 10 minutes). Please see below for the meaning of the ''timeout'' property.
  
 **Step 3 : Request subscription changes** **Step 3 : Request subscription changes**
Line 115: Line 160:
 With an open websocket and while receiving data from the ezeio system, you can call the subscribe API to request immediate updates or to cancel updates from a certain ezeio. With an open websocket and while receiving data from the ezeio system, you can call the subscribe API to request immediate updates or to cancel updates from a certain ezeio.
  
-To request fast updates, the call is: +To request unbuffered log updates, the call is: 
-<code>https://api.eze.io/v1/subscribe/wstktXXXXXXXXXXXXXXXXXXXXXXX/!ABC123</code>+<code>https://api.eze.io/v1/subscribe/wstktXXXXXXXXXXXXXXXXXXXXXXX/ABC123</code> 
 +The log updates will revert to normal (buffered) mode after 30 minutes.
  
 To cancel updates, the call is: To cancel updates, the call is:
Line 122: Line 168:
  
 Multiple requests can be sent in the same command: Multiple requests can be sent in the same command:
-<code>https://api.eze.io/v1/subscribe/wstktXXXXXXXXXXXXXXXXXXXXXXX/-ABC123,!ABC124,!ABC321,-ABC322</code> +<code>https://api.eze.io/v1/subscribe/wstktXXXXXXXXXXXXXXXXXXXXXXX/-ABC123,ABC124,ABC321,-ABC322</code> 
 +Up to 50 devices can be included in the same command
  
-=== Example code (PHP) ===+=== Example code to set up the websocket channel and receive data (PHP) ===
 <code php> <code php>
 <?php <?php
  • ezeio2/apiref/subscribe.1611706346.txt.gz
  • Last modified: 2021-01-27 00:12
  • by andreh