Skip to content

Plugin file

Plugin configuration file
{
    "name": "milesight-iot-wt201v1",
    "version": "1.0.0",
    "description": "Milesight WT201 smart thermostat uses LoRaWAN® technology for remote HVAC control, delivering energy efficiency and eco-friendly heating/cooling management. Offers convenient operation aligned with green energy strategies for sustainable living spaces.",
    "author": "Thinger.io",
    "license": "MIT",
    "repository": {
        "type": "git",
        "url": "https://github.com/thinger-io/plugins.git",
        "directory": "milesight-iot-wt201v1"
    },
    "metadata": {
        "name": "Milesight-Iot WT201V1",
        "description": "Milesight WT201 smart thermostat uses LoRaWAN® technology for remote HVAC control, delivering energy efficiency and eco-friendly heating/cooling management. Offers convenient operation aligned with green energy strategies for sustainable living spaces.",
        "image": "assets/wt201v1.png",
        "category": "devices",
        "vendor": "milesight-iot"
    },
    "resources": {
        "products": [
            {
                "description": "Milesight WT201 smart thermostat uses LoRaWAN® technology for remote HVAC control, delivering energy efficiency and eco-friendly heating/cooling management. Offers convenient operation aligned with green energy strategies for sustainable living spaces.",
                "enabled": true,
                "name": "Milesight-Iot WT201V1",
                "product": "milesight_iot_wt201v1",
                "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_function": "",
                                    "payload_type": "",
                                    "plugin": "{{property.uplink.source}}",
                                    "target": "plugin_endpoint"
                                }
                            }
                        },
                        "uplink": {
                            "enabled": true,
                            "handle_connectivity": true,
                            "request": {
                                "data": {
                                    "payload": "{{payload}}",
                                    "payload_function": "",
                                    "payload_type": "source_payload",
                                    "resource_stream": "uplink",
                                    "target": "resource_stream"
                                }
                            }
                        }
                    },
                    "autoprovisions": {
                        "device_autoprovisioning": {
                            "config": {
                                "mode": "pattern",
                                "pattern": "wt201_.*"
                            },
                            "enabled": true
                        }
                    },
                    "buckets": {
                        "milesight_wt201_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\n/**\n * Payload Decoder\n *\n * Copyright 2025 Milesight IoT\n *\n * @product WT201\n */\nvar RAW_VALUE = 0x00;\n\n/* eslint-disable */\n// Chirpstack v4\nfunction decodeUplink(input) {\n    var decoded = milesightDeviceDecode(input.bytes);\n    return { data: decoded };\n}\n\n// Chirpstack v3\nfunction Decode(fPort, bytes) {\n    return milesightDeviceDecode(bytes);\n}\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\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        // TEMPERATURE\n        else if (channel_id === 0x03 && channel_type === 0x67) {\n            decoded.temperature = readInt16LE(bytes.slice(i, i + 2)) / 10;\n            i += 2;\n        }\n        // TARGET TEMPERATURE\n        else if (channel_id === 0x04 && channel_type === 0x67) {\n            decoded.target_temperature = readInt16LE(bytes.slice(i, i + 2)) / 10;\n            i += 2;\n        }\n        // TEMPERATURE CONTROL\n        else if (channel_id === 0x05 && channel_type === 0xe7) {\n            var temperature_control_value = bytes[i];\n            decoded.temperature_control_mode = readTemperatureControlMode((temperature_control_value >>> 0) & 0x03);\n            decoded.temperature_control_status = readTemperatureControlStatus((temperature_control_value >>> 4) & 0x0f);\n            i += 1;\n        }\n        // FAN CONTROL\n        else if (channel_id === 0x06 && channel_type === 0xe8) {\n            var fan_value = bytes[i];\n            decoded.fan_mode = readFanMode((fan_value >>> 0) & 0x03);\n            decoded.fan_status = readFanStatus((fan_value >>> 2) & 0x03);\n            i += 1;\n        }\n        // PLAN EVENT\n        else if (channel_id === 0x07 && channel_type === 0xbc) {\n            var plan_event_value = bytes[i];\n            decoded.plan_type = readPlanEvent((plan_event_value >>> 0) & 0x0f);\n            i += 1;\n        }\n        // SYSTEM STATUS\n        else if (channel_id === 0x08 && channel_type === 0x8e) {\n            decoded.system_status = readOnOffStatus(bytes[i]);\n            i += 1;\n        }\n        // HUMIDITY\n        else if (channel_id === 0x09 && channel_type === 0x68) {\n            decoded.humidity = readUInt8(bytes[i]) / 2;\n            i += 1;\n        }\n        // RELAY STATUS\n        else if (channel_id === 0x0a && channel_type === 0x6e) {\n            decoded.wires_relay = readWiresRelay(bytes[i]);\n            i += 1;\n        }\n        // TEMPERATURE MODE SUPPORT\n        else if (channel_id === 0xff && channel_type === 0xcb) {\n            decoded.temperature_control_support_mode = readTemperatureControlSupportMode(bytes[i]);\n            decoded.temperature_control_support_status = readTemperatureControlSupportStatus(bytes[i + 1], bytes[i + 2]);\n            i += 3;\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 += 2;\n        }\n        // TEMPERATURE EXCEPTION\n        else if (channel_id === 0xb3 && channel_type === 0x67) {\n            decoded.temperature_sensor_status = readSensorStatus(bytes[i]);\n            i += 1;\n        }\n        // HUMIDITY EXCEPTION\n        else if (channel_id === 0xb9 && channel_type === 0x68) {\n            decoded.humidity_sensor_status = readSensorStatus(bytes[i]);\n            i += 1;\n        }\n        // HISTORICAL DATA\n        else if (channel_id === 0x20 && channel_type === 0xce) {\n            var timestamp = readUInt32LE(bytes.slice(i, i + 4));\n            var value1 = readUInt16LE(bytes.slice(i + 4, i + 6));\n            var value2 = readUInt16LE(bytes.slice(i + 6, i + 8));\n\n            var data = { timestamp: timestamp };\n            // fan_mode(0..1) + fan_status(2..3) + system_status(4) + temperature(5..15)\n            data.fan_mode = readFanMode((value1 >>> 0) & 0x03);\n            data.fan_status = readFanStatus((value1 >>> 2) & 0x03);\n            data.system_status = readOnOffStatus((value1 >>> 4) & 0x01);\n            var temperature = ((value1 >>> 5) & 0x7ff) / 10 - 100;\n            data.temperature = Number(temperature.toFixed(1));\n\n            // temperature_control_mode(0..1) + temperature_control_status(2..4) + target_temperature(5..15)\n            data.temperature_control_mode = readTemperatureControlMode((value2 >>> 0) & 0x03);\n            data.temperature_control_status = readTemperatureControlStatus((value2 >>> 2) & 0x07);\n            var target_temperature = ((value2 >>> 5) & 0x7ff) / 10 - 100;\n            data.target_temperature = Number(target_temperature.toFixed(1));\n            i += 8;\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 respResult = handle_downlink_response(channel_type, bytes, i);\n            decoded = Object.assign(decoded, respResult.data);\n            i = respResult.offset;\n        }\n        // DOWNLINK RESPONSE EXT\n        else if (channel_id === 0xf8 || channel_id === 0xf9) {\n            var respResultExt = handle_downlink_response_ext(channel_id, channel_type, bytes, i);\n            decoded = Object.assign(decoded, respResultExt.data);\n            i = respResultExt.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 0x03:\n            decoded.outside_temperature = readInt16LE(bytes.slice(offset, offset + 2)) / 10;\n            offset += 2;\n            break;\n        case 0x06:\n            var ctl = readUInt8(bytes[offset]);\n            var condition = ctl & 0x07;\n            var alarm_type = (ctl >>> 3) & 0x07;\n\n            var condition_map = { 0: \"disable\", 1: \"below\", 2: \"above\", 3: \"between\", 4: \"outside\" };\n            var alarm_type_map = { 0: \"temperature threshold\", 1: \"continuous low temperature\", 2: \"continuous high temperature\" };\n            var data = { condition: getValue(condition_map, condition), alarm_type: getValue(alarm_type_map, alarm_type) };\n\n            if (condition === 1 || condition === 3 || condition === 4 || alarm_type === 1) {\n                data.threshold_min = readInt16LE(bytes.slice(offset + 1, offset + 3)) / 10;\n            }\n            if (condition === 2 || condition === 3 || condition === 4 || alarm_type === 2) {\n                data.threshold_max = readInt16LE(bytes.slice(offset + 3, offset + 5)) / 10;\n            }\n            data.lock_time = readInt16LE(bytes.slice(offset + 5, offset + 7));\n            data.continue_time = readInt16LE(bytes.slice(offset + 7, offset + 9));\n            offset += 9;\n\n            decoded.temperature_alarm_config = data;\n            break;\n        case 0x10:\n            decoded.reboot = readYesNoStatus(1);\n            offset += 1;\n            break;\n        case 0x25:\n            var masked = readUInt8(bytes[offset]);\n            var status = readUInt8(bytes[offset + 1]);\n            var button_mask_bit_offset = { power_button: 0, up_button: 1, down_button: 2, fan_button: 3, mode_button: 4, reset_button: 5 };\n            decoded.child_lock_config = decoded.child_lock_config || {};\n            for (var button in button_mask_bit_offset) {\n                if ((masked >> button_mask_bit_offset[button]) & 0x01) {\n                    decoded.child_lock_config[button] = readEnableStatus((status >> button_mask_bit_offset[button]) & 0x01);\n                }\n            }\n            offset += 2;\n            break;\n        case 0x27:\n            decoded.clear_history = readYesNoStatus(1);\n            offset += 1;\n            break;\n        case 0x28:\n            decoded.report_status = readReportStatus(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            switch (interval_type) {\n                case 0:\n                    decoded.retransmit_interval = readUInt16LE(bytes.slice(offset + 1, offset + 3));\n                    break;\n                case 1:\n                    decoded.resend_interval = readUInt16LE(bytes.slice(offset + 1, offset + 3));\n                    break;\n            }\n            offset += 3;\n            break;\n        case 0x82:\n            var value = readUInt8(bytes[offset]);\n            var mask = value >>> 4;\n            var enabled = value & 0x0f;\n\n            var group_mask_bit_offset = { group1_enable: 0, group2_enable: 1, group3_enable: 2, group4_enable: 3 };\n            decoded.multicast_group_config = {};\n            for (var group in group_mask_bit_offset) {\n                if ((mask >> group_mask_bit_offset[group]) & 0x01) {\n                    decoded.multicast_group_config[group] = readEnableStatus((enabled >> group_mask_bit_offset[group]) & 0x01);\n                }\n            }\n            offset += 1;\n            break;\n        case 0x83:\n            var d2d_slave_config = {};\n            d2d_slave_config.id = readUInt8(bytes[offset]) + 1;\n            d2d_slave_config.enable = readEnableStatus(bytes[offset + 1]);\n            d2d_slave_config.d2d_cmd = readD2DCommand(bytes.slice(offset + 2, offset + 4));\n            var action_type_value = (readUInt8(bytes[offset + 4]) >>> 4) & 0x0f;\n            d2d_slave_config.action_type = readActionType(action_type_value);\n            if (action_type_value === 0) {\n                d2d_slave_config.action = readOnOffStatus(readUInt8(bytes[offset + 4]) & 0x0f);\n            } else {\n                d2d_slave_config.action = readPlanEventType(readUInt8(bytes[offset + 4]) & 0x0f);\n            }\n            offset += 5;\n            decoded.d2d_slave_config = decoded.d2d_slave_config || [];\n            decoded.d2d_slave_config.push(d2d_slave_config);\n            break;\n        case 0x96:\n            var d2d_master_config = {};\n            d2d_master_config.mode = readPlanEventType(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_enable = readEnableStatus(bytes[offset + 7]);\n            d2d_master_config.time = readUInt16LE(bytes.slice(offset + 5, 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        case 0x4a:\n            decoded.sync_time = readYesNoStatus(1);\n            offset += 1;\n            break;\n        case 0x8e:\n            // ignore the first byte\n            decoded.report_interval = readUInt16LE(bytes.slice(offset + 1, offset + 3));\n            offset += 3;\n            break;\n        case 0xab:\n            decoded.temperature_calibration_settings = {};\n            decoded.temperature_calibration_settings.enable = readEnableStatus(readUInt8(bytes[offset]));\n            decoded.temperature_calibration_settings.calibration_value = readInt16LE(bytes.slice(offset + 1, offset + 3)) / 10;\n            offset += 3;\n            break;\n        case 0xb0:\n            decoded.freeze_protection_config = decoded.freeze_protection_config || {};\n            decoded.freeze_protection_config.enable = readEnableStatus(readUInt8(bytes[offset]));\n            decoded.freeze_protection_config.temperature = readInt16LE(bytes.slice(offset + 1, offset + 3)) / 10;\n            offset += 3;\n            break;\n        case 0xb5:\n            decoded.ob_mode = readObMode(readUInt8(bytes[offset]));\n            offset += 1;\n            break;\n        case 0xb6:\n            decoded.fan_mode = readFanMode(readUInt8(bytes[offset]));\n            offset += 1;\n            break;\n        case 0xb7:\n            decoded.temperature_control_mode = readTemperatureControlMode(readUInt8(bytes[offset]));\n            var t = readUInt8(bytes[offset + 1]);\n            decoded.target_temperature = t & 0x7f;\n            decoded.temperature_unit = readTemperatureUnit((t >>> 7) & 0x01);\n            offset += 2;\n            break;\n        case 0xb8:\n            decoded.temperature_tolerance = {};\n            decoded.temperature_tolerance.target_temperature_tolerance = readUInt8(bytes[offset]) / 10;\n            decoded.temperature_tolerance.auto_temperature_tolerance = readUInt8(bytes[offset + 1]) / 10;\n            offset += 2;\n            break;\n        case 0xb9:\n            decoded.temperature_level_up_condition = {};\n            decoded.temperature_level_up_condition.type = readTemperatureLevelUpCondition(readUInt8(bytes[offset]));\n            decoded.temperature_level_up_condition.time = readUInt8(bytes[offset + 1]);\n            decoded.temperature_level_up_condition.temperature_tolerance = readInt16LE(bytes.slice(offset + 2, offset + 4)) / 10;\n            offset += 4;\n            break;\n        case 0xba:\n            var enable_value = bytes[offset];\n            decoded.dst_config = {};\n            decoded.dst_config.enable = readEnableStatus(enable_value);\n            decoded.dst_config.offset = readUInt8(bytes[offset + 1]);\n            decoded.dst_config.start_month = readUInt8(bytes[offset + 2]);\n            var start_day = readUInt8(bytes[offset + 3]);\n            decoded.dst_config.start_week_num = (start_day >>> 4) & 0x0f;\n            decoded.dst_config.start_week_day = start_day & 0x0f;\n            decoded.dst_config.start_time = readUInt16LE(bytes.slice(offset + 4, offset + 6));\n            decoded.dst_config.end_month = readUInt8(bytes[offset + 6]);\n            var end_day = readUInt8(bytes[offset + 7]);\n            decoded.dst_config.end_week_num = (end_day >>> 4) & 0x0f;\n            decoded.dst_config.end_week_day = end_day & 0x0f;\n            decoded.dst_config.end_time = readUInt16LE(bytes.slice(offset + 8, offset + 10));\n            offset += 10;\n            break;\n        case 0xbd:\n            decoded.time_zone = readTimeZone(readInt16LE(bytes.slice(offset, offset + 2)));\n            offset += 2;\n            break;\n        case 0xc1:\n            var action_map = { 0: \"power\", 1: \"plan\" };\n            var action_value = readUInt8(bytes[offset + 1]);\n            var card_action = readUInt8(bytes[offset + 2]);\n            decoded.card_config = {};\n            decoded.card_config.enable = readEnableStatus(bytes[offset]);\n            decoded.card_config.action_type = getValue(action_map, action_value);\n            if (action_value === 1) {\n                decoded.card_config.in_plan_type = readPlanEventType((card_action >>> 4) & 0x0f);\n                decoded.card_config.out_plan_type = readPlanEventType(card_action & 0x0f);\n            } else if (action_value === 0) {\n                decoded.card_config.action = readOnOffStatus(card_action);\n            }\n            decoded.card_config.invert = readYesNoStatus(bytes[offset + 3]);\n            offset += 4;\n            break;\n        case 0xc2:\n            decoded.plan_type = readPlanEventType(readUInt8(bytes[offset]));\n            offset += 1;\n            break;\n        case 0xc4:\n            decoded.outside_temperature_control = decoded.outside_temperature_control_config || {};\n            decoded.outside_temperature_control.enable = readEnableStatus(bytes[offset]);\n            decoded.outside_temperature_control.timeout = readUInt8(bytes[offset + 1]);\n            offset += 2;\n            break;\n        case 0xc5:\n            decoded.temperature_control_enable = readEnableStatus(bytes[offset]);\n            offset += 1;\n            break;\n        case 0xc7:\n            var d2d_enable_value = readUInt8(bytes[offset]);\n            offset += 1;\n            var d2d_mask = (d2d_enable_value >>> 4) & 0x0f;\n            var d2d_status = (d2d_enable_value >>> 0) & 0x0f;\n            if ((d2d_mask >> 0) & 0x01) {\n                decoded.d2d_master_enable = readEnableStatus((d2d_status >>> 0) & 0x01);\n            }\n            if ((d2d_mask >> 1) & 0x01) {\n                decoded.d2d_slave_enable = readEnableStatus((d2d_status >>> 1) & 0x01);\n            }\n            break;\n        case 0xc8:\n            var plan_config = {};\n            plan_config.type = readPlanEventType(readUInt8(bytes[offset]));\n            plan_config.temperature_control_mode = readTemperatureControlMode(readUInt8(bytes[offset + 1]));\n            plan_config.fan_mode = readFanMode(readUInt8(bytes[offset + 2]));\n            var target_temperature_value = readInt8(bytes[offset + 3]);\n            plan_config.target_temperature = target_temperature_value & 0x7f;\n            decoded.temperature_unit = readTemperatureUnit((target_temperature_value >>> 7) & 0x01);\n            plan_config.temperature_tolerance = readInt8(bytes[offset + 4] & 0x7f) / 10;\n            offset += 5;\n            decoded.plan_config = decoded.plan_config || [];\n            decoded.plan_config.push(plan_config);\n            break;\n        case 0xc9:\n            var plan_schedule = {};\n            plan_schedule.type = readPlanEventType(bytes[offset]);\n            plan_schedule.id = bytes[offset + 1] + 1;\n            plan_schedule.enable = readEnableStatus(bytes[offset + 2]);\n            plan_schedule.week_recycle = readWeekRecycleSettings(bytes[offset + 3]);\n            plan_schedule.time = readUInt16LE(bytes.slice(offset + 4, offset + 6));\n            offset += 6;\n            decoded.plan_schedule = decoded.plan_schedule || [];\n            decoded.plan_schedule.push(plan_schedule);\n            break;\n        case 0xca:\n            decoded.wires = readWires(bytes[offset], bytes[offset + 1], bytes[offset + 2]);\n            decoded.ob_mode = readObMode((bytes[offset + 2] >>> 2) & 0x03);\n            offset += 3;\n            break;\n        case 0xf6:\n            decoded.control_permission = readControlPermission(readUInt8(bytes[offset]));\n            offset += 1;\n            break;\n        case 0xf7:\n            var wires_relay_mask = readUInt16LE(bytes.slice(offset, offset + 2));\n            var wires_relay_status = readUInt16LE(bytes.slice(offset + 2, offset + 4));\n            offset += 4;\n\n            decoded.wires_relay_config = {};\n            var wire_relay_bit_offset = { y1: 0, y2_gl: 1, w1: 2, w2_aux: 3, e: 4, g: 5, ob: 6 };\n            for (var key in wire_relay_bit_offset) {\n                if ((wires_relay_mask >>> wire_relay_bit_offset[key]) & 0x01) {\n                    decoded.wires_relay_config[key] = readOnOffStatus((wires_relay_status >>> wire_relay_bit_offset[key]) & 0x01);\n                }\n            }\n            break;\n        case 0xf8:\n            decoded.offline_control_mode = readOfflineControlMode(readUInt8(bytes[offset]));\n            offset += 1;\n            break;\n        case 0xf9:\n            decoded.humidity_calibration_settings = {};\n            decoded.humidity_calibration_settings.enable = readEnableStatus(readUInt8(bytes[offset]));\n            decoded.humidity_calibration_settings.calibration_value = readInt16LE(bytes.slice(offset + 1, offset + 3)) / 10;\n            offset += 3;\n            break;\n        case 0xfa:\n            decoded.temperature_control_mode = readTemperatureControlMode(readUInt8(bytes[offset]));\n            decoded.target_temperature = readInt16LE(bytes.slice(offset + 1, offset + 3)) / 10;\n            offset += 3;\n            break;\n        case 0xfb:\n            decoded.temperature_control_mode = readTemperatureControlMode(readUInt8(bytes[offset]));\n            offset += 1;\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 0x05:\n            decoded.fan_delay_enable = readEnableStatus(readUInt8(bytes[offset]));\n            decoded.fan_delay_time = readUInt8(bytes[offset + 1]);\n            offset += 2;\n            break;\n        case 0x06:\n            decoded.fan_execute_time = readUInt8(bytes[offset]);\n            offset += 1;\n            break;\n        case 0x07:\n            decoded.fan_dehumidify = {};\n            decoded.fan_dehumidify.enable = readEnableStatus(readUInt8(bytes[offset]));\n            decoded.fan_dehumidify.execute_time = readUInt8(bytes[offset + 1]);\n            offset += 2;\n            break;\n        case 0x08:\n            var screen_display_mode_map = { 0: \"on\", 1: \"without plan show\", 2: \"disable all\" };\n            decoded.screen_display_mode = getValue(screen_display_mode_map, readUInt8(bytes[offset]));\n            offset += 1;\n            break;\n        case 0x09:\n            decoded.humidity_range = {};\n            decoded.humidity_range.min = readUInt8(bytes[offset]);\n            decoded.humidity_range.max = readUInt8(bytes[offset + 1]);\n            offset += 2;\n            break;\n        case 0x0a:\n            decoded.temperature_dehumidify = {};\n            decoded.temperature_dehumidify.enable = readEnableStatus(bytes[offset]);\n            var temperature_dehumidify_value = readUInt8(bytes[offset + 1]);\n            if (temperature_dehumidify_value !== 0xff) {\n                decoded.temperature_dehumidify.temperature_tolerance = temperature_dehumidify_value / 10;\n            }\n            offset += 2;\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 readEnableStatus(status) {\n    var status_map = { 0: \"disable\", 1: \"enable\" };\n    return getValue(status_map, status);\n}\n\nfunction readYesNoStatus(type) {\n    var yes_no_status_map = { 0: \"no\", 1: \"yes\" };\n    return getValue(yes_no_status_map, type);\n}\n\nfunction readOnOffStatus(type) {\n    var on_off_status_map = { 0: \"off\", 1: \"on\" };\n    return getValue(on_off_status_map, type);\n}\n\nfunction readTemperatureUnit(type) {\n    var temperature_unit_map = { 0: \"celsius\", 1: \"fahrenheit\" };\n    return getValue(temperature_unit_map, type);\n}\n\nfunction readTemperatureAlarm(type) {\n    var temperature_alarm_map = {\n        1: \"emergency heating timeout alarm\",\n        2: \"auxiliary heating timeout alarm\",\n        3: \"persistent low temperature alarm\",\n        4: \"persistent low temperature alarm release\",\n        5: \"persistent high temperature alarm\",\n        6: \"persistent high temperature alarm release\",\n        7: \"freeze protection alarm\",\n        8: \"freeze protection alarm release\",\n        9: \"threshold alarm\",\n        10: \"threshold alarm release\",\n    };\n    return getValue(temperature_alarm_map, type);\n}\n\nfunction readSensorStatus(type) {\n    var sensor_status_map = {\n        1: \"read failed\",\n        2: \"out of range\",\n    };\n    return getValue(sensor_status_map, type);\n}\n\nfunction readPlanEvent(type) {\n    var fix_type = type - 1;\n    if (fix_type === -1) {\n        fix_type = 255;\n    }\n    var plan_event_map = {\n        0: \"wake\",\n        1: \"away\",\n        2: \"home\",\n        3: \"sleep\",\n        255: \"not executed\",\n    };\n    return getValue(plan_event_map, fix_type);\n}\n\nfunction readPlanEventType(type) {\n    var plan_event_type_map = {\n        0: \"wake\",\n        1: \"away\",\n        2: \"home\",\n        3: \"sleep\",\n    };\n    return getValue(plan_event_type_map, type);\n}\n\nfunction readFanMode(type) {\n    var fan_mode_map = {\n        0: \"auto\",\n        1: \"on\",\n        2: \"circulate\",\n        3: \"disable\",\n    };\n    return getValue(fan_mode_map, type);\n}\n\nfunction readFanStatus(type) {\n    var fan_status_map = {\n        0: \"standby\",\n        1: \"high speed\",\n        2: \"low speed\",\n        3: \"on\",\n    };\n    return getValue(fan_status_map, type);\n}\n\nfunction readControlPermission(type) {\n    var control_permission_map = { 0: \"thermostat\", 1: \"remote control\" };\n    return getValue(control_permission_map, type);\n}\n\nfunction readOfflineControlMode(type) {\n    var offline_control_mode_map = { 0: \"keep\", 1: \"thermostat\", 2: \"off\" };\n    return getValue(offline_control_mode_map, type);\n}\n\nfunction readTemperatureControlMode(type) {\n    var temperature_control_mode_map = { 0: \"heat\", 1: \"em_heat\", 2: \"cool\", 3: \"auto\" };\n    return getValue(temperature_control_mode_map, type);\n}\n\nfunction readTemperatureControlStatus(type) {\n    var temperature_control_status_map = {\n        0: \"standby\",\n        1: \"stage-1 heat\",\n        2: \"stage-2 heat\",\n        3: \"stage-3 heat\",\n        4: \"stage-4 heat\",\n        5: \"em_heat\",\n        6: \"stage-1 cool\",\n        7: \"stage-2 cool\",\n    };\n    return getValue(temperature_control_status_map, type);\n}\n\nfunction readWires(wire1, wire2, wire3) {\n    var wire = {};\n    wire.y1 = readOnOffStatus((wire1 >>> 0) & 0x03);\n    wire.gh = readOnOffStatus((wire1 >>> 2) & 0x03);\n    wire.ob = readOnOffStatus((wire1 >>> 4) & 0x03);\n    wire.w1 = readOnOffStatus((wire1 >>> 6) & 0x03);\n\n    wire.e = readOnOffStatus((wire2 >>> 0) & 0x03);\n    wire.di = readOnOffStatus((wire2 >>> 2) & 0x03);\n    wire.pek = readOnOffStatus((wire2 >>> 4) & 0x03);\n    wire.w2 = readOnOffStatus((wire2 >>> 6) & 0x01);\n    wire.aux = readOnOffStatus(((wire2 >>> 6) & 0x03) === 2 ? 1 : 0);\n\n    wire.y2 = readOnOffStatus((wire3 >>> 0) & 0x01);\n    wire.gl = readOnOffStatus(((wire3 >>> 0) & 0x03) === 2 ? 1 : 0);\n    return wire;\n}\n\nfunction readWiresRelay(status) {\n    var relay = {};\n    relay.y1 = readOnOffStatus((status >>> 0) & 0x01);\n    relay.y2_gl = readOnOffStatus((status >>> 1) & 0x01);\n    relay.w1 = readOnOffStatus((status >>> 2) & 0x01);\n    relay.w2_aux = readOnOffStatus((status >>> 3) & 0x01);\n    relay.e = readOnOffStatus((status >>> 4) & 0x01);\n    relay.g = readOnOffStatus((status >>> 5) & 0x01);\n    relay.ob = readOnOffStatus((status >>> 6) & 0x01);\n    return relay;\n}\n\nfunction readObMode(type) {\n    var ob_mode_map = { 0: \"on_cool\", 1: \"on_heat\", 3: \"hold\" };\n    return getValue(ob_mode_map, type);\n}\n\nfunction readActionType(type) {\n    var action_type_map = { 0: \"power\", 1: \"plan\" };\n    return getValue(action_type_map, type);\n}\n\nfunction readTemperatureLevelUpCondition(type) {\n    var temperature_level_up_condition_map = { 0: \"heat\", 1: \"cool\" };\n    return getValue(temperature_level_up_condition_map, type);\n}\n\nfunction readTemperatureControlSupportMode(type) {\n    var enable = {};\n    enable.heat = readEnableStatus((type >>> 0) & 0x01);\n    enable.em_heat = readEnableStatus((type >>> 1) & 0x01);\n    enable.cool = readEnableStatus((type >>> 2) & 0x01);\n    enable.auto = readEnableStatus((type >>> 3) & 0x01);\n    return enable;\n}\n\nfunction readTemperatureControlSupportStatus(heat_mode, cool_mode) {\n    var enable = {};\n    enable.stage_1_heat = readEnableStatus((heat_mode >>> 0) & 0x01);\n    enable.stage_2_heat = readEnableStatus((heat_mode >>> 1) & 0x01);\n    enable.stage_3_heat = readEnableStatus((heat_mode >>> 2) & 0x01);\n    enable.stage_4_heat = readEnableStatus((heat_mode >>> 3) & 0x01);\n    enable.aux_heat = readEnableStatus((heat_mode >>> 4) & 0x01);\n    enable.stage_1_cool = readEnableStatus((cool_mode >>> 0) & 0x01);\n    enable.stage_2_cool = readEnableStatus((cool_mode >>> 1) & 0x01);\n    return enable;\n}\n\nfunction readReportStatus(type) {\n    var report_status_map = { 0: \"plan\", 1: \"periodic\" };\n    return getValue(report_status_map, type);\n}\n\nfunction readWeekRecycleSettings(type) {\n    var week_day_bits_offset = { monday: 1, tuesday: 2, wednesday: 3, thursday: 4, friday: 5, saturday: 6, sunday: 7 };\n    var week_enable = {};\n    for (var day in week_day_bits_offset) {\n        week_enable[day] = readEnableStatus((type >>> week_day_bits_offset[day]) & 0x01);\n    }\n    return week_enable;\n}\n\nfunction readTimeZone(time_zone) {\n    var timezone_map = { \"-720\": \"UTC-12\", \"-660\": \"UTC-11\", \"-600\": \"UTC-10\", \"-570\": \"UTC-9:30\", \"-540\": \"UTC-9\", \"-480\": \"UTC-8\", \"-420\": \"UTC-7\", \"-360\": \"UTC-6\", \"-300\": \"UTC-5\", \"-240\": \"UTC-4\", \"-210\": \"UTC-3:30\", \"-180\": \"UTC-3\", \"-120\": \"UTC-2\", \"-60\": \"UTC-1\", 0: \"UTC\", 60: \"UTC+1\", 120: \"UTC+2\", 180: \"UTC+3\", 210: \"UTC+3:30\", 240: \"UTC+4\", 270: \"UTC+4:30\", 300: \"UTC+5\", 330: \"UTC+5:30\", 345: \"UTC+5:45\", 360: \"UTC+6\", 390: \"UTC+6:30\", 420: \"UTC+7\", 480: \"UTC+8\", 540: \"UTC+9\", 570: \"UTC+9:30\", 600: \"UTC+10\", 630: \"UTC+10:30\", 660: \"UTC+11\", 720: \"UTC+12\", 765: \"UTC+12:45\", 780: \"UTC+13\", 840: \"UTC+14\" };\n    return getValue(timezone_map, time_zone);\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\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 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\nObject.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/* eslint-enable */",
                        "environment": "javascript",
                        "storage": "",
                        "version": "1.0"
                    },
                    "flows": {
                        "milesight_wt201_decoder": {
                            "data": {
                                "payload": "{{payload}}",
                                "payload_function": "decodeThingerUplink",
                                "payload_type": "source_payload",
                                "resource": "uplink",
                                "source": "resource",
                                "update": "events"
                            },
                            "enabled": true,
                            "sink": {
                                "payload": "{{payload}}",
                                "payload_function": "",
                                "payload_type": "source_payload",
                                "resource_stream": "uplink_decoded",
                                "target": "resource_stream"
                            },
                            "split_data": false
                        }
                    },
                    "properties": {
                        "uplink": {
                            "data": {
                                "payload": "{{payload}}",
                                "payload_function": "",
                                "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": "Temperature"
                                                },
                                                "properties": {
                                                    "decimalPlaces": 1,
                                                    "icon": "fas fa-thermometer-half",
                                                    "iconColor": "#e74c3c",
                                                    "iconGap": "8px",
                                                    "iconPosition": "above-value",
                                                    "iconSize": "50px",
                                                    "textAlign": "center",
                                                    "textColor": "#1E313E",
                                                    "textSize": "65px",
                                                    "textWeight": "font-light",
                                                    "unit": "°C",
                                                    "unitSize": "18px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_wt201_data",
                                                            "mapping": "temperature",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#e74c3c",
                                                        "name": "Temperature",
                                                        "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": "Target Temperature"
                                                },
                                                "properties": {
                                                    "decimalPlaces": 1,
                                                    "icon": "fas fa-bullseye",
                                                    "iconColor": "#3498db",
                                                    "iconGap": "8px",
                                                    "iconPosition": "above-value",
                                                    "iconSize": "50px",
                                                    "textAlign": "center",
                                                    "textColor": "#1E313E",
                                                    "textSize": "65px",
                                                    "textWeight": "font-light",
                                                    "unit": "°C",
                                                    "unitSize": "18px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_wt201_data",
                                                            "mapping": "target_temperature",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#3498db",
                                                        "name": "Target 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",
                                                    "iconGap": "8px",
                                                    "iconPosition": "above-value",
                                                    "iconSize": "50px",
                                                    "textAlign": "center",
                                                    "textColor": "#1E313E",
                                                    "textSize": "65px",
                                                    "textWeight": "font-light",
                                                    "unit": "%",
                                                    "unitSize": "18px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_wt201_data",
                                                            "mapping": "humidity",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#3498db",
                                                        "name": "Humidity",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "text"
                                            },
                                            {
                                                "layout": {
                                                    "col": 0,
                                                    "row": 5,
                                                    "sizeX": 2,
                                                    "sizeY": 4
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "System Status"
                                                },
                                                "properties": {
                                                    "icon": "fas fa-power-off",
                                                    "iconColor": "#34495e",
                                                    "iconColorConditions": [
                                                        {
                                                            "color": "#27ae60",
                                                            "value": "on"
                                                        },
                                                        {
                                                            "color": "#95a5a6",
                                                            "value": "off"
                                                        }
                                                    ],
                                                    "iconGap": "8px",
                                                    "iconPosition": "above-value",
                                                    "iconSize": "40px",
                                                    "textAlign": "center",
                                                    "textColor": "#1E313E",
                                                    "textColorConditions": [
                                                        {
                                                            "color": "#27ae60",
                                                            "value": "on"
                                                        },
                                                        {
                                                            "color": "#95a5a6",
                                                            "value": "off"
                                                        }
                                                    ],
                                                    "textSize": "32px",
                                                    "textWeight": "font-medium"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_wt201_data",
                                                            "mapping": "system_status",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#34495e",
                                                        "name": "System Status",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "text"
                                            },
                                            {
                                                "layout": {
                                                    "col": 2,
                                                    "row": 5,
                                                    "sizeX": 2,
                                                    "sizeY": 4
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Control Mode"
                                                },
                                                "properties": {
                                                    "icon": "fas fa-cog",
                                                    "iconColor": "#34495e",
                                                    "iconColorConditions": [
                                                        {
                                                            "color": "#e74c3c",
                                                            "value": "heat"
                                                        },
                                                        {
                                                            "color": "#3498db",
                                                            "value": "cool"
                                                        },
                                                        {
                                                            "color": "#9b59b6",
                                                            "value": "auto"
                                                        },
                                                        {
                                                            "color": "#e67e22",
                                                            "value": "em_heat"
                                                        }
                                                    ],
                                                    "iconGap": "8px",
                                                    "iconPosition": "above-value",
                                                    "iconSize": "35px",
                                                    "textAlign": "center",
                                                    "textColor": "#1E313E",
                                                    "textColorConditions": [
                                                        {
                                                            "color": "#e74c3c",
                                                            "value": "heat"
                                                        },
                                                        {
                                                            "color": "#3498db",
                                                            "value": "cool"
                                                        },
                                                        {
                                                            "color": "#9b59b6",
                                                            "value": "auto"
                                                        },
                                                        {
                                                            "color": "#e67e22",
                                                            "value": "em_heat"
                                                        }
                                                    ],
                                                    "textSize": "24px",
                                                    "textWeight": "font-medium"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_wt201_data",
                                                            "mapping": "temperature_control_mode",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#34495e",
                                                        "name": "Control Mode",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "text"
                                            },
                                            {
                                                "layout": {
                                                    "col": 4,
                                                    "row": 5,
                                                    "sizeX": 2,
                                                    "sizeY": 4
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Control Status"
                                                },
                                                "properties": {
                                                    "icon": "fas fa-info-circle",
                                                    "iconColor": "#34495e",
                                                    "iconGap": "8px",
                                                    "iconPosition": "above-value",
                                                    "iconSize": "30px",
                                                    "textAlign": "center",
                                                    "textColor": "#1E313E",
                                                    "textSize": "20px",
                                                    "textWeight": "font-medium"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_wt201_data",
                                                            "mapping": "temperature_control_status",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#34495e",
                                                        "name": "Control Status",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "text"
                                            },
                                            {
                                                "layout": {
                                                    "col": 0,
                                                    "row": 9,
                                                    "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: '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        {\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_wt201_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_wt201_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": 19,
                                                    "sizeX": 6,
                                                    "sizeY": 9
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Target vs Actual Temperature (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: 3\n    },\n    xaxis: {\n        type: 'datetime',\n        labels: {\n            datetimeUTC: false\n        },\n        tooltip: {\n            enabled: false\n        }\n    },\n    yaxis: {\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    tooltip: {\n        x: {\n            format: 'dd/MM/yyyy HH:mm:ss'\n        }\n    }\n};\n",
                                                    "realTimeUpdate": true
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_wt201_data",
                                                            "mapping": "temperature",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#e74c3c",
                                                        "name": "Current Temperature",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "magnitude": "hour",
                                                            "mode": "relative",
                                                            "period": "latest",
                                                            "value": 24
                                                        }
                                                    },
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_wt201_data",
                                                            "mapping": "target_temperature",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#3498db",
                                                        "name": "Target Temperature",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "magnitude": "hour",
                                                            "mode": "relative",
                                                            "period": "latest",
                                                            "value": 24
                                                        }
                                                    }
                                                ],
                                                "type": "apex_charts"
                                            }
                                        ]
                                    },
                                    {
                                        "name": "Fan & Relay",
                                        "widgets": [
                                            {
                                                "layout": {
                                                    "col": 0,
                                                    "row": 0,
                                                    "sizeX": 3,
                                                    "sizeY": 5
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Fan Mode"
                                                },
                                                "properties": {
                                                    "icon": "fas fa-fan",
                                                    "iconColor": "#34495e",
                                                    "iconColorConditions": [
                                                        {
                                                            "color": "#9b59b6",
                                                            "value": "auto"
                                                        },
                                                        {
                                                            "color": "#27ae60",
                                                            "value": "on"
                                                        },
                                                        {
                                                            "color": "#3498db",
                                                            "value": "circulate"
                                                        },
                                                        {
                                                            "color": "#95a5a6",
                                                            "value": "disable"
                                                        }
                                                    ],
                                                    "iconGap": "10px",
                                                    "iconPosition": "above-value",
                                                    "iconSize": "50px",
                                                    "textAlign": "center",
                                                    "textColor": "#1E313E",
                                                    "textColorConditions": [
                                                        {
                                                            "color": "#9b59b6",
                                                            "value": "auto"
                                                        },
                                                        {
                                                            "color": "#27ae60",
                                                            "value": "on"
                                                        },
                                                        {
                                                            "color": "#3498db",
                                                            "value": "circulate"
                                                        },
                                                        {
                                                            "color": "#95a5a6",
                                                            "value": "disable"
                                                        }
                                                    ],
                                                    "textSize": "36px",
                                                    "textWeight": "font-medium"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_wt201_data",
                                                            "mapping": "fan_mode",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#34495e",
                                                        "name": "Fan Mode",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "text"
                                            },
                                            {
                                                "layout": {
                                                    "col": 3,
                                                    "row": 0,
                                                    "sizeX": 3,
                                                    "sizeY": 5
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Fan Status"
                                                },
                                                "properties": {
                                                    "icon": "fas fa-tachometer-alt",
                                                    "iconColor": "#34495e",
                                                    "iconColorConditions": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "value": "standby"
                                                        },
                                                        {
                                                            "color": "#27ae60",
                                                            "value": "on"
                                                        },
                                                        {
                                                            "color": "#e74c3c",
                                                            "value": "high speed"
                                                        },
                                                        {
                                                            "color": "#f39c12",
                                                            "value": "low speed"
                                                        }
                                                    ],
                                                    "iconGap": "10px",
                                                    "iconPosition": "above-value",
                                                    "iconSize": "50px",
                                                    "textAlign": "center",
                                                    "textColor": "#1E313E",
                                                    "textColorConditions": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "value": "standby"
                                                        },
                                                        {
                                                            "color": "#27ae60",
                                                            "value": "on"
                                                        },
                                                        {
                                                            "color": "#e74c3c",
                                                            "value": "high speed"
                                                        },
                                                        {
                                                            "color": "#f39c12",
                                                            "value": "low speed"
                                                        }
                                                    ],
                                                    "textSize": "36px",
                                                    "textWeight": "font-medium"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_wt201_data",
                                                            "mapping": "fan_status",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#34495e",
                                                        "name": "Fan Status",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "text"
                                            },
                                            {
                                                "layout": {
                                                    "col": 0,
                                                    "row": 5,
                                                    "sizeX": 1,
                                                    "sizeY": 4
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Y1 Relay"
                                                },
                                                "properties": {
                                                    "color": "#2ebd59",
                                                    "colors": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "max": "off",
                                                            "min": "off"
                                                        },
                                                        {
                                                            "blink": false,
                                                            "color": "#27ae60",
                                                            "max": "on",
                                                            "min": "on"
                                                        }
                                                    ],
                                                    "size": "60px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_wt201_data",
                                                            "mapping": "wires_relay.y1",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#27ae60",
                                                        "name": "Y1",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "led"
                                            },
                                            {
                                                "layout": {
                                                    "col": 1,
                                                    "row": 5,
                                                    "sizeX": 1,
                                                    "sizeY": 4
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Y2/GL Relay"
                                                },
                                                "properties": {
                                                    "color": "#2ebd59",
                                                    "colors": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "max": "off",
                                                            "min": "off"
                                                        },
                                                        {
                                                            "blink": false,
                                                            "color": "#27ae60",
                                                            "max": "on",
                                                            "min": "on"
                                                        }
                                                    ],
                                                    "size": "60px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_wt201_data",
                                                            "mapping": "wires_relay.y2_gl",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#27ae60",
                                                        "name": "Y2_GL",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "led"
                                            },
                                            {
                                                "layout": {
                                                    "col": 2,
                                                    "row": 5,
                                                    "sizeX": 1,
                                                    "sizeY": 4
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "W1 Relay"
                                                },
                                                "properties": {
                                                    "color": "#2ebd59",
                                                    "colors": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "max": "off",
                                                            "min": "off"
                                                        },
                                                        {
                                                            "blink": false,
                                                            "color": "#e74c3c",
                                                            "max": "on",
                                                            "min": "on"
                                                        }
                                                    ],
                                                    "size": "60px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_wt201_data",
                                                            "mapping": "wires_relay.w1",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#e74c3c",
                                                        "name": "W1",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "led"
                                            },
                                            {
                                                "layout": {
                                                    "col": 3,
                                                    "row": 5,
                                                    "sizeX": 1,
                                                    "sizeY": 4
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "W2/AUX Relay"
                                                },
                                                "properties": {
                                                    "color": "#2ebd59",
                                                    "colors": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "max": "off",
                                                            "min": "off"
                                                        },
                                                        {
                                                            "blink": false,
                                                            "color": "#e74c3c",
                                                            "max": "on",
                                                            "min": "on"
                                                        }
                                                    ],
                                                    "size": "60px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_wt201_data",
                                                            "mapping": "wires_relay.w2_aux",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#e74c3c",
                                                        "name": "W2_AUX",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "led"
                                            },
                                            {
                                                "layout": {
                                                    "col": 4,
                                                    "row": 5,
                                                    "sizeX": 1,
                                                    "sizeY": 4
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "E Relay"
                                                },
                                                "properties": {
                                                    "color": "#2ebd59",
                                                    "colors": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "max": "off",
                                                            "min": "off"
                                                        },
                                                        {
                                                            "blink": false,
                                                            "color": "#3498db",
                                                            "max": "on",
                                                            "min": "on"
                                                        }
                                                    ],
                                                    "size": "60px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_wt201_data",
                                                            "mapping": "wires_relay.e",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#3498db",
                                                        "name": "E",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "led"
                                            },
                                            {
                                                "layout": {
                                                    "col": 5,
                                                    "row": 5,
                                                    "sizeX": 1,
                                                    "sizeY": 4
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "G Relay"
                                                },
                                                "properties": {
                                                    "color": "#2ebd59",
                                                    "colors": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "max": "off",
                                                            "min": "off"
                                                        },
                                                        {
                                                            "blink": false,
                                                            "color": "#27ae60",
                                                            "max": "on",
                                                            "min": "on"
                                                        }
                                                    ],
                                                    "size": "60px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_wt201_data",
                                                            "mapping": "wires_relay.g",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#27ae60",
                                                        "name": "G",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "led"
                                            },
                                            {
                                                "layout": {
                                                    "col": 0,
                                                    "row": 9,
                                                    "sizeX": 1,
                                                    "sizeY": 4
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "OB Relay"
                                                },
                                                "properties": {
                                                    "color": "#2ebd59",
                                                    "colors": [
                                                        {
                                                            "color": "#95a5a6",
                                                            "max": "off",
                                                            "min": "off"
                                                        },
                                                        {
                                                            "blink": false,
                                                            "color": "#9b59b6",
                                                            "max": "on",
                                                            "min": "on"
                                                        }
                                                    ],
                                                    "size": "60px"
                                                },
                                                "sources": [
                                                    {
                                                        "bucket": {
                                                            "backend": "mongodb",
                                                            "id": "milesight_wt201_data",
                                                            "mapping": "wires_relay.ob",
                                                            "tags": {
                                                                "device": [],
                                                                "group": []
                                                            }
                                                        },
                                                        "color": "#9b59b6",
                                                        "name": "OB",
                                                        "source": "bucket",
                                                        "timespan": {
                                                            "mode": "latest"
                                                        }
                                                    }
                                                ],
                                                "type": "led"
                                            },
                                            {
                                                "layout": {
                                                    "col": 1,
                                                    "row": 9,
                                                    "sizeX": 5,
                                                    "sizeY": 8
                                                },
                                                "panel": {
                                                    "color": "#ffffff",
                                                    "currentColor": "#ffffff",
                                                    "showOffline": {
                                                        "type": "none"
                                                    },
                                                    "title": "Relay Status Legend"
                                                },
                                                "properties": {
                                                    "source": "code",
                                                    "template": "<div style=\"padding: 20px; font-family: Arial, sans-serif;\">\n  <h4 style=\"margin-bottom: 15px; color: #34495e;\">HVAC Relay Functions</h4>\n  <table style=\"width: 100%; border-collapse: collapse;\">\n    <tr style=\"background-color: #ecf0f1;\">\n      <th style=\"padding: 10px; text-align: left; border: 1px solid #bdc3c7;\">Relay</th>\n      <th style=\"padding: 10px; text-align: left; border: 1px solid #bdc3c7;\">Function</th>\n    </tr>\n    <tr>\n      <td style=\"padding: 8px; border: 1px solid #bdc3c7;\"><strong>Y1</strong></td>\n      <td style=\"padding: 8px; border: 1px solid #bdc3c7;\">Stage 1 Cooling / Heat Pump</td>\n    </tr>\n    <tr style=\"background-color: #f8f9fa;\">\n      <td style=\"padding: 8px; border: 1px solid #bdc3c7;\"><strong>Y2/GL</strong></td>\n      <td style=\"padding: 8px; border: 1px solid #bdc3c7;\">Stage 2 Cooling / Gas Line</td>\n    </tr>\n    <tr>\n      <td style=\"padding: 8px; border: 1px solid #bdc3c7;\"><strong>W1</strong></td>\n      <td style=\"padding: 8px; border: 1px solid #bdc3c7;\">Stage 1 Heating</td>\n    </tr>\n    <tr style=\"background-color: #f8f9fa;\">\n      <td style=\"padding: 8px; border: 1px solid #bdc3c7;\"><strong>W2/AUX</strong></td>\n      <td style=\"padding: 8px; border: 1px solid #bdc3c7;\">Stage 2 Heating / Auxiliary Heat</td>\n    </tr>\n    <tr>\n      <td style=\"padding: 8px; border: 1px solid #bdc3c7;\"><strong>E</strong></td>\n      <td style=\"padding: 8px; border: 1px solid #bdc3c7;\">Emergency Heat</td>\n    </tr>\n    <tr style=\"background-color: #f8f9fa;\">\n      <td style=\"padding: 8px; border: 1px solid #bdc3c7;\"><strong>G</strong></td>\n      <td style=\"padding: 8px; border: 1px solid #bdc3c7;\">Fan Control</td>\n    </tr>\n    <tr>\n      <td style=\"padding: 8px; border: 1px solid #bdc3c7;\"><strong>OB</strong></td>\n      <td style=\"padding: 8px; border: 1px solid #bdc3c7;\">Reversing Valve (Heat Pump)</td>\n    </tr>\n  </table>\n</div>"
                                                },
                                                "sources": [],
                                                "type": "html_time"
                                            }
                                        ]
                                    }
                                ]
                            }
                        }
                    ]
                }
            }
        ]
    }
}