Mirasys Restaurant Occupancy
Adjustments for restaurant usage
Maximum amount of person have to be adjusted in the Edit mode in the local variable @ShopCapacity (in every panel).
Adjustments for restaurant usage
{
  "__inputs": [
    {
      "name": "DS_DVMSDATA",
      "label": "DvmsData",
      "description": "",
      "type": "datasource",
      "pluginId": "mssql",
      "pluginName": "Microsoft SQL Server"
    }
  ],
  "__requires": [
    {
      "type": "panel",
      "id": "bargauge",
      "name": "Bar gauge",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "7.3.2"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "mssql",
      "name": "Microsoft SQL Server",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "singlestat",
      "name": "Singlestat",
      "version": ""
    },
    {
      "type": "panel",
      "id": "text",
      "name": "Text",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "description": "Adjustments for restaurant usage",
  "editable": true,
  "gnetId": 13464,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1606291138874,
  "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,
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "format": "none",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 5,
        "w": 12,
        "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,
      "pluginVersion": "6.4.4",
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "100%",
      "rangeMaps": [
        {
          "from": "0",
          "text": "Current restaurant occupancy (no recording)",
          "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 = 30\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' OR Conf.AlarmName = 'In 2') AND $__timeFilter(UtcStartTime)\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' OR Conf.AlarmName = 'Out 2') AND $__timeFilter(UtcStartTime)\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"
    },
    {
      "cacheTimeout": null,
      "colorBackground": true,
      "colorPostfix": false,
      "colorPrefix": false,
      "colorValue": false,
      "colors": [
        "#299c46",
        "rgba(237, 129, 40, 0.89)",
        "#d44a3a"
      ],
      "datasource": "${DS_DVMSDATA}",
      "decimals": 0,
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "format": "none",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 5,
        "w": 12,
        "x": 12,
        "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,
      "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 = 30\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' OR Conf.AlarmName = 'In 2') AND $__timeFilter(UtcStartTime)\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' OR Conf.AlarmName = 'Out 2') AND $__timeFilter(UtcStartTime)\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"
    },
    {
      "datasource": "${DS_DVMSDATA}",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {},
          "decimals": 0,
          "mappings": [],
          "max": 1,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "#EAB839",
                "value": 0.5
              },
              {
                "color": "semi-dark-red",
                "value": 0.8
              }
            ]
          },
          "unit": "percentunit"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 11,
        "w": 6,
        "x": 0,
        "y": 5
      },
      "id": 6,
      "options": {
        "displayMode": "basic",
        "orientation": "vertical",
        "reduceOptions": {
          "calcs": [
            "last"
          ],
          "fields": "",
          "values": false
        },
        "showUnfilled": true
      },
      "pluginVersion": "7.3.2",
      "targets": [
        {
          "alias": "",
          "format": "table",
          "rawSql": "declare @InsToday float, @OutsToday float, @ShopCapacity float, @CurrentOccupation as float\r\n\r\nSELECT @ShopCapacity = 30\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' OR Conf.AlarmName = 'In 2') AND $__timeFilter(UtcStartTime)\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' OR Conf.AlarmName = 'Out 2') AND $__timeFilter(UtcStartTime)\r\n\r\nSELECT @CurrentOccupation = (@InsToday - @OutsToday)/@ShopCapacity if(@CurrentOccupation > 0)\r\n\r\nSELECT @CurrentOccupation AS CurrentOccupation",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "(last 3 hours)",
      "type": "bargauge"
    },
    {
      "aliasColors": {},
      "bars": true,
      "cacheTimeout": null,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_DVMSDATA}",
      "fieldConfig": {
        "defaults": {
          "custom": {},
          "links": []
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 7,
        "w": 18,
        "x": 6,
        "y": 5
      },
      "hiddenSeries": false,
      "id": 3,
      "legend": {
        "alignAsTable": false,
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": false,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "7.3.2",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": true,
      "steppedLine": false,
      "targets": [
        {
          "alias": "",
          "format": "time_series",
          "hide": false,
          "rawSql": "SELECT\n  \n\tCOUNT(dbo.AlarmConfig.AlarmName) AS 'Value',\n  \n\tdbo.AlarmConfig.AlarmName AS metric,\n  \n\t$__timeGroup(dbo.AlarmEvent.UtcStartTime, '5m', 0) AS time\n\nFROM\n  \n\tdbo.AlarmConfig    INNER JOIN\n                      dbo.AlarmEvent ON dbo.AlarmConfig.AlarmConfigId = dbo.AlarmEvent.AlarmConfigId\nWHERE\n  \n\t$__timeFilter(dbo.AlarmEvent.UtcStartTime) AND \n\n\tdbo.AlarmConfig.AlarmName in ($Alarms) AND dbo.AlarmConfig.TriggerChannelNumber in ($Channels) AND\n \n\tdbo.AlarmConfig.RecorderName in ($Servers)\nGROUP BY $__timeGroup(dbo.AlarmEvent.UtcStartTime, '5m', 0), dbo.AlarmConfig.AlarmName",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Person movement (last 3 hours)",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:157",
          "decimals": 0,
          "format": "none",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": "0",
          "show": true
        },
        {
          "$$hashKey": "object:158",
          "decimals": 0,
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": true,
      "cacheTimeout": null,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_DVMSDATA}",
      "fieldConfig": {
        "defaults": {
          "custom": {},
          "links": []
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 7,
        "w": 18,
        "x": 6,
        "y": 12
      },
      "hiddenSeries": false,
      "id": 8,
      "interval": "5h",
      "legend": {
        "alignAsTable": false,
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": true,
        "sideWidth": 40,
        "total": false,
        "values": false
      },
      "lines": false,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "options": {
        "alertThreshold": false
      },
      "percentage": false,
      "pluginVersion": "7.3.2",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": true,
      "steppedLine": false,
      "targets": [
        {
          "alias": "",
          "format": "time_series",
          "hide": false,
          "rawSql": "SELECT\n  \n\tCOUNT(dbo.AlarmConfig.AlarmName) AS 'Value',\n  \n\tdbo.AlarmConfig.AlarmName AS metric,\n  \n\t$__timeGroup(dbo.AlarmEvent.UtcStartTime, '30m', 0) AS time\n\nFROM\n  \n\tdbo.AlarmConfig    INNER JOIN\n                      dbo.AlarmEvent ON dbo.AlarmConfig.AlarmConfigId = dbo.AlarmEvent.AlarmConfigId\nWHERE\n  \n\tCONVERT(VARCHAR(10), [UtcStartTime], 102) >= CONVERT(VARCHAR(10), GETUTCDATE()-7, 102) AND \n\n\tdbo.AlarmConfig.AlarmName in ($Alarms) AND dbo.AlarmConfig.TriggerChannelNumber in ($Channels) AND\n \n\tdbo.AlarmConfig.RecorderName in ($Servers)\nGROUP BY $__timeGroup(dbo.AlarmEvent.UtcStartTime, '30m', 0), dbo.AlarmConfig.AlarmName",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": "7d",
      "timeRegions": [],
      "timeShift": null,
      "title": "Person movement (last 7 days)",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:83",
          "decimals": 0,
          "format": "short",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": "0",
          "show": true
        },
        {
          "$$hashKey": "object:84",
          "decimals": 0,
          "format": "dateTimeFromNow",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": true,
        "alignLevel": null
      }
    },
    {
      "cacheTimeout": null,
      "datasource": "${DS_DVMSDATA}",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "gridPos": {
        "h": 3,
        "w": 6,
        "x": 0,
        "y": 16
      },
      "id": 7,
      "interval": null,
      "links": [],
      "maxDataPoints": 100,
      "options": {
        "content": "<img style=\"\" data-type=\"image\" itemprop=\"image\" src=\"/public/img/Mirasys_black_deep.JPG\">\r\n",
        "mode": "html"
      },
      "pluginVersion": "7.3.2",
      "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": "text"
    }
  ],
  "refresh": "5s",
  "schemaVersion": 26,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_DVMSDATA}",
        "definition": "SELECT          distinct dvmsdata.dbo.AlarmConfig.AlarmName FROM \tdvmsdata.dbo.AlarmConfig",
        "error": null,
        "hide": 0,
        "includeAll": true,
        "label": "Alarms",
        "multi": true,
        "name": "Alarms",
        "options": [],
        "query": "SELECT          distinct dvmsdata.dbo.AlarmConfig.AlarmName FROM \tdvmsdata.dbo.AlarmConfig",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_DVMSDATA}",
        "definition": "SELECT          distinct dvmsdata.dbo.AlarmConfig.TriggerChannelNumber  FROM \tdvmsdata.dbo.AlarmConfig",
        "error": null,
        "hide": 0,
        "includeAll": true,
        "label": "Channels",
        "multi": true,
        "name": "Channels",
        "options": [],
        "query": "SELECT          distinct dvmsdata.dbo.AlarmConfig.TriggerChannelNumber  FROM \tdvmsdata.dbo.AlarmConfig",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_DVMSDATA}",
        "definition": "SELECT          distinct dvmsdata.dbo.AlarmConfig.RecorderName  FROM \tdvmsdata.dbo.AlarmConfig",
        "error": null,
        "hide": 0,
        "includeAll": true,
        "label": "Servers",
        "multi": true,
        "name": "Servers",
        "options": [],
        "query": "SELECT          distinct dvmsdata.dbo.AlarmConfig.RecorderName  FROM \tdvmsdata.dbo.AlarmConfig",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-3h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ]
  },
  "timezone": "",
  "title": "Mirasys Restaurant Occupancy",
  "uid": "jWw0qmMGz",
  "version": 33
}