Grafana dashboard: Mirasys location occupancy
Description: This dashboard shows the current occupancy of a location based on VCA people counting and works for multiple entrances.

This dashboard shows the current occupancy of a location based on VCA people counting and works for multiple entrances.

{
  "__inputs": [
    {
      "name": "DS_DVMSDATA",
      "label": "DvmsData",
      "description": "Alarm database",
      "type": "datasource",
      "pluginId": "mssql",
      "pluginName": "Microsoft SQL Server"
    }
  ],
  "__requires": [
    {
      "type": "panel",
      "id": "bargauge",
      "name": "Bar Gauge",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "6.4.4"
    },
    {
      "type": "datasource",
      "id": "mssql",
      "name": "Microsoft SQL Server",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "singlestat",
      "name": "Singlestat",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": 12864,
  "graphTooltip": 0,
  "id": null,
  "links": [],
  "panels": [
    {
      "cacheTimeout": null,
      "colorBackground": true,
      "colorPostfix": false,
      "colorPrefix": false,
      "colorValue": false,
      "colors": [
        "#299c46",
        "rgba(237, 129, 40, 0.89)",
        "#d44a3a"
      ],
      "datasource": "${DS_DVMSDATA}",
      "decimals": 0,
      "format": "percentunit",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 20,
        "w": 8,
        "x": 0,
        "y": 0
      },
      "id": 4,
      "interval": null,
      "links": [],
      "mappingType": 2,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "options": {},
      "pluginVersion": "6.4.4",
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "100%",
      "rangeMaps": [
        {
          "from": "0",
          "text": "SHOP OCCUPANCY 76sqm available",
          "to": "1000"
        }
      ],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false,
        "ymax": null,
        "ymin": null
      },
      "tableColumn": "",
      "targets": [
        {
          "alias": "",
          "format": "table",
          "rawSql": "declare @InsToday float, @OutsToday float, @ShopCapacity float, @CurrentOccupation as float\r\n\r\nSELECT @ShopCapacity = 100\r\n\r\nSELECT @InsToday = COUNT(CONVERT(VARCHAR(10), [UtcStartTime], 102))\r\nFROM [DvmsData].[dbo].[AlarmEvent] AS Event INNER JOIN AlarmConfig AS Conf ON Event.AlarmConfigId = Conf.AlarmConfigId\r\nWHERE (Conf.AlarmName = 'In 1' OR Conf.AlarmName = 'In 2') AND CONVERT(VARCHAR(10), [UtcStartTime], 102) = CONVERT(VARCHAR(10), GETUTCDATE(), 102)\r\n\r\nSELECT @OutsToday = COUNT(CONVERT(VARCHAR(10), [UtcStartTime], 102))\r\nFROM [DvmsData].[dbo].[AlarmEvent] AS Event INNER JOIN AlarmConfig AS Conf ON Event.AlarmConfigId = Conf.AlarmConfigId\r\nWHERE (Conf.AlarmName = 'Out 1' OR Conf.AlarmName = 'Out 2') AND CONVERT(VARCHAR(10), [UtcStartTime], 102) = CONVERT(VARCHAR(10), GETUTCDATE(), 102)\r\n\r\nSELECT @CurrentOccupation = (@InsToday - @OutsToday)/@ShopCapacity\r\n\r\nSELECT @CurrentOccupation AS CurrentOccupation",
          "refId": "A"
        }
      ],
      "thresholds": "0.5,0.8",
      "timeFrom": null,
      "timeShift": null,
      "title": "",
      "type": "singlestat",
      "valueFontSize": "110%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "datasource": "${DS_DVMSDATA}",
      "gridPos": {
        "h": 20,
        "w": 6,
        "x": 8,
        "y": 0
      },
      "id": 6,
      "options": {
        "displayMode": "basic",
        "fieldOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "defaults": {
            "decimals": 0,
            "mappings": [],
            "max": 1,
            "min": 0,
            "thresholds": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "#EAB839",
                "value": 0.5
              },
              {
                "color": "semi-dark-red",
                "value": 0.8
              }
            ],
            "unit": "percentunit"
          },
          "override": {},
          "values": false
        },
        "orientation": "vertical"
      },
      "pluginVersion": "6.4.4",
      "targets": [
        {
          "alias": "",
          "format": "table",
          "rawSql": "declare @InsToday float, @OutsToday float, @ShopCapacity float, @CurrentOccupation as float\r\n\r\nSELECT @ShopCapacity = 100\r\n\r\nSELECT @InsToday = COUNT(CONVERT(VARCHAR(10), [UtcStartTime], 102))\r\nFROM [DvmsData].[dbo].[AlarmEvent] AS Event INNER JOIN AlarmConfig AS Conf ON Event.AlarmConfigId = Conf.AlarmConfigId\r\nWHERE (Conf.AlarmName = 'In 1' OR Conf.AlarmName = 'In 2') AND CONVERT(VARCHAR(10), [UtcStartTime], 102) = CONVERT(VARCHAR(10), GETUTCDATE(), 102)\r\n\r\nSELECT @OutsToday = COUNT(CONVERT(VARCHAR(10), [UtcStartTime], 102))\r\nFROM [DvmsData].[dbo].[AlarmEvent] AS Event INNER JOIN AlarmConfig AS Conf ON Event.AlarmConfigId = Conf.AlarmConfigId\r\nWHERE (Conf.AlarmName = 'Out 1' OR Conf.AlarmName = 'Out 2') AND CONVERT(VARCHAR(10), [UtcStartTime], 102) = CONVERT(VARCHAR(10), GETUTCDATE(), 102)\r\n\r\nSELECT @CurrentOccupation = (@InsToday - @OutsToday)/@ShopCapacity\r\n\r\nSELECT @CurrentOccupation AS CurrentOccupation",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "",
      "type": "bargauge"
    },
    {
      "cacheTimeout": null,
      "colorBackground": true,
      "colorPostfix": false,
      "colorPrefix": false,
      "colorValue": false,
      "colors": [
        "#299c46",
        "rgba(237, 129, 40, 0.89)",
        "#d44a3a"
      ],
      "datasource": "${DS_DVMSDATA}",
      "decimals": 0,
      "format": "percentunit",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 20,
        "w": 10,
        "x": 14,
        "y": 0
      },
      "id": 2,
      "interval": null,
      "links": [],
      "mappingType": 2,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "options": {},
      "pluginVersion": "6.4.4",
      "postfix": "",
      "postfixFontSize": "30%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "0",
          "text": "SAFE TO ENTER",
          "to": "0.5"
        },
        {
          "from": "0.51",
          "text": "NORMAL OCCUPANCY",
          "to": "0.8"
        },
        {
          "from": "0.81",
          "text": "CROWDED",
          "to": "0.99"
        },
        {
          "from": "1",
          "text": "PLEASE WAIT",
          "to": "100"
        }
      ],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false,
        "ymax": null,
        "ymin": null
      },
      "tableColumn": "",
      "targets": [
        {
          "alias": "",
          "format": "table",
          "rawSql": "declare @InsToday float, @OutsToday float, @ShopCapacity float, @CurrentOccupation as float\r\n\r\nSELECT @ShopCapacity = 100\r\n\r\nSELECT @InsToday = COUNT(CONVERT(VARCHAR(10), [UtcStartTime], 102))\r\nFROM [DvmsData].[dbo].[AlarmEvent] AS Event INNER JOIN AlarmConfig AS Conf ON Event.AlarmConfigId = Conf.AlarmConfigId\r\nWHERE (Conf.AlarmName = 'In 1' OR Conf.AlarmName = 'In 2') AND CONVERT(VARCHAR(10), [UtcStartTime], 102) = CONVERT(VARCHAR(10), GETUTCDATE(), 102)\r\n\r\nSELECT @OutsToday = COUNT(CONVERT(VARCHAR(10), [UtcStartTime], 102))\r\nFROM [DvmsData].[dbo].[AlarmEvent] AS Event INNER JOIN AlarmConfig AS Conf ON Event.AlarmConfigId = Conf.AlarmConfigId\r\nWHERE (Conf.AlarmName = 'Out 1' OR Conf.AlarmName = 'Out 2') AND CONVERT(VARCHAR(10), [UtcStartTime], 102) = CONVERT(VARCHAR(10), GETUTCDATE(), 102)\r\n\r\nSELECT @CurrentOccupation = (@InsToday - @OutsToday)/@ShopCapacity\r\n\r\nSELECT @CurrentOccupation AS CurrentOccupation",
          "refId": "A"
        }
      ],
      "thresholds": "0.5,0.8",
      "timeFrom": null,
      "timeShift": null,
      "title": "",
      "type": "singlestat",
      "valueFontSize": "200%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "cacheTimeout": null,
      "colorBackground": true,
      "colorPostfix": false,
      "colorPrefix": false,
      "colorValue": false,
      "colors": [
        "#299c46",
        "rgba(237, 129, 40, 0.89)",
        "#d44a3a"
      ],
      "datasource": "${DS_DVMSDATA}",
      "decimals": 0,
      "format": "percentunit",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 17,
        "w": 8,
        "x": 7,
        "y": 20
      },
      "id": 3,
      "interval": null,
      "links": [],
      "mappingType": 2,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "options": {},
      "pluginVersion": "6.4.4",
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "100%",
      "rangeMaps": [],
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false,
        "ymax": null,
        "ymin": null
      },
      "tableColumn": "",
      "targets": [
        {
          "alias": "",
          "format": "table",
          "rawSql": "declare @InsToday float, @OutsToday float, @ShopCapacity float, @CurrentOccupation as float\r\n\r\nSELECT @ShopCapacity = 100\r\n\r\nSELECT @InsToday = COUNT(CONVERT(VARCHAR(10), [UtcStartTime], 102))\r\nFROM [DvmsData].[dbo].[AlarmEvent] AS Event INNER JOIN AlarmConfig AS Conf ON Event.AlarmConfigId = Conf.AlarmConfigId\r\nWHERE (Conf.AlarmName = 'In 1' OR Conf.AlarmName = 'In 2') AND CONVERT(VARCHAR(10), [UtcStartTime], 102) = CONVERT(VARCHAR(10), GETUTCDATE(), 102)\r\n\r\nSELECT @OutsToday = COUNT(CONVERT(VARCHAR(10), [UtcStartTime], 102))\r\nFROM [DvmsData].[dbo].[AlarmEvent] AS Event INNER JOIN AlarmConfig AS Conf ON Event.AlarmConfigId = Conf.AlarmConfigId\r\nWHERE (Conf.AlarmName = 'Out 1' OR Conf.AlarmName = 'Out 2') AND CONVERT(VARCHAR(10), [UtcStartTime], 102) = CONVERT(VARCHAR(10), GETUTCDATE(), 102)\r\n\r\nSELECT @CurrentOccupation = (@InsToday - @OutsToday)/@ShopCapacity\r\n\r\nSELECT @CurrentOccupation AS CurrentOccupation",
          "refId": "A"
        }
      ],
      "thresholds": "0.5,0.8",
      "timeFrom": null,
      "timeShift": null,
      "title": "",
      "type": "singlestat",
      "valueFontSize": "200%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    }
  ],
  "refresh": "5s",
  "schemaVersion": 20,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ]
  },
  "timezone": "",
  "title": "Mirasys location occupancy",
  "uid": "jWw0qmMGz",
  "version": 4,
  "description": "This dashboard shows the current occupancy of a location based on VCA people counting and works for multiple entrances."
}