The Occupancy API provides a Boolean value of 0 or 1 to indicate occupied (1) or unoccupied (0) for a specified asset. There are no units for this value.
Use the following URL method structure to retrieve historical occupancy data for a selected asset.
| METHOD: |
GET |
| URI: |
<production url>/v1/assets/{id}/events?event-types=OCCUPANCY(start-ts,end-ts,size,page) |
| SAMPLE URI: |
<production url>/v1/assets/1000000540/events?event-types=OCCUPANCY&start-ts=1453766605577&end-ts=1453772603879&size=10&page=1 |
Query Parameters
| Parameter |
Description |
Required? |
Values |
| id |
GE identifier for an asset. |
Yes |
For example, 1000000540. |
| event-types |
Filter by type of event. |
Yes |
Event expressed as a string, such as OCCUPANCY. |
| start-ts |
Start timestamp in milliseconds. |
Yes |
Numerical value, such as 1460823091064. |
| end-ts |
End timestamp in milliseconds. |
Yes |
Numerical value, such as 1460998885254. |
| Page |
Page number. |
No |
Numerical value, such as 1. |
| Size |
Maximum number of records per page. If no size is specified, the default limit applies. |
No |
Numerical value, such as 1453772603879. |
Response Parameters
| Parameter |
Data Type |
Required? |
Description |
| _embedded |
Object |
Yes |
Length of time (seconds) spent in a particular zone. |
| events |
Array |
Yes |
List of events |
| ….measures |
Array |
Yes |
Provides the following values:- tag: OCCUPANCY
- value: 1
- unit: null
|
| ….event-uid |
String |
Yes |
Unique identifier established by a customer or external resource for the event. For this example, it is null. |
| ….timestamp |
Number |
Yes |
Actual timestamp when event occurred, such as 1460823106425. |
| ….event-types |
String |
Yes |
Type of event recorded, such as OCCUPANCY. |
| ….device-uid |
String |
Yes |
Unique identifier established by a customer or external resource, such as Sensor_250_50. |
| ….location-uid |
String |
Yes |
Unique identifier established by a customer or external resource for a specific location within the monitored area, such as Sensor_250_50. |
| _links |
Object |
Yes |
HREFs related to this specific node.- self: Link to the asset details using the GE identifier. See the Get Asset Details section for information on obtaining additional data.
- next page: HREFs to navigate the result set using paging.
|
| page |
Object |
Yes |
Pageable information satisfying the search filter. |
| ….size |
Number |
No |
Maximum number of records to return per page, such as 2. |
| ….totalElements |
Number |
No |
Total number of elements, such as 6. |
| ….totalPages |
Number |
No |
Total number of pages, such as 3. |
| ….number |
Number |
No |
Indicates the page number displayed when returned. Default value is 0. |
Sample Response
{
"_embedded": {
"events": [
{
"properties": {},
"measures": [
{
"tag": "OCCUPANCY",
"value": 1,
"unit": ""
}
],
"event-uid": null,
"timestamp": 1461174096503,
"event-type": "OCCUPANCY",
"device-uid": "Sensor_250_50",
"location-uid": "Sensor_250_50"
},
{
"properties": {},
"measures": [
{
"tag": "OCCUPANCY",
"value": 1,
"unit": ""
}
],
"event-uid": null,
"timestamp": 1461174156504,
"event-type": "OCCUPANCY",
"device-uid": "Sensor_250_50",
"location-uid": "Sensor_250_50"
}
]
},
"_links": {
"self": {
"href": "http://ie-environmental-dev.run.aws-usw02-pr.ice.predix.io/v1/assets/1000000540/events?start-ts=1461113400000&end-ts=1461199342009&event-types=OCCUPANCY"
},
"next-page": {
"href": "http://ie-environmental-dev.run.aws-usw02-pr.ice.predix.io/v1/assets/1000000540/events?event-types=OCCUPANCY&start-ts=1461174156504&end-ts=1461199342009&size=2"
}
},
"page": {
"size": 2,
"totalElements": 6,
"totalPages": 3,
"number": 0
}
}