Skip to content

Plugin file

Plugin configuration file
{
    "name": "milesight-iot-vs321",
    "version": "1.0.0",
    "description": "VS321 is a low-power, battery-operated wireless occupancy sensor empowered by advancedAI algorithms.It achieves up to 95% occupancy detection accuracy powered by its AI algorithm.",
    "author": "Thinger.io",
    "license": "MIT",
    "repository": {
        "type": "git",
        "url": "https://github.com/thinger-io/plugins.git",
        "directory": "milesight-iot-vs321"
    },
    "metadata": {
        "name": "Milesight-Iot VS321",
        "description": "VS321 is a low-power, battery-operated wireless occupancy sensor empowered by advancedAI algorithms.It achieves up to 95% occupancy detection accuracy powered by its AI algorithm.",
        "image": "assets/vs321.png",
        "category": "devices",
        "vendor": "milesight-iot"
    },
    "resources": {
        "products": [
            {
                "description": "VS321 is a low-power, battery-operated wireless occupancy sensor empowered by advancedAI algorithms.It achieves up to 95% occupancy detection accuracy powered by its AI algorithm.",
                "enabled": true,
                "name": "Milesight-Iot VS321",
                "product": "milesight_iot_vs321",
                "profile": {
                    "api": {
                        "downlink": {
                            "enabled": true,
                            "handle_connectivity": false,
                            "request": {
                                "data": {
                                    "path": "/downlink",
                                    "payload": "{\r\n    \"data\"    : \"{{payload.data=\"\"}}\",\r\n    \"port\"    :  {{payload.port=2}},\r\n    \"priority\":  {{payload.priority=3}},\r\n    \"confirmed\" :  {{payload.confirmed=false}},\r\n    \"uplink\"  :  {{property.uplink}} \r\n}",
                                    "payload_type": "",
                                    "plugin": "{{property.uplink.source}}",
                                    "target": "plugin_endpoint"
                                }
                            }
                        },
                        "uplink": {
                            "enabled": true,
                            "handle_connectivity": true,
                            "request": {
                                "data": {
                                    "payload": "{{payload}}",
                                    "payload_type": "source_payload",
                                    "resource_stream": "uplink",
                                    "target": "resource_stream"
                                }
                            }
                        }
                    },
                    "autoprovisions": {
                        "device_autoprovisioning": {
                            "config": {
                                "mode": "pattern",
                                "pattern": "vs321_.*"
                            },
                            "enabled": true
                        }
                    },
                    "buckets": {
                        "milesight_vs321_data": {
                            "backend": "mongodb",
                            "data": {
                                "payload": "{{payload}}",
                                "payload_function": "",
                                "payload_type": "source_payload",
                                "resource_stream": "uplink_decoded",
                                "source": "resource_stream"
                            },
                            "enabled": true,
                            "retention": {
                                "period": 3,
                                "unit": "months"
                            },
                            "tags": []
                        }
                    },
                    "code": {
                        "code": "function decodeThingerUplink(thingerData) {\n    // 0. If data has already been decoded, we will return it\n    if (thingerData.decodedPayload) return thingerData.decodedPayload;\n    \n    // 1. Extract and Validate Input\n    // We need 'payload' (hex string) and 'fPort' (integer)\n    const hexPayload = thingerData.payload || \"\";\n    const port = thingerData.fPort || 1;\n\n    // 2. Convert Hex String to Byte Array\n    const bytes = [];\n    for (let i = 0; i < hexPayload.length; i += 2) {\n        bytes.push(parseInt(hexPayload.substr(i, 2), 16));\n    }\n\n    // 3. Dynamic Function Detection and Execution\n    \n    // CASE A: (The Things Stack v3)\n    if (typeof decodeUplink === 'function') {\n        try {\n            const input = {\n                bytes: bytes,\n                fPort: port\n            };\n            var result = decodeUplink(input);\n            \n            if (result.data) return result.data;\n\n            return result; \n        } catch (e) {\n            console.error(\"Error inside decodeUplink:\", e);\n            throw e;\n        }\n    }\n\n    // CASE B: Legacy TTN (v2)\n    else if (typeof Decoder === 'function') {\n        try {\n            return Decoder(bytes, port);\n        } catch (e) {\n            console.error(\"Error inside Decoder:\", e);\n            throw e;\n        }\n    }\n\n    // CASE C: No decoder found\n    else {\n        throw new Error(\"No compatible TTN decoder function (decodeUplink or Decoder) found in scope.\");\n    }\n}\n\n\n// TTN decoder\nfunction decodeUplink(input) {\n    var res = Decoder(input.bytes, input.fPort);\n    if (res.error) {\n        return {\n            errors: [res.error],\n        };\n    }\n    return {\n        data: res,\n    };\n}\n/**\n * Payload Decoder\n *\n * Copyright 2025 Milesight IoT\n *\n * @product VS321\n */\nvar RAW_VALUE = 0x00;\n\n/* eslint no-redeclare: \"off\" */\n/* eslint-disable */\n\n// The Things Network\nfunction Decoder(bytes, port) {\n    return milesightDeviceDecode(bytes);\n}\n/* eslint-enable */\n\nfunction milesightDeviceDecode(bytes) {\n    var decoded = {};\n    for (var i = 0; i < bytes.length;) {\n        var channel_id = bytes[i++];\n        var channel_type = bytes[i++];\n\n        // IPSO VERSION\n        if (channel_id === 0xff && channel_type === 0x01) {\n            decoded.ipso_version = readProtocolVersion(bytes[i]);\n            i += 1;\n        }\n        // HARDWARE VERSION\n        else if (channel_id === 0xff && channel_type === 0x09) {\n            decoded.hardware_version = readHardwareVersion(bytes.slice(i, i + 2));\n            i += 2;\n        }\n        // FIRMWARE VERSION\n        else if (channel_id === 0xff && channel_type === 0x0a) {\n            decoded.firmware_version = readFirmwareVersion(bytes.slice(i, i + 2));\n            i += 2;\n        }\n        // TSL VERSION\n        else if (channel_id === 0xff && channel_type === 0xff) {\n            decoded.tsl_version = readTslVersion(bytes.slice(i, i + 2));\n            i += 2;\n        }\n        // SERIAL NUMBER\n        else if (channel_id === 0xff && channel_type === 0x16) {\n            decoded.sn = readSerialNumber(bytes.slice(i, i + 8));\n            i += 8;\n        }\n        // LORAWAN CLASS TYPE\n        else if (channel_id === 0xff && channel_type === 0x0f) {\n            decoded.lorawan_class = readLoRaWANClass(bytes[i]);\n            i += 1;\n        }\n        // RESET EVENT\n        else if (channel_id === 0xff && channel_type === 0xfe) {\n            decoded.reset_event = readResetEvent(1);\n            i += 1;\n        }\n        // DEVICE STATUS\n        else if (channel_id === 0xff && channel_type === 0x0b) {\n            decoded.device_status = readDeviceStatus(1);\n            i += 1;\n        }\n        // BATTERY\n        else if (channel_id === 0x01 && channel_type === 0x75) {\n            decoded.battery = readUInt8(bytes[i]);\n            i += 1;\n        }\n        // TEMPERATURE\n        else if (channel_id === 0x03 && channel_type === 0x67) {\n            var temperature_value = readUInt16LE(bytes.slice(i, i + 2));\n            if (temperature_value === 0xFFFF) {\n                decoded.temperature_sensor_status = readSensorStatus(2);\n            } else {\n                decoded.temperature = readInt16LE(bytes.slice(i, i + 2)) / 10;\n            }\n            i += 2;\n        }\n        // HUMIDITY\n        else if (channel_id === 0x04 && channel_type === 0x68) {\n            var humidity_value = readUInt8(bytes[i]);\n            if (humidity_value === 0xFF) {\n                decoded.humidity_sensor_status = readSensorStatus(2);\n            } else {\n                decoded.humidity = readUInt8(bytes[i]) / 2;\n            }\n            i += 1;\n        }\n        // PEOPLE TOTAL COUNTS\n        else if (channel_id === 0x05 && channel_type === 0xfd) {\n            decoded.people_total_counts = readUInt16LE(bytes.slice(i, i + 2));\n            i += 2;\n        }\n        // REGION OCCUPANCY\n        else if (channel_id === 0x06 && channel_type === 0xFE) {\n            var region_mask = readUInt16LE(bytes.slice(i, i + 2));\n            var region_data = readUInt16LE(bytes.slice(i + 2, i + 4));\n            var region_offset = { region_1: 0, region_2: 1, region_3: 2, region_4: 3, region_5: 4, region_6: 5, region_7: 6, region_8: 7, region_9: 8, region_10: 9 };\n            for (var key in region_offset) {\n                decoded[key + \"_enable\"] = readEnableStatus((region_mask >>> region_offset[key]) & 0x01);\n                decoded[key] = readOccupancyStatus((region_data >>> region_offset[key]) & 0x01);\n            }\n            i += 4;\n        }\n        // ILLUMINANCE STATUS\n        else if (channel_id === 0x07 && channel_type === 0xFF) {\n            decoded.illuminance_status = readIlluminanceStatus(bytes[i]);\n            i += 1;\n        }\n        // CONFIDENCE STATUS\n        else if (channel_id === 0x08 && channel_type === 0xF4) {\n            // skip first byte\n            decoded.detection_status = readDetectionStatus(bytes[i + 1]);\n            i += 2;\n        }\n        // TIMESTAMP\n        else if (channel_id === 0x0a && channel_type === 0xEF) {\n            decoded.timestamp = readUInt32LE(bytes.slice(i, i + 4));\n            i += 4;\n        }\n        // TEMPERATURE ALARM\n        else if (channel_id === 0x83 && channel_type === 0x67) {\n            decoded.temperature = readInt16LE(bytes.slice(i, i + 2)) / 10;\n            decoded.temperature_alarm = readTemperatureAlarm(bytes[i + 2]);\n            i += 3;\n        }\n        // HUMIDITY ALARM\n        else if (channel_id === 0x84 && channel_type === 0x68) {\n            decoded.humidity = readUInt8(bytes[i]) / 2;\n            decoded.humidity_alarm = readHumidityAlarm(bytes[i + 1]);\n            i += 2;\n        }\n        else if (channel_id === 0x20 && channel_type === 0xce) {\n            var data = {};\n            data.timestamp = readUInt32LE(bytes.slice(i, i + 4));\n            var mode = readUInt8(bytes[i + 4]);\n            if (mode === 0x00) {\n                data.people_total_counts = readUInt16LE(bytes.slice(i + 5, i + 7));\n                i += 7;\n            } else if (mode === 0x01) {\n                var data_mask = readUInt16LE(bytes.slice(i + 5, i + 7));\n                var data_value = readUInt16LE(bytes.slice(i + 7, i + 9));\n                var data_offset = { region_1: 0, region_2: 1, region_3: 2, region_4: 3, region_5: 4, region_6: 5, region_7: 6, region_8: 7, region_9: 8, region_10: 9 };\n                for (var key in data_offset) {\n                    data[key + \"_enable\"] = readEnableStatus((data_mask >>> data_offset[key]) & 0x01);\n                    data[key] = readOccupancyStatus((data_value >>> data_offset[key]) & 0x01);\n                }\n                i += 9;\n            }\n            decoded.history = decoded.history || [];\n            decoded.history.push(data);\n        }\n        // DOWNLINK RESPONSE\n        else if (channel_id === 0xfe || channel_id === 0xff) {\n            var result = handle_downlink_response(channel_type, bytes, i);\n            decoded = Object.assign(decoded, result.data);\n            i = result.offset;\n        } else if (channel_id === 0xf8 || channel_id === 0xf9) {\n            var result = handle_downlink_response_ext(channel_id, channel_type, bytes, i);\n            decoded = Object.assign(decoded, result.data);\n            i = result.offset;\n        } else {\n            break;\n        }\n    }\n\n    return decoded;\n}\n\nfunction handle_downlink_response(channel_type, bytes, offset) {\n    var decoded = {};\n\n    switch (channel_type) {\n        case 0x02:\n            decoded.collection_interval = readUInt16LE(bytes.slice(offset, offset + 2));\n            offset += 2;\n            break;\n        case 0x06:\n            var data = readUInt8(bytes[offset]);\n            var condition_value = data & 0x07;\n            var channel_id = (data >>> 3 & 0x07);\n            if (channel_id === 0x01) {\n                decoded.temperature_alarm_config = {};\n                decoded.temperature_alarm_config.condition = readConditionType(condition_value);\n                decoded.temperature_alarm_config.threshold_min = readInt16LE(bytes.slice(offset + 1, offset + 3)) / 10;\n                decoded.temperature_alarm_config.threshold_max = readInt16LE(bytes.slice(offset + 3, offset + 5)) / 10;\n                decoded.temperature_alarm_config.lock_time = readUInt16LE(bytes.slice(offset + 5, offset + 7));\n                decoded.temperature_alarm_config.continue_time = readUInt16LE(bytes.slice(offset + 7, offset + 9));\n            } else if (channel_id === 0x02) {\n                decoded.humidity_alarm_config = {};\n                decoded.humidity_alarm_config.condition = readConditionType(condition_value);\n                decoded.humidity_alarm_config.threshold_min = readUInt16LE(bytes.slice(offset + 1, offset + 3)) / 2;\n                decoded.humidity_alarm_config.threshold_max = readUInt16LE(bytes.slice(offset + 3, offset + 5)) / 2;\n                decoded.humidity_alarm_config.lock_time = readUInt16LE(bytes.slice(offset + 5, offset + 7));\n                decoded.humidity_alarm_config.continue_time = readUInt16LE(bytes.slice(offset + 7, offset + 9));\n            } else if (channel_id === 0x03) {\n                decoded.illuminance_alarm_config = {};\n                decoded.illuminance_alarm_config.condition = readConditionType(condition_value);\n                decoded.illuminance_alarm_config.threshold_min = readUInt16LE(bytes.slice(offset + 1, offset + 3));\n                decoded.illuminance_alarm_config.threshold_max = readUInt16LE(bytes.slice(offset + 3, offset + 5));\n                decoded.illuminance_alarm_config.lock_time = readUInt16LE(bytes.slice(offset + 5, offset + 7));\n                decoded.illuminance_alarm_config.continue_time = readUInt16LE(bytes.slice(offset + 7, offset + 9));\n            }\n            offset += 9;\n            break;\n        case 0x10:\n            decoded.reboot = readYesNoStatus(1);\n            offset += 1;\n            break;\n        case 0x35:\n            decoded.d2d_key = readHexString(bytes.slice(offset, offset + 8));\n            offset += 8;\n            break;\n        case 0x40:\n            decoded.adr_enable = readEnableStatus(bytes[offset]);\n            offset += 1;\n            break;\n        case 0x65:\n            decoded.lora_port = readUInt8(bytes[offset]);\n            offset += 1;\n            break;\n        case 0x68:\n            decoded.history_enable = readEnableStatus(bytes[offset]);\n            offset += 1;\n            break;\n        case 0x69:\n            decoded.retransmit_enable = readEnableStatus(bytes[offset]);\n            offset += 1;\n            break;\n        case 0x6a:\n            var interval_type = readUInt8(bytes[offset]);\n            if (interval_type === 0) {\n                decoded.retransmit_interval = readUInt16LE(bytes.slice(offset + 1, offset + 3));\n            } else if (interval_type === 1) {\n                decoded.resend_interval = readUInt16LE(bytes.slice(offset + 1, offset + 3));\n            }\n            offset += 3;\n            break;\n        case 0x6d:\n            decoded.stop_transmit = readYesNoStatus(1);\n            offset += 1;\n            break;\n        case 0x84:\n            decoded.d2d_enable = readEnableStatus(bytes[offset]);\n            offset += 1;\n            break;\n        case 0x8e:\n            // skip first byte\n            decoded.report_interval = readUInt16LE(bytes.slice(offset + 1, offset + 3));\n            offset += 3;\n            break;\n        case 0x96:\n            var d2d_master_config = {};\n            d2d_master_config.mode = readUInt8(bytes[offset]);\n            d2d_master_config.enable = readEnableStatus(bytes[offset + 1]);\n            d2d_master_config.lora_uplink_enable = readEnableStatus(bytes[offset + 2]);\n            d2d_master_config.d2d_cmd = readD2DCommand(bytes.slice(offset + 3, offset + 5));\n            d2d_master_config.time = readUInt16LE(bytes.slice(offset + 5, offset + 7));\n            d2d_master_config.time_enable = readEnableStatus(bytes[offset + 7]);\n            offset += 8;\n            decoded.d2d_master_config = decoded.d2d_master_config || [];\n            decoded.d2d_master_config.push(d2d_master_config);\n            break;\n        default:\n            throw new Error(\"unknown downlink response\");\n    }\n\n    return { data: decoded, offset: offset };\n}\n\nfunction handle_downlink_response_ext(code, channel_type, bytes, offset) {\n    var decoded = {};\n\n    switch (channel_type) {\n        case 0x10:\n            decoded.report_type = readReportType(bytes[offset]);\n            offset += 1;\n            break;\n        case 0x6b:\n            decoded.detection_mode = readDetectionMode(bytes[offset]);\n            offset += 1;\n            break;\n        case 0x6c:\n            decoded.detect = readYesNoStatus(1);\n            offset += 1;\n            break;\n        case 0x6e:\n            decoded.reset = readYesNoStatus(1);\n            offset += 1;\n            break;\n        default:\n            throw new Error(\"unknown downlink response\");\n    }\n\n    if (hasResultFlag(code)) {\n        var result_value = readUInt8(bytes[offset]);\n        offset += 1;\n\n        if (result_value !== 0) {\n            var request = decoded;\n            decoded = {};\n            decoded.device_response_result = {};\n            decoded.device_response_result.channel_type = channel_type;\n            decoded.device_response_result.result = readResultStatus(result_value);\n            decoded.device_response_result.request = request;\n        }\n    }\n\n    return { data: decoded, offset: offset };\n}\n\nfunction hasResultFlag(code) {\n    return code === 0xf8;\n}\n\nfunction readResultStatus(status) {\n    var status_map = { 0: \"success\", 1: \"forbidden\", 2: \"invalid parameter\" };\n    return getValue(status_map, status);\n}\n\nfunction readProtocolVersion(bytes) {\n    var major = (bytes & 0xf0) >> 4;\n    var minor = bytes & 0x0f;\n    return \"v\" + major + \".\" + minor;\n}\n\nfunction readHardwareVersion(bytes) {\n    var major = (bytes[0] & 0xff).toString(16);\n    var minor = (bytes[1] & 0xff) >> 4;\n    return \"v\" + major + \".\" + minor;\n}\n\nfunction readFirmwareVersion(bytes) {\n    var major = (bytes[0] & 0xff).toString(16);\n    var minor = (bytes[1] & 0xff).toString(16);\n    return \"v\" + major + \".\" + minor;\n}\n\nfunction readTslVersion(bytes) {\n    var major = bytes[0] & 0xff;\n    var minor = bytes[1] & 0xff;\n    return \"v\" + major + \".\" + minor;\n}\n\nfunction readSerialNumber(bytes) {\n    var temp = [];\n    for (var idx = 0; idx < bytes.length; idx++) {\n        temp.push((\"0\" + (bytes[idx] & 0xff).toString(16)).slice(-2));\n    }\n    return temp.join(\"\");\n}\n\nfunction readLoRaWANClass(type) {\n    var class_map = {\n        0: \"Class A\",\n        1: \"Class B\",\n        2: \"Class C\",\n        3: \"Class CtoB\",\n    };\n    return getValue(class_map, type);\n}\n\nfunction readResetEvent(status) {\n    var status_map = { 0: \"normal\", 1: \"reset\" };\n    return getValue(status_map, status);\n}\n\nfunction readDeviceStatus(status) {\n    var status_map = { 0: \"off\", 1: \"on\" };\n    return getValue(status_map, status);\n}\n\nfunction readSensorStatus(status) {\n    var status_map = { 0: \"normal\", 1: \"over_range\", 2: \"read_failed\" };\n    return getValue(status_map, status);\n}\n\nfunction readOccupancyStatus(status) {\n    var status_map = { 0: \"vacant\", 1: \"occupied\" };\n    return getValue(status_map, status);\n}\n\nfunction readIlluminanceStatus(status) {\n    var status_map = { 0: \"dim\", 1: \"bright\" };\n    return getValue(status_map, status);\n}\n\nfunction readDetectionStatus(status) {\n    var status_map = { 0: \"normal\", 1: \"unavailable\" };\n    return getValue(status_map, status);\n}\n\nfunction readTemperatureAlarm(type) {\n    var alarm_map = { 0: \"threshold_alarm_release\", 1: \"threshold_alarm\" };\n    return getValue(alarm_map, type);\n}\n\nfunction readHumidityAlarm(type) {\n    var alarm_map = { 0: \"threshold_alarm_release\", 1: \"threshold_alarm\" };\n    return getValue(alarm_map, type);\n}\n\nfunction readEnableStatus(status) {\n    var status_map = { 0: \"disable\", 1: \"enable\" };\n    return getValue(status_map, status);\n}\n\nfunction readYesNoStatus(status) {\n    var status_map = { 0: \"no\", 1: \"yes\" };\n    return getValue(status_map, status);\n}\n\nfunction readReportType(type) {\n    var type_map = { 0: \"period\", 1: \"immediately\" };\n    return getValue(type_map, type);\n}\n\nfunction readDetectionMode(type) {\n    var type_map = { 0: \"auto\", 1: \"on\" };\n    return getValue(type_map, type);\n}\n\nfunction readConditionType(type) {\n    var condition_map = { 0: \"disable\", 1: \"below\", 2: \"above\", 3: \"between\", 4: \"outside\" };\n    return getValue(condition_map, type);\n}\n\n/* eslint-disable */\nfunction readUInt8(bytes) {\n    return bytes & 0xff;\n}\n\nfunction readInt8(bytes) {\n    var ref = readUInt8(bytes);\n    return ref > 0x7f ? ref - 0x100 : ref;\n}\n\nfunction readUInt16LE(bytes) {\n    var value = (bytes[1] << 8) + bytes[0];\n    return value & 0xffff;\n}\n\nfunction readInt16LE(bytes) {\n    var ref = readUInt16LE(bytes);\n    return ref > 0x7fff ? ref - 0x10000 : ref;\n}\n\nfunction readUInt32LE(bytes) {\n    var value = (bytes[3] << 24) + (bytes[2] << 16) + (bytes[1] << 8) + bytes[0];\n    return (value & 0xffffffff) >>> 0;\n}\n\nfunction readInt32LE(bytes) {\n    var ref = readUInt32LE(bytes);\n    return ref > 0x7fffffff ? ref - 0x100000000 : ref;\n}\n\nfunction readHexString(bytes) {\n    var temp = [];\n    for (var i = 0; i < bytes.length; i++) {\n        temp.push((\"0\" + (bytes[i] & 0xff).toString(16)).slice(-2));\n    }\n    return temp.join(\"\");\n}\n\nfunction readD2DCommand(bytes) {\n    return (\"0\" + (bytes[1] & 0xff).toString(16)).slice(-2) + (\"0\" + (bytes[0] & 0xff).toString(16)).slice(-2);\n}\n\nfunction getValue(map, key) {\n    if (RAW_VALUE) return key;\n\n    var value = map[key];\n    if (!value) value = \"unknown\";\n    return value;\n}\n\nif (!Object.assign) {\n    Object.defineProperty(Object, \"assign\", {\n        enumerable: false,\n        configurable: true,\n        writable: true,\n        value: function (target) {\n            \"use strict\";\n            if (target == null) {\n                throw new TypeError(\"Cannot convert first argument to object\");\n            }\n\n            var to = Object(target);\n            for (var i = 1; i < arguments.length; i++) {\n                var nextSource = arguments[i];\n                if (nextSource == null) {\n                    continue;\n                }\n                nextSource = Object(nextSource);\n\n                var keysArray = Object.keys(Object(nextSource));\n                for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {\n                    var nextKey = keysArray[nextIndex];\n                    var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);\n                    if (desc !== undefined && desc.enumerable) {\n                        // concat array\n                        if (Array.isArray(to[nextKey]) && Array.isArray(nextSource[nextKey])) {\n                            to[nextKey] = to[nextKey].concat(nextSource[nextKey]);\n                        } else {\n                            to[nextKey] = nextSource[nextKey];\n                        }\n                    }\n                }\n            }\n            return to;\n        },\n    });\n}",
                        "environment": "javascript",
                        "storage": "",
                        "version": "1.0"
                    },
                    "flows": {
                        "milesight_vs321_decoder": {
                            "data": {
                                "payload": "{{payload}}",
                                "payload_function": "decodeThingerUplink",
                                "payload_type": "source_payload",
                                "resource": "uplink",
                                "source": "resource",
                                "update": "events"
                            },
                            "enabled": true,
                            "sink": {
                                "payload": "{{payload}}",
                                "payload_type": "source_payload",
                                "resource_stream": "uplink_decoded",
                                "target": "resource_stream"
                            },
                            "split_data": false
                        }
                    },
                    "properties": {
                        "uplink": {
                            "data": {
                                "payload": "{{payload}}",
                                "payload_type": "source_payload",
                                "resource": "uplink",
                                "source": "resource",
                                "update": "events"
                            },
                            "default": {
                                "source": "value"
                            },
                            "enabled": true
                        }
                    }
                },
                "_resources": {
                    "properties": [
                        {
                            "property": "dashboard",
                            "value": {
                                "tabs": [
                                    {
                                        "name": "Overview",
                                        "widgets": [
                                            {
                                                "layout": {
                                                    "col": 0,
                                                    "row": 0,
                                                    "sizeX": 2,
                                                    "sizeY": 5
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "People Count"
                                                },
                                                "properties": {
                                                    "decimalPlaces": 0,
                                                    "icon": "fas fa-users",
                                                    "iconColor": "#3498db",
                                                    "iconPosition": "above-value",
                                                    "iconSize": "50px",
                                                    "textAlign": "center",
                                                    "textColor": "#1E313E",
                                                    "textSize": "75px",
                                                    "textWeight": "font-light",
                                                    "unit": "people",
                                                    "unitSize": "20px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "people_total_counts",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#3498db",
                                                        "name": "People Count",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "text"
                                            },
                                            {
                                                "layout": {
                                                    "col": 2,
                                                    "row": 0,
                                                    "sizeX": 2,
                                                    "sizeY": 5
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Temperature"
                                                },
                                                "properties": {
                                                    "decimalPlaces": 1,
                                                    "icon": "fas fa-thermometer-half",
                                                    "iconColor": "#e74c3c",
                                                    "iconPosition": "above-value",
                                                    "iconSize": "50px",
                                                    "textAlign": "center",
                                                    "textColor": "#1E313E",
                                                    "textSize": "75px",
                                                    "textWeight": "font-light",
                                                    "unit": "°C",
                                                    "unitSize": "20px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "temperature",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#e74c3c",
                                                        "name": "Temperature",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "text"
                                            },
                                            {
                                                "layout": {
                                                    "col": 4,
                                                    "row": 0,
                                                    "sizeX": 2,
                                                    "sizeY": 5
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Humidity"
                                                },
                                                "properties": {
                                                    "decimalPlaces": 1,
                                                    "icon": "fas fa-tint",
                                                    "iconColor": "#3498db",
                                                    "iconPosition": "above-value",
                                                    "iconSize": "50px",
                                                    "textAlign": "center",
                                                    "textColor": "#1E313E",
                                                    "textSize": "75px",
                                                    "textWeight": "font-light",
                                                    "unit": "%",
                                                    "unitSize": "20px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "humidity",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#3498db",
                                                        "name": "Humidity",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "text"
                                            },
                                            {
                                                "layout": {
                                                    "col": 0,
                                                    "row": 5,
                                                    "sizeX": 6,
                                                    "sizeY": 10
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "People Count (24h)"
                                                },
                                                "properties": {
                                                    "alignTimeSeries": false,
                                                    "dataAppend": false,
                                                    "options": "var options = {\n    chart: {\n        type: 'area',\n        stacked: false\n    },\n    dataLabels: {\n        enabled: false\n    },\n    stroke: {\n        curve: 'smooth',\n        width: 2\n    },\n    xaxis: {\n        type: 'datetime',\n        labels: {\n            datetimeUTC: false\n        },\n        tooltip: {\n            enabled: false\n        }\n    },\n    yaxis: {\n        labels: {\n            formatter: function (val) {\n                if (val !== null && typeof val !== 'undefined')\n                    return Math.round(val);\n            }\n        },\n        min: 0\n    },\n    tooltip: {\n        x: {\n            format: 'dd/MM/yyyy HH:mm:ss'\n        }\n    },\n    fill: {\n        type: 'gradient',\n        gradient: {\n            shadeIntensity: 1,\n            opacityFrom: 0.7,\n            opacityTo: 0.3\n        }\n    }\n};\n",
                                                    "realTimeUpdate": true
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "people_total_counts",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#3498db",
                                                        "name": "People Count",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "magnitude": "hour",
                                                            "mode": "relative",
                                                            "period": "latest",
                                                            "value": 24
                                                        }
                                                    }
                                                ],
                                                "type": "apex_charts"
                                            },
                                            {
                                                "layout": {
                                                    "col": 0,
                                                    "row": 15,
                                                    "sizeX": 6,
                                                    "sizeY": 10
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Temperature & Humidity (24h)"
                                                },
                                                "properties": {
                                                    "alignTimeSeries": false,
                                                    "dataAppend": false,
                                                    "options": "var options = {\n    chart: {\n        type: 'line',\n        stacked: false\n    },\n    dataLabels: {\n        enabled: false\n    },\n    stroke: {\n        curve: 'smooth',\n        width: 2\n    },\n    xaxis: {\n        type: 'datetime',\n        labels: {\n            datetimeUTC: false\n        },\n        tooltip: {\n            enabled: false\n        }\n    },\n    yaxis: [\n        {\n            title: {\n                text: 'Temperature (°C)'\n            },\n            labels: {\n                formatter: function (val) {\n                    if (val !== null && typeof val !== 'undefined')\n                        return val.toFixed(1);\n                }\n            }\n        },\n        {\n            opposite: true,\n            title: {\n                text: 'Humidity (%)'\n            },\n            labels: {\n                formatter: function (val) {\n                    if (val !== null && typeof val !== 'undefined')\n                        return val.toFixed(1);\n                }\n            }\n        }\n    ],\n    tooltip: {\n        x: {\n            format: 'dd/MM/yyyy HH:mm:ss'\n        }\n    }\n};\n",
                                                    "realTimeUpdate": true
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "temperature",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#e74c3c",
                                                        "name": "Temperature",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "magnitude": "hour",
                                                            "mode": "relative",
                                                            "period": "latest",
                                                            "value": 24
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "humidity",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#3498db",
                                                        "name": "Humidity",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "magnitude": "hour",
                                                            "mode": "relative",
                                                            "period": "latest",
                                                            "value": 24
                                                        }
                                                    }
                                                ],
                                                "type": "apex_charts"
                                            },
                                            {
                                                "layout": {
                                                    "col": 0,
                                                    "row": 25,
                                                    "sizeX": 2,
                                                    "sizeY": 5
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Battery"
                                                },
                                                "properties": {
                                                    "color": "#2ebd59",
                                                    "gradient": false,
                                                    "max": 100,
                                                    "min": 0,
                                                    "unit": "%"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "battery",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#2ebd59",
                                                        "name": "Battery",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "gauge"
                                            },
                                            {
                                                "layout": {
                                                    "col": 2,
                                                    "row": 25,
                                                    "sizeX": 2,
                                                    "sizeY": 5
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Illuminance Status"
                                                },
                                                "properties": {
                                                    "icon": "fas fa-lightbulb",
                                                    "iconColor": "#f39c12",
                                                    "iconPosition": "above-value",
                                                    "iconSize": "50px",
                                                    "textAlign": "center",
                                                    "textColor": "#1E313E",
                                                    "textSize": "40px",
                                                    "textWeight": "font-light"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "illuminance_status",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#f39c12",
                                                        "name": "Illuminance",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "text"
                                            },
                                            {
                                                "layout": {
                                                    "col": 4,
                                                    "row": 25,
                                                    "sizeX": 2,
                                                    "sizeY": 5
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Detection Status"
                                                },
                                                "properties": {
                                                    "icon": "fas fa-signal",
                                                    "iconColor": "#27ae60",
                                                    "iconPosition": "above-value",
                                                    "iconSize": "50px",
                                                    "textAlign": "center",
                                                    "textColor": "#1E313E",
                                                    "textSize": "40px",
                                                    "textWeight": "font-light"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "detection_status",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#27ae60",
                                                        "name": "Detection",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "text"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "Region Occupancy",
                                        "widgets": [
                                            {
                                                "layout": {
                                                    "col": 0,
                                                    "row": 0,
                                                    "sizeX": 1,
                                                    "sizeY": 3
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Region 1"
                                                },
                                                "properties": {
                                                    "color": "#2ecc71",
                                                    "colors": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "max": "vacant",
                                                            "min": "vacant"
                                                        },
                                                        {
                                                            "blink": true,
                                                            "color": "#2ecc71",
                                                            "max": "occupied",
                                                            "min": "occupied"
                                                        }
                                                    ],
                                                    "size": "50px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_1",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#2ecc71",
                                                        "name": "Region 1",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "led"
                                            },
                                            {
                                                "layout": {
                                                    "col": 1,
                                                    "row": 0,
                                                    "sizeX": 1,
                                                    "sizeY": 3
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Region 2"
                                                },
                                                "properties": {
                                                    "color": "#2ecc71",
                                                    "colors": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "max": "vacant",
                                                            "min": "vacant"
                                                        },
                                                        {
                                                            "blink": true,
                                                            "color": "#2ecc71",
                                                            "max": "occupied",
                                                            "min": "occupied"
                                                        }
                                                    ],
                                                    "size": "50px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_2",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#2ecc71",
                                                        "name": "Region 2",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "led"
                                            },
                                            {
                                                "layout": {
                                                    "col": 2,
                                                    "row": 0,
                                                    "sizeX": 1,
                                                    "sizeY": 3
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Region 3"
                                                },
                                                "properties": {
                                                    "color": "#2ecc71",
                                                    "colors": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "max": "vacant",
                                                            "min": "vacant"
                                                        },
                                                        {
                                                            "blink": true,
                                                            "color": "#2ecc71",
                                                            "max": "occupied",
                                                            "min": "occupied"
                                                        }
                                                    ],
                                                    "size": "50px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_3",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#2ecc71",
                                                        "name": "Region 3",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "led"
                                            },
                                            {
                                                "layout": {
                                                    "col": 3,
                                                    "row": 0,
                                                    "sizeX": 1,
                                                    "sizeY": 3
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Region 4"
                                                },
                                                "properties": {
                                                    "color": "#2ecc71",
                                                    "colors": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "max": "vacant",
                                                            "min": "vacant"
                                                        },
                                                        {
                                                            "blink": true,
                                                            "color": "#2ecc71",
                                                            "max": "occupied",
                                                            "min": "occupied"
                                                        }
                                                    ],
                                                    "size": "50px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_4",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#2ecc71",
                                                        "name": "Region 4",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "led"
                                            },
                                            {
                                                "layout": {
                                                    "col": 4,
                                                    "row": 0,
                                                    "sizeX": 1,
                                                    "sizeY": 3
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Region 5"
                                                },
                                                "properties": {
                                                    "color": "#2ecc71",
                                                    "colors": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "max": "vacant",
                                                            "min": "vacant"
                                                        },
                                                        {
                                                            "blink": true,
                                                            "color": "#2ecc71",
                                                            "max": "occupied",
                                                            "min": "occupied"
                                                        }
                                                    ],
                                                    "size": "50px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_5",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#2ecc71",
                                                        "name": "Region 5",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "led"
                                            },
                                            {
                                                "layout": {
                                                    "col": 0,
                                                    "row": 3,
                                                    "sizeX": 1,
                                                    "sizeY": 3
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Region 6"
                                                },
                                                "properties": {
                                                    "color": "#2ecc71",
                                                    "colors": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "max": "vacant",
                                                            "min": "vacant"
                                                        },
                                                        {
                                                            "blink": true,
                                                            "color": "#2ecc71",
                                                            "max": "occupied",
                                                            "min": "occupied"
                                                        }
                                                    ],
                                                    "size": "50px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_6",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#2ecc71",
                                                        "name": "Region 6",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "led"
                                            },
                                            {
                                                "layout": {
                                                    "col": 1,
                                                    "row": 3,
                                                    "sizeX": 1,
                                                    "sizeY": 3
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Region 7"
                                                },
                                                "properties": {
                                                    "color": "#2ecc71",
                                                    "colors": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "max": "vacant",
                                                            "min": "vacant"
                                                        },
                                                        {
                                                            "blink": true,
                                                            "color": "#2ecc71",
                                                            "max": "occupied",
                                                            "min": "occupied"
                                                        }
                                                    ],
                                                    "size": "50px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_7",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#2ecc71",
                                                        "name": "Region 7",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "led"
                                            },
                                            {
                                                "layout": {
                                                    "col": 2,
                                                    "row": 3,
                                                    "sizeX": 1,
                                                    "sizeY": 3
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Region 8"
                                                },
                                                "properties": {
                                                    "color": "#2ecc71",
                                                    "colors": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "max": "vacant",
                                                            "min": "vacant"
                                                        },
                                                        {
                                                            "blink": true,
                                                            "color": "#2ecc71",
                                                            "max": "occupied",
                                                            "min": "occupied"
                                                        }
                                                    ],
                                                    "size": "50px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_8",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#2ecc71",
                                                        "name": "Region 8",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "led"
                                            },
                                            {
                                                "layout": {
                                                    "col": 3,
                                                    "row": 3,
                                                    "sizeX": 1,
                                                    "sizeY": 3
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Region 9"
                                                },
                                                "properties": {
                                                    "color": "#2ecc71",
                                                    "colors": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "max": "vacant",
                                                            "min": "vacant"
                                                        },
                                                        {
                                                            "blink": true,
                                                            "color": "#2ecc71",
                                                            "max": "occupied",
                                                            "min": "occupied"
                                                        }
                                                    ],
                                                    "size": "50px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_9",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#2ecc71",
                                                        "name": "Region 9",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "led"
                                            },
                                            {
                                                "layout": {
                                                    "col": 4,
                                                    "row": 3,
                                                    "sizeX": 1,
                                                    "sizeY": 3
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Region 10"
                                                },
                                                "properties": {
                                                    "color": "#2ecc71",
                                                    "colors": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "max": "vacant",
                                                            "min": "vacant"
                                                        },
                                                        {
                                                            "blink": true,
                                                            "color": "#2ecc71",
                                                            "max": "occupied",
                                                            "min": "occupied"
                                                        }
                                                    ],
                                                    "size": "50px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_10",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#2ecc71",
                                                        "name": "Region 10",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "led"
                                            },
                                            {
                                                "layout": {
                                                    "col": 0,
                                                    "row": 6,
                                                    "sizeX": 5,
                                                    "sizeY": 8
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Region Status Summary"
                                                },
                                                "properties": {
                                                    "source": "code",
                                                    "template": "<div style=\"width:100%; height:100%; overflow-y:auto; padding:10px;\">\n  <table class=\"table table-striped table-condensed\">\n    <thead>\n      <tr>\n        <th>Region</th>\n        <th>Status</th>\n        <th>Enabled</th>\n      </tr>\n    </thead>\n    <tbody>\n      <tr>\n        <td>Region 1</td>\n        <td><span ng-class=\"{'label label-success': region_1 === 'occupied', 'label label-default': region_1 === 'vacant'}\">{{ region_1 || '—' }}</span></td>\n        <td>{{ region_1_enable || '—' }}</td>\n      </tr>\n      <tr>\n        <td>Region 2</td>\n        <td><span ng-class=\"{'label label-success': region_2 === 'occupied', 'label label-default': region_2 === 'vacant'}\">{{ region_2 || '—' }}</span></td>\n        <td>{{ region_2_enable || '—' }}</td>\n      </tr>\n      <tr>\n        <td>Region 3</td>\n        <td><span ng-class=\"{'label label-success': region_3 === 'occupied', 'label label-default': region_3 === 'vacant'}\">{{ region_3 || '—' }}</span></td>\n        <td>{{ region_3_enable || '—' }}</td>\n      </tr>\n      <tr>\n        <td>Region 4</td>\n        <td><span ng-class=\"{'label label-success': region_4 === 'occupied', 'label label-default': region_4 === 'vacant'}\">{{ region_4 || '—' }}</span></td>\n        <td>{{ region_4_enable || '—' }}</td>\n      </tr>\n      <tr>\n        <td>Region 5</td>\n        <td><span ng-class=\"{'label label-success': region_5 === 'occupied', 'label label-default': region_5 === 'vacant'}\">{{ region_5 || '—' }}</span></td>\n        <td>{{ region_5_enable || '—' }}</td>\n      </tr>\n      <tr>\n        <td>Region 6</td>\n        <td><span ng-class=\"{'label label-success': region_6 === 'occupied', 'label label-default': region_6 === 'vacant'}\">{{ region_6 || '—' }}</span></td>\n        <td>{{ region_6_enable || '—' }}</td>\n      </tr>\n      <tr>\n        <td>Region 7</td>\n        <td><span ng-class=\"{'label label-success': region_7 === 'occupied', 'label label-default': region_7 === 'vacant'}\">{{ region_7 || '—' }}</span></td>\n        <td>{{ region_7_enable || '—' }}</td>\n      </tr>\n      <tr>\n        <td>Region 8</td>\n        <td><span ng-class=\"{'label label-success': region_8 === 'occupied', 'label label-default': region_8 === 'vacant'}\">{{ region_8 || '—' }}</span></td>\n        <td>{{ region_8_enable || '—' }}</td>\n      </tr>\n      <tr>\n        <td>Region 9</td>\n        <td><span ng-class=\"{'label label-success': region_9 === 'occupied', 'label label-default': region_9 === 'vacant'}\">{{ region_9 || '—' }}</span></td>\n        <td>{{ region_9_enable || '—' }}</td>\n      </tr>\n      <tr>\n        <td>Region 10</td>\n        <td><span ng-class=\"{'label label-success': region_10 === 'occupied', 'label label-default': region_10 === 'vacant'}\">{{ region_10 || '—' }}</span></td>\n        <td>{{ region_10_enable || '—' }}</td>\n      </tr>\n    </tbody>\n  </table>\n</div>"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_1",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#1abc9c",
                                                        "name": "region_1",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_1_enable",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#2ecc71",
                                                        "name": "region_1_enable",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_2",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#3498db",
                                                        "name": "region_2",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_2_enable",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#9b59b6",
                                                        "name": "region_2_enable",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_3",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#e67e22",
                                                        "name": "region_3",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_3_enable",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#e74c3c",
                                                        "name": "region_3_enable",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_4",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#95a5a6",
                                                        "name": "region_4",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_4_enable",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#34495e",
                                                        "name": "region_4_enable",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_5",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#16a085",
                                                        "name": "region_5",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_5_enable",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#27ae60",
                                                        "name": "region_5_enable",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_6",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#2980b9",
                                                        "name": "region_6",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_6_enable",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#8e44ad",
                                                        "name": "region_6_enable",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_7",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#d35400",
                                                        "name": "region_7",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_7_enable",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#c0392b",
                                                        "name": "region_7_enable",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_8",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#7f8c8d",
                                                        "name": "region_8",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_8_enable",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#2c3e50",
                                                        "name": "region_8_enable",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_9",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#1abc9c",
                                                        "name": "region_9",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_9_enable",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#2ecc71",
                                                        "name": "region_9_enable",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_10",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#3498db",
                                                        "name": "region_10",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_vs321_data",
                                                            "mapping": "region_10_enable",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#9b59b6",
                                                        "name": "region_10_enable",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "html_time"
                                            }
                                        ]
                                    }
                                ]
                            }
                        }
                    ]
                }
            }
        ]
    }
}