Butlr Developer Docs
  • Welcome
  • What is Butlr
  • Spatial Metrics
  • Getting Started
    • Authentication
    • Making your first query
    • Mint Client Credentials
  • Changelog
  • Asset Management
    • GraphQL API Overview
      • Sites
      • Buildings
      • Floors
      • Rooms
      • Zones
      • Hives
      • Sensors
      • Asset Tags
    • GraphQL API Introsepction
  • Historical Occupancy
    • Reporting API Overview
      • Floor Occupancy
      • Room Occupancy
      • Zone Occupancy
      • Query Occupancy by Tag
      • Traffic
      • Presence Time
      • Statistic Overview
    • FAQs
  • Real-time occupancy
    • Webhooks Overview
      • Area Detections
      • Entryway Traffic
      • Floor Occupancy
      • Room Occupancy
      • Zone Occupancy
      • Motion Detection
      • No Motion Detection
    • Manage Webhooks
      • Create Webhooks
      • Update Webhooks
      • Delete Webhooks
      • List Webhooks
  • LINKS
    • Butlr Postman Collection
    • Butlr Website
    • Status
    • Support
    • Log In
Powered by GitBook
On this page
  1. Historical Occupancy
  2. Reporting API Overview

Zone Occupancy

PreviousRoom OccupancyNextQuery Occupancy by Tag

Last updated 1 month ago

Zone occupancy refers to the number of people detected in a specific at a given time. It is calculated by consolidating data from multiple presence sensors within the zone.

Below are sample queries for retrieving zone-level occupancy data to analyze peak, and average within a selected time range.

Recommended Practices

  1. Recommended Aggregation by Query Interval: To ensure accurate interpretation of occupancy data, we recommend different aggregation methods based on the query interval:

    1. 1-Minute Interval (we recommend query for <24h time ranges only due to performance)

      Use median : this smooths out short-term fluctuations (e.g. quick in-and-outs) and best reflects actual occupancy minute-to-minute.

    2. Larger Intervals (e.g. hourly, daily)

      1. Use mean for average occupancy over the interval to help identify overall usage patterns.

      2. Use max for peak occupancy within the interval to understand the busiest times or capacity thresholds.

  2. Avoid Relative Time Queries: Do not use relative time functionality (e.g., -5m) as it may result in missing data depending on query timing. Always specify absolute start and stop times.

  3. Timezone Configuration: Always provide a timezone when querying traffic-based occupancy

  4. Include Zero Values in Output: To ensure zero values are included in the results, add the filter:

    "filter": { "value": { "gte": 0 } }

Presence-based Zone Occupancy

Use the sample queries below to retrieve the total occupancy for areas covered by presence sensors in the zone. Keep in mind that the sensor coverage area influences the count and may not represent the zone's actual occupancy.

Query the peak hourly occupancy of a room with presence sensors installed:

Use measurement: zone_occupancy

Use function: max

Request
// POST https://api.butlr.io/api/v3/reporting
{
    "window": {
        "every": "1h",
        "function": "max",
        "timezone": "Europe/Amsterdam" 
    },
    "filter": {
        "start": "2024-01-01T04:00:00Z",
        "stop": "2024-01-02T04:00:00Z",
        "measurements": ["zone_occupancy"],
        "zones": {
            "eq": ["zone_2qfew7oRPTDPQ0f7X9ZotfoiI3w"]
        }
    },
    "group_by": {
      "order": ["time"]
    }
}

Response
// POST https://api.butlr.io/api/v3/reporting
{
   "data": {
	"2024-01-01T04:00:00Z": {
		"sum": 2,
		"min": 1,
		"max": 1,//peak
		"count": 2,
		"mean": 1,
		"median": 1,
		"stddev": 0,
		"first": 1,
		"last": 1
	 }
    }
}

Query the average hourly occupancy of a room with presence sensors installed:

Use measurement: zone_occupancy

Use function: mean

Request
// POST https://api.butlr.io/api/v3/reporting
{
    "window": {
        "every": "1h",
        "function": "mean",
        "timezone": "Europe/Amsterdam" 
    },
    "filter": {
        "start": "2024-01-01T04:00:00Z",
        "stop": "2024-01-01T04:00:00Z",
        "measurements": ["zone_occupancy"],
        "zones": {
            "eq": ["zone_2qfew7oRPTDPQ0f7X9ZotfoiI3w"]
        }
    },
    "group_by": {
      "order": ["time"]
    }
}

Response
// POST https://api.butlr.io/api/v3/reporting
{
    "data": {
	"2024-01-01T04:00:00Z": {
		"sum": 2,
		"min": 1,
		"max": 1,
		"count": 2,
		"mean": 1,//average
		"median": 1,
		"stddev": 0,
		"first": 1,
		"last": 1
	}
    }
}

zone