Plugin file
Plugin configuration file
{
"name": "milesight-iot-wt304",
"version": "1.0.0",
"description": "WT304 is an advanced room thermostat specifically developed to over see fan and valve operations in air conditioner applications where 2-pipe or 4-pipe fan coil unit (FCU) with 3-speed fan or ECMfan is adopted.",
"author": "Thinger.io",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/thinger-io/plugins.git",
"directory": "milesight-iot-wt304"
},
"metadata": {
"name": "Milesight-Iot WT304",
"description": "WT304 is an advanced room thermostat specifically developed to over see fan and valve operations in air conditioner applications where 2-pipe or 4-pipe fan coil unit (FCU) with 3-speed fan or ECMfan is adopted.",
"image": "assets/wt304.png",
"category": "devices",
"vendor": "milesight-iot"
},
"resources": {
"products": [
{
"config": {
"icons": []
},
"description": "WT304 is an advanced room thermostat specifically developed to over see fan and valve operations in air conditioner applications where 2-pipe or 4-pipe fan coil unit (FCU) with 3-speed fan or ECMfan is adopted.",
"enabled": true,
"name": "Milesight-Iot WT304",
"product": "milesight_iot_wt304",
"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": "wt304_.*"
},
"enabled": true
}
},
"buckets": {
"milesight_wt304_data": {
"backend": "mongodb",
"data": {
"payload": "{{payload}}",
"payload_function": "",
"payload_type": "source_payload",
"resource_stream": "uplink_decoded",
"source": "resource_stream"
},
"enabled": true,
"retention": {
"period": 3,
"unit": "months"
},
"tags": []
}
},
"code": {
"code": "function decodeThingerUplink(thingerData) {\n // 0. If data has already been decoded, we will return it\n if (thingerData.decodedPayload) return thingerData.decodedPayload;\n \n // 1. Extract and Validate Input\n // We need 'payload' (hex string) and 'fPort' (integer)\n const hexPayload = thingerData.payload || \"\";\n const port = thingerData.fPort || 1;\n\n // 2. Convert Hex String to Byte Array\n const bytes = [];\n for (let i = 0; i < hexPayload.length; i += 2) {\n bytes.push(parseInt(hexPayload.substr(i, 2), 16));\n }\n\n // 3. Dynamic Function Detection and Execution\n \n // CASE A: (The Things Stack v3)\n if (typeof decodeUplink === 'function') {\n try {\n const input = {\n bytes: bytes,\n fPort: port\n };\n var result = decodeUplink(input);\n \n if (result.data) return result.data;\n\n return result; \n } catch (e) {\n console.error(\"Error inside decodeUplink:\", e);\n throw e;\n }\n }\n\n // CASE B: Legacy TTN (v2)\n else if (typeof Decoder === 'function') {\n try {\n return Decoder(bytes, port);\n } catch (e) {\n console.error(\"Error inside Decoder:\", e);\n throw e;\n }\n }\n\n // CASE C: No decoder found\n else {\n throw new Error(\"No compatible TTN decoder function (decodeUplink or Decoder) found in scope.\");\n }\n}\n\n\n// TTN decoder\nfunction decodeUplink(input) {\n var res = Decoder(input.bytes, input.fPort);\n if (res.error) {\n return {\n errors: [res.error],\n };\n }\n return {\n data: res,\n };\n}\n/**\n * Payload Decoder\n *\n * Copyright 2025 Milesight IoT\n *\n * @product WT303\n */\nvar RAW_VALUE = 0x00;\n\n/* eslint no-redeclare: \"off\" */\n/* eslint-disable */\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 var unknown_command = 0;\n for (var i = 0; i < bytes.length; ) {\n var command_id = bytes[i++];\n\n switch (command_id) {\n // attribute\n case 0xdf:\n decoded.tsl_version = readProtocolVersion(bytes.slice(i, i + 2));\n i += 2;\n break;\n case 0xde: // ?\n decoded.product_name = readString(bytes.slice(i, i + 32));\n i += 32;\n break;\n case 0xdd: // ?\n decoded.product_pn = readString(bytes.slice(i, i + 32));\n i += 32;\n break;\n case 0xdb:\n decoded.product_sn = readHexString(bytes.slice(i, i + 8));\n i += 8;\n break;\n case 0xda:\n decoded.version = {};\n decoded.version.hardware_version = readHardwareVersion(bytes.slice(i, i + 2));\n decoded.version.firmware_version = readFirmwareVersion(bytes.slice(i + 2, i + 8));\n i += 8;\n break;\n case 0xd9:\n decoded.oem_id = readHexString(bytes.slice(i, i + 2));\n i += 2;\n break;\n case 0xd8:\n decoded.product_frequency_band = readString(bytes.slice(i, i + 16));\n i += 16;\n break;\n case 0xee:\n decoded.device_request = 1;\n i += 0;\n break;\n case 0xc8:\n decoded.device_status = readDeviceStatus(bytes[i]);\n i += 1;\n break;\n case 0xcf:\n // skip 1 byte\n decoded.lorawan_class = readLoRaWANClass(bytes[i + 1]);\n i += 2;\n break;\n\n // telemetry\n case 0x01:\n decoded.temperature = readInt16LE(bytes.slice(i, i + 2)) / 100;\n i += 2;\n break;\n case 0x02:\n decoded.humidity = readUInt16LE(bytes.slice(i, i + 2)) / 10;\n i += 2;\n break;\n case 0x03:\n decoded.target_temperature = readInt16LE(bytes.slice(i, i + 2)) / 100;\n i += 2;\n break;\n case 0x04:\n decoded.temperature_data_source = readTemperatureDataSource(bytes[i]);\n i += 1;\n break;\n case 0x05:\n var temperature_control_data = readUInt8(bytes[i]);\n decoded.temperature_control_status = readTemperatureControlStatus((temperature_control_data >>> 0) & 0x0f);\n decoded.temperature_control_mode = readTemperatureControlMode((temperature_control_data >>> 4) & 0x0f);\n i += 1;\n break;\n case 0x06:\n decoded.valve_status = readValveStatus(bytes[i]);\n i += 1;\n break;\n case 0x07:\n var fan_data = readUInt8(bytes[i]);\n decoded.fan_status = readFanStatus((fan_data >>> 0) & 0x0f);\n decoded.fan_mode = readFanMode((fan_data >>> 4) & 0x0f);\n i += 1;\n break;\n case 0x08:\n decoded.plan_id = readPlanId(readUInt8(bytes[i]));\n i += 1;\n break;\n case 0x09:\n var alarm_type = readUInt8(bytes[i]);\n decoded.temperature_alarm = {};\n decoded.temperature_alarm.type = readTemperatureAlarmType(alarm_type);\n if (hasTemperature(alarm_type)) {\n var temperature = readInt16LE(bytes.slice(i + 1, i + 3)) / 100;\n decoded.temperature = temperature;\n decoded.temperature_alarm.temperature = temperature;\n i += 3;\n } else {\n i += 1;\n }\n break;\n case 0x0a:\n decoded.humidity_alarm = readHumidityAlarm(bytes[i]);\n i += 1;\n break;\n case 0x0b:\n decoded.target_temperature_alarm = readTargetTemperatureAlarm(bytes[i]);\n i += 1;\n break;\n case 0x10:\n var relay_status_offset = { gl_status: 0, gm_status: 1, gh_status: 2, valve_1_status: 3, valve_2_status: 4 };\n var relay_status_data = readUInt32LE(bytes.slice(i, i + 4));\n decoded.relay_status = decoded.relay_status || {};\n for (var key in relay_status_offset) {\n decoded.relay_status[key] = readEnableStatus((relay_status_data >>> relay_status_offset[key]) & 0x01);\n }\n i += 4;\n break;\n\n // config\n case 0x60:\n var time_unit = readUInt8(bytes[i]);\n decoded.collection_interval = {};\n decoded.collection_interval.unit = readTimeUnitType(time_unit);\n if (time_unit === 0) {\n decoded.collection_interval.seconds_of_time = readUInt16LE(bytes.slice(i + 1, i + 3));\n } else if (time_unit === 1) {\n decoded.collection_interval.minutes_of_time = readUInt16LE(bytes.slice(i + 1, i + 3));\n }\n i += 3;\n break;\n case 0x62:\n var time_unit = readUInt8(bytes[i]);\n decoded.reporting_interval = {};\n decoded.reporting_interval.unit = readTimeUnitType(time_unit);\n if (time_unit === 0) {\n decoded.reporting_interval.seconds_of_time = readUInt16LE(bytes.slice(i + 1, i + 3));\n } else if (time_unit === 1) {\n decoded.reporting_interval.minutes_of_time = readUInt16LE(bytes.slice(i + 1, i + 3));\n }\n i += 3;\n break;\n case 0x63:\n decoded.temperature_unit = readTemperatureUnit(bytes[i]);\n i += 1;\n break;\n case 0x64:\n decoded.support_mode = readSupportMode(bytes[i]);\n i += 1;\n break;\n case 0x65:\n decoded.intelligent_display_enable = readEnableStatus(bytes[i]);\n i += 1;\n break;\n case 0x66:\n decoded.screen_object_settings = decoded.screen_object_settings || {};\n decoded.screen_object_settings.enable = readEnableStatus(bytes[i]);\n var screen_object_data = readUInt8(bytes[i + 1]);\n var screen_object_offset = { environment_temperature_enable: 0, environment_humidity_enable: 1, target_temperature_enable: 2, schedule_name_enable: 3 };\n for (var key in screen_object_offset) {\n decoded.screen_object_settings[key] = readEnableStatus((screen_object_data >>> screen_object_offset[key]) & 0x01);\n }\n i += 2;\n break;\n case 0x67:\n decoded.system_status = readSystemStatus(bytes[i]);\n i += 1;\n break;\n case 0x68:\n decoded.temperature_control_mode = readTemperatureControlMode(bytes[i]);\n i += 1;\n break;\n case 0x69:\n decoded.target_temperature_resolution = readTargetTemperatureResolution(bytes[i]);\n i += 1;\n break;\n case 0x6a:\n decoded.target_temperature_tolerance = readInt16LE(bytes.slice(i, i + 2)) / 100;\n i += 2;\n break;\n case 0x6b:\n decoded.heating_target_temperature = readInt16LE(bytes.slice(i, i + 2)) / 100;\n i += 2;\n break;\n case 0x6c:\n decoded.cooling_target_temperature = readInt16LE(bytes.slice(i, i + 2)) / 100;\n i += 2;\n break;\n case 0x6d:\n decoded.heating_target_temperature_range = {};\n decoded.heating_target_temperature_range.min = readInt16LE(bytes.slice(i, i + 2)) / 100;\n decoded.heating_target_temperature_range.max = readInt16LE(bytes.slice(i + 2, i + 4)) / 100;\n i += 4;\n break;\n case 0x6e:\n decoded.cooling_target_temperature_range = {};\n decoded.cooling_target_temperature_range.min = readInt16LE(bytes.slice(i, i + 2)) / 100;\n decoded.cooling_target_temperature_range.max = readInt16LE(bytes.slice(i + 2, i + 4)) / 100;\n i += 4;\n break;\n case 0x6f:\n decoded.dehumidify_config = {};\n decoded.dehumidify_config.enable = readEnableStatus(bytes[i]);\n decoded.dehumidify_config.temperature_tolerance = readInt16LE(bytes.slice(i + 1, i + 3)) / 100;\n i += 3;\n break;\n case 0x70:\n decoded.target_humidity_range = {};\n decoded.target_humidity_range.min = readUInt16LE(bytes.slice(i, i + 2)) / 10;\n decoded.target_humidity_range.max = readUInt16LE(bytes.slice(i + 2, i + 4)) / 10;\n i += 4;\n break;\n case 0x72:\n decoded.fan_mode = readFanMode(bytes[i]);\n i += 1;\n break;\n case 0x73:\n decoded.fan_speed_config = {};\n decoded.fan_speed_config.delta_1 = readInt16LE(bytes.slice(i, i + 2)) / 100;\n decoded.fan_speed_config.delta_2 = readInt16LE(bytes.slice(i + 2, i + 4)) / 100;\n i += 4;\n break;\n case 0x74:\n decoded.fan_delay_config = {};\n decoded.fan_delay_config.enable = readEnableStatus(bytes[i]);\n decoded.fan_delay_config.delay_time = readUInt16LE(bytes.slice(i + 1, i + 3));\n i += 3;\n break;\n case 0x75:\n var child_lock_offset = { system_button: 0, temperature_button: 1, fan_button: 2, temperature_control_button: 3, reboot_reset_button: 4 };\n decoded.child_lock_settings = {};\n decoded.child_lock_settings.enable = readEnableStatus(bytes[i]);\n var child_lock_data = readUInt8(bytes[i + 1]);\n for (var key in child_lock_offset) {\n decoded.child_lock_settings[key] = readEnableStatus((child_lock_data >>> child_lock_offset[key]) & 0x01);\n }\n i += 2;\n break;\n case 0x76:\n decoded.temperature_alarm_settings = {};\n decoded.temperature_alarm_settings.enable = readEnableStatus(bytes[i]);\n decoded.temperature_alarm_settings.condition = readMathConditionType(readUInt8(bytes[i + 1]));\n decoded.temperature_alarm_settings.threshold_min = readInt16LE(bytes.slice(i + 2, i + 4)) / 100;\n decoded.temperature_alarm_settings.threshold_max = readInt16LE(bytes.slice(i + 4, i + 6)) / 100;\n i += 6;\n break;\n case 0x77:\n decoded.high_temperature_alarm_settings = {};\n decoded.high_temperature_alarm_settings.enable = readEnableStatus(bytes[i]);\n decoded.high_temperature_alarm_settings.delta_temperature = readInt16LE(bytes.slice(i + 1, i + 3)) / 100;\n decoded.high_temperature_alarm_settings.duration = readUInt8(bytes[i + 3]);\n i += 4;\n break;\n case 0x78:\n decoded.low_temperature_alarm_settings = {};\n decoded.low_temperature_alarm_settings.enable = readEnableStatus(bytes[i]);\n decoded.low_temperature_alarm_settings.delta_temperature = readInt16LE(bytes.slice(i + 1, i + 3)) / 100;\n decoded.low_temperature_alarm_settings.duration = readUInt8(bytes[i + 3]);\n i += 4;\n break;\n case 0x79:\n decoded.temperature_calibration_settings = {};\n decoded.temperature_calibration_settings.enable = readEnableStatus(bytes[i]);\n decoded.temperature_calibration_settings.calibration_value = readInt16LE(bytes.slice(i + 1, i + 3)) / 100;\n i += 3;\n break;\n case 0x7a:\n decoded.humidity_calibration_settings = {};\n decoded.humidity_calibration_settings.enable = readEnableStatus(bytes[i]);\n decoded.humidity_calibration_settings.calibration_value = readInt16LE(bytes.slice(i + 1, i + 3)) / 10;\n i += 3;\n break;\n case 0x7b:\n var plan_config = {};\n plan_config.plan_id = readUInt8(bytes[i]) + 1;\n var data = readUInt8(bytes[i + 1]);\n if (data === 0x00) {\n plan_config.enable = readEnableStatus(bytes[i + 2]);\n i += 3;\n } else if (data === 0x01) {\n plan_config.name_first = readString(bytes.slice(i + 2, i + 8));\n i += 8;\n } else if (data === 0x02) {\n plan_config.name_last = readString(bytes.slice(i + 2, i + 6));\n i += 6;\n } else if (data === 0x03) {\n var fan_mode_data = readUInt8(bytes[i + 2]);\n var heating_temperature_data = readInt16LE(bytes.slice(i + 3, i + 5));\n var cooling_temperature_data = readInt16LE(bytes.slice(i + 5, i + 7));\n var temperature_tolerance_data = readInt16LE(bytes.slice(i + 7, i + 9));\n plan_config.fan_mode = readFanMode(fan_mode_data);\n plan_config.heating_temperature = (heating_temperature_data >>> 1) / 100;\n plan_config.cooling_temperature = (cooling_temperature_data >>> 1) / 100;\n plan_config.temperature_tolerance = (temperature_tolerance_data >>> 1) / 100;\n plan_config.heating_temperature_enable = readEnableStatus((heating_temperature_data >>> 0) & 0x01);\n plan_config.cooling_temperature_enable = readEnableStatus((cooling_temperature_data >>> 0) & 0x01);\n plan_config.temperature_tolerance_enable = readEnableStatus((temperature_tolerance_data >>> 0) & 0x01);\n i += 9;\n } else if (data === 0x04) {\n var schedule_config = {};\n schedule_config.index = readUInt8(bytes[i + 2]) + 1;\n schedule_config.enable = readEnableStatus(bytes[i + 3]);\n schedule_config.time = readUInt16LE(bytes.slice(i + 4, i + 6));\n var data = readUInt8(bytes[i + 6]);\n var weekday_bits_offset = { sunday: 0, monday: 1, tuesday: 2, wednesday: 3, thursday: 4, friday: 5, saturday: 6 };\n schedule_config.weekday = {};\n for (var key in weekday_bits_offset) {\n schedule_config.weekday[key] = readEnableStatus((data >>> weekday_bits_offset[key]) & 0x01);\n }\n i += 7;\n plan_config.schedule_config = plan_config.schedule_config || [];\n plan_config.schedule_config.push(schedule_config);\n }\n decoded.plan_config = decoded.plan_config || [];\n decoded.plan_config.push(plan_config);\n break;\n case 0x7c:\n var mode_value = readUInt8(bytes[i]);\n decoded.valve_interface_settings = {};\n decoded.valve_interface_settings.mode = readValveInterfaceMode(mode_value);\n // four_pipe_two_wire\n if (mode_value === 0x00) {\n decoded.valve_interface_settings.four_pipe_two_wire = {};\n decoded.valve_interface_settings.four_pipe_two_wire.cooling_valve = readValve(bytes[i + 1]);\n decoded.valve_interface_settings.four_pipe_two_wire.heating_valve = readValve(bytes[i + 2]);\n i += 3;\n }\n // two_pipe_two_wire\n else if (mode_value === 0x01) {\n decoded.valve_interface_settings.two_pipe_two_wire = {};\n decoded.valve_interface_settings.two_pipe_two_wire.valve = readValve(bytes[i + 1]);\n i += 2;\n }\n // two_pipe_three_wire\n else if (mode_value === 0x02) {\n decoded.valve_interface_settings.two_pipe_three_wire = {};\n decoded.valve_interface_settings.two_pipe_three_wire.no_valve = readValve(bytes[i + 1]);\n decoded.valve_interface_settings.two_pipe_three_wire.nc_valve = readValve(bytes[i + 2]);\n i += 3;\n }\n break;\n case 0x80:\n decoded.di_settings = decoded.di_settings || {};\n decoded.di_settings.enable = readEnableStatus(bytes[i]);\n i += 1;\n break;\n case 0x81:\n decoded.di_settings = decoded.di_settings || {};\n var di_settings_type = readUInt8(bytes[i]);\n decoded.di_settings.type = readDIType(di_settings_type);\n if (di_settings_type === 0) {\n decoded.di_settings.card_control = {};\n var card_control_data = readUInt8(bytes[i + 1]);\n decoded.di_settings.card_control.mode = readCardControlMode(card_control_data);\n // power mode\n if (card_control_data === 0x00) {\n decoded.di_settings.card_control.system_status = readSystemStatus(bytes[i + 2]);\n i += 3;\n }\n // plan mode\n else if (card_control_data === 0x01) {\n decoded.di_settings.card_control.in_plan_id = readUInt8(bytes[i + 2]) + 1;\n decoded.di_settings.card_control.out_plan_id = readUInt8(bytes[i + 3]) + 1;\n i += 4;\n }\n } else if (di_settings_type === 1) {\n decoded.di_settings.magnet_detection = {};\n var magnet_detection_data = readUInt8(bytes[i + 1]);\n decoded.di_settings.magnet_detection.mode = readMagnetDetectionMode(magnet_detection_data);\n i += 2;\n }\n break;\n case 0x82:\n decoded.window_opening_detection_settings = decoded.window_opening_detection_settings || {};\n decoded.window_opening_detection_settings.enable = readEnableStatus(bytes[i]);\n i += 1;\n break;\n case 0x83:\n decoded.window_opening_detection_settings = decoded.window_opening_detection_settings || {};\n var data = readUInt8(bytes[i]);\n decoded.window_opening_detection_settings.type = readWindowOpeningDetectionType(data);\n // temperature detection\n if (data === 0x00) {\n decoded.window_opening_detection_settings.temperature_detection = {};\n decoded.window_opening_detection_settings.temperature_detection.delta_temperature = readInt16LE(bytes.slice(i + 1, i + 3)) / 100;\n decoded.window_opening_detection_settings.temperature_detection.duration = readUInt8(bytes[i + 3]);\n i += 4;\n }\n // magnet detection\n else if (data === 0x01) {\n decoded.window_opening_detection_settings.magnet_detection = {};\n decoded.window_opening_detection_settings.magnet_detection.duration = readUInt8(bytes[i + 1]);\n i += 2;\n }\n break;\n case 0x84:\n decoded.freeze_protection_settings = decoded.freeze_protection_settings || {};\n decoded.freeze_protection_settings.enable = readEnableStatus(bytes[i]);\n decoded.freeze_protection_settings.target_temperature = readInt16LE(bytes.slice(i + 1, i + 3)) / 100;\n i += 3;\n break;\n case 0x85:\n decoded.temperature_source_settings = decoded.temperature_source_settings || {};\n var data_source = readUInt8(bytes[i]);\n decoded.temperature_source_settings.source = readTemperatureDataSource(data_source);\n if (data_source === 0 || data_source === 1) {\n i += 1;\n } else if (data_source === 2 || data_source === 3) {\n decoded.temperature_source_settings.duration = readUInt8(bytes[i + 1]);\n decoded.temperature_source_settings.missing_data_action = readMissingDataAction(bytes[i + 2]);\n i += 3;\n }\n break;\n case 0x86:\n decoded.d2d_pairing_enable = readEnableStatus(bytes[i]);\n i += 1;\n break;\n case 0x87:\n var d2d_pairing_settings = {};\n d2d_pairing_settings.index = readUInt8(bytes[i]) + 1;\n var data = readUInt8(bytes[i + 1]);\n if (data === 0x00) {\n d2d_pairing_settings.enable = readEnableStatus(bytes[i + 2]);\n i += 3;\n } else if (data === 0x01) {\n d2d_pairing_settings.eui = readHexString(bytes.slice(i + 2, i + 10));\n i += 10;\n } else if (data === 0x02) {\n d2d_pairing_settings.name_first = readString(bytes.slice(i + 2, i + 10));\n i += 10;\n } else if (data === 0x03) {\n d2d_pairing_settings.name_last = readString(bytes.slice(i + 2, i + 10));\n i += 10;\n }\n decoded.d2d_pairing_settings = decoded.d2d_pairing_settings || [];\n decoded.d2d_pairing_settings.push(d2d_pairing_settings);\n break;\n case 0x88:\n decoded.d2d_master_enable = readEnableStatus(bytes[i]);\n i += 1;\n break;\n case 0x89:\n var trigger_source_data = readUInt8(bytes[i]);\n var d2d_master_settings = {};\n d2d_master_settings.trigger_source = readD2DTriggerSource(trigger_source_data);\n d2d_master_settings.enable = readEnableStatus(bytes[i + 1]);\n d2d_master_settings.lora_uplink_enable = readEnableStatus(bytes[i + 2]);\n d2d_master_settings.command = readHexStringLE(bytes.slice(i + 3, i + 5));\n d2d_master_settings.time_enable = readEnableStatus(bytes[i + 5]);\n d2d_master_settings.time = readUInt16LE(bytes.slice(i + 6, i + 8));\n i += 8;\n decoded.d2d_master_settings = decoded.d2d_master_settings || [];\n decoded.d2d_master_settings.push(d2d_master_settings);\n break;\n case 0x8a:\n decoded.d2d_slave_enable = readEnableStatus(bytes[i]);\n i += 1;\n break;\n case 0x8b:\n var d2d_slave_settings = {};\n d2d_slave_settings.index = readUInt8(bytes[i]) + 1;\n d2d_slave_settings.enable = readEnableStatus(bytes[i + 1]);\n d2d_slave_settings.command = readHexStringLE(bytes.slice(i + 2, i + 4));\n d2d_slave_settings.trigger_target = readD2DTriggerTarget(bytes[i + 4]);\n i += 5;\n decoded.d2d_slave_settings = decoded.d2d_slave_settings || [];\n decoded.d2d_slave_settings.push(d2d_slave_settings);\n break;\n case 0x8c:\n var type = readUInt8(bytes[i]);\n decoded.timed_system_control_settings = decoded.timed_system_control_settings || {};\n if (type === 0) {\n decoded.timed_system_control_settings.enable = readEnableStatus(bytes[i + 1]);\n i += 2;\n } else if (type === 1) {\n var start_cycle_settings = {};\n start_cycle_settings.index = readUInt8(bytes[i + 1]) + 1;\n start_cycle_settings.enable = readEnableStatus(bytes[i + 2]);\n start_cycle_settings.time = readUInt16LE(bytes.slice(i + 3, i + 5));\n var weekday_data = readUInt8(bytes[i + 5]);\n var weekday_bits_offset = { sunday: 0, monday: 1, tuesday: 2, wednesday: 3, thursday: 4, friday: 5, saturday: 6 };\n start_cycle_settings.weekday = {};\n for (var key in weekday_bits_offset) {\n start_cycle_settings.weekday[key] = readEnableStatus((weekday_data >>> weekday_bits_offset[key]) & 0x01);\n }\n i += 6;\n decoded.timed_system_control_settings.start_cycle_settings = decoded.timed_system_control_settings.start_cycle_settings || [];\n decoded.timed_system_control_settings.start_cycle_settings.push(start_cycle_settings);\n } else if (type === 2) {\n var end_cycle_settings = {};\n end_cycle_settings.index = readUInt8(bytes[i + 1]) + 1;\n end_cycle_settings.enable = readEnableStatus(bytes[i + 2]);\n end_cycle_settings.time = readUInt16LE(bytes.slice(i + 3, i + 5));\n var weekday_data = readUInt8(bytes[i + 5]);\n var week_bits_offset = { sunday: 0, monday: 1, tuesday: 2, wednesday: 3, thursday: 4, friday: 5, saturday: 6 };\n end_cycle_settings.weekday = {};\n for (var key in week_bits_offset) {\n end_cycle_settings.weekday[key] = readEnableStatus((weekday_data >>> week_bits_offset[key]) & 0x01);\n }\n i += 6;\n decoded.timed_system_control_settings.end_cycle_settings = decoded.timed_system_control_settings.end_cycle_settings || [];\n decoded.timed_system_control_settings.end_cycle_settings.push(end_cycle_settings);\n }\n break;\n case 0x8d:\n var data = readUInt8(bytes[i]);\n var unlock_bits_offset = { system_button: 0, temperature_up_button: 1, temperature_down_button: 2, fan_button: 3, temperature_control_mode_button: 4 };\n decoded.temporary_unlock_settings = decoded.temporary_unlock_settings || {};\n for (var key in unlock_bits_offset) {\n decoded.temporary_unlock_settings[key] = readEnableStatus((data >>> unlock_bits_offset[key]) & 0x01);\n }\n decoded.temporary_unlock_settings.duration = readUInt16LE(bytes.slice(i + 1, i + 3));\n i += 3;\n break;\n case 0x8e:\n decoded.temperature_control_with_standby_fan_mode = readTemperatureControlWithStandbyFanMode(bytes[i]);\n i += 1;\n break;\n case 0x8f:\n decoded.valve_opening_negative_valve_mode = readValveOpeningNegativeValveMode(bytes[i]);\n i += 1;\n break;\n case 0x90:\n decoded.relay_changes_report_enable = readEnableStatus(bytes[i]);\n i += 1;\n break;\n\n case 0xc4:\n decoded.auto_provisioning_enable = readEnableStatus(bytes[i]);\n i += 1;\n break;\n case 0xc5:\n decoded.history_transmit_settings = decoded.history_transmit_settings || {};\n var data = readUInt8(bytes[i]);\n if (data === 0x00) {\n decoded.history_transmit_settings.enable = readEnableStatus(bytes[i + 1]);\n i += 2;\n } else if (data === 0x01) {\n decoded.history_transmit_settings.retransmission_interval = readUInt16LE(bytes.slice(i + 1, i + 3));\n i += 3;\n } else if (data === 0x02) {\n decoded.history_transmit_settings.resend_interval = readUInt16LE(bytes.slice(i + 1, i + 3));\n i += 3;\n }\n break;\n case 0xc6:\n decoded.daylight_saving_time = {};\n decoded.daylight_saving_time.enable = readEnableStatus(bytes[i]);\n decoded.daylight_saving_time.offset = readUInt8(bytes[i + 1]);\n decoded.daylight_saving_time.start_month = readUInt8(bytes[i + 2]);\n var start_day_value = readUInt8(bytes[i + 3]);\n decoded.daylight_saving_time.start_week_num = (start_day_value >>> 4) & 0x07;\n decoded.daylight_saving_time.start_week_day = start_day_value & 0x0f;\n decoded.daylight_saving_time.start_hour_min = readUInt16LE(bytes.slice(i + 4, i + 6));\n decoded.daylight_saving_time.end_month = readUInt8(bytes[i + 6]);\n var end_day_value = readUInt8(bytes[i + 7]);\n decoded.daylight_saving_time.end_week_num = (end_day_value >>> 4) & 0x0f;\n decoded.daylight_saving_time.end_week_day = end_day_value & 0x0f;\n decoded.daylight_saving_time.end_hour_min = readUInt16LE(bytes.slice(i + 8, i + 10));\n i += 10;\n break;\n case 0xc7:\n decoded.time_zone = readTimeZone(readInt16LE(bytes.slice(i, i + 2)));\n i += 2;\n break;\n\n // services\n case 0xb6:\n decoded.reconnect = readYesNoStatus(1);\n break;\n case 0xb8:\n decoded.synchronize_time = readYesNoStatus(1);\n break;\n case 0xb9:\n decoded.query_device_status = readYesNoStatus(1);\n break;\n case 0xba:\n decoded.fetch_history = decoded.fetch_history || {};\n decoded.fetch_history.start_time = readUInt32LE(bytes.slice(i, i + 4));\n i += 4;\n break;\n case 0xbb:\n decoded.fetch_history = decoded.fetch_history || {};\n decoded.fetch_history.start_time = readUInt32LE(bytes.slice(i, i + 4));\n decoded.fetch_history.end_time = readUInt32LE(bytes.slice(i + 4, i + 8));\n i += 8;\n break;\n case 0xbc:\n decoded.stop_transmit_history = readYesNoStatus(1);\n break;\n case 0xbd:\n decoded.clear_history = readYesNoStatus(1);\n break;\n case 0xbe:\n decoded.reboot = readYesNoStatus(1);\n break;\n case 0x5b:\n decoded.temperature = readInt16LE(bytes.slice(i, i + 2)) / 100;\n i += 2;\n break;\n case 0x5c:\n decoded.humidity = readInt16LE(bytes.slice(i, i + 2)) / 10;\n i += 2;\n break;\n case 0x5d:\n decoded.opening_window_alarm = readOpenWindowAlarm(bytes[i]);\n i += 1;\n break;\n case 0x5e:\n decoded.insert_plan_id = readUInt8(bytes[i]) + 1;\n i += 1;\n break;\n case 0x5f:\n decoded.clear_plan = decoded.clear_plan || {};\n var plan_data = readUInt8(bytes[i]);\n var plan_offset = { 0: \"plan_1\", 1: \"plan_2\", 2: \"plan_3\", 3: \"plan_4\", 4: \"plan_5\", 5: \"plan_6\", 6: \"plan_7\", 7: \"plan_8\", 8: \"plan_9\", 9: \"plan_10\", 10: \"plan_11\", 11: \"plan_12\", 12: \"plan_13\", 13: \"plan_14\", 14: \"plan_15\", 15: \"plan_16\", 255: \"reset\" };\n decoded.clear_plan[plan_offset[plan_data]] = readYesNoStatus(1);\n i += 1;\n break;\n\n // control frame\n case 0xef:\n var cmd_data = readUInt8(bytes[i]);\n var cmd_result = (cmd_data >>> 4) & 0x0f;\n var cmd_length = cmd_data & 0x0f;\n var cmd_id = readHexString(bytes.slice(i + 1, i + 1 + cmd_length));\n var cmd_header = readHexString(bytes.slice(i + 1, i + 2));\n i += 1 + cmd_length;\n\n var response = {};\n response.result = readCmdResult(cmd_result);\n response.cmd_id = cmd_id;\n response.cmd_name = readCmdName(cmd_header);\n\n decoded.request_result = decoded.request_result || [];\n decoded.request_result.push(response);\n break;\n case 0xfe:\n decoded.frame = readUInt8(bytes[i]);\n i += 1;\n break;\n default:\n unknown_command = 1;\n break;\n }\n\n if (unknown_command) {\n throw new Error(\"unknown command: \" + command_id);\n }\n }\n\n return decoded;\n}\n\nfunction readProtocolVersion(bytes) {\n var major = bytes[0] & 0xff;\n var minor = bytes[1] & 0xff;\n return \"v\" + major + \".\" + minor;\n}\n\nfunction readHardwareVersion(bytes) {\n var major = bytes[0] & 0xff;\n var minor = bytes[1] & 0xff;\n return \"v\" + major + \".\" + minor;\n}\n\nfunction readFirmwareVersion(bytes) {\n var major = bytes[0] & 0xff;\n var minor = bytes[1] & 0xff;\n var release = bytes[2] & 0xff;\n var alpha = bytes[3] & 0xff;\n var unit_test = bytes[4] & 0xff;\n var test = bytes[5] & 0xff;\n\n var version = \"v\" + major + \".\" + minor;\n if (release !== 0) version += \"-r\" + release;\n if (alpha !== 0) version += \"-a\" + alpha;\n if (unit_test !== 0) version += \"-u\" + unit_test;\n if (test !== 0) version += \"-t\" + test;\n return version;\n}\n\nfunction readDeviceStatus(type) {\n var device_status_map = { 0: \"off\", 1: \"on\" };\n return getValue(device_status_map, type);\n}\n\nfunction readLoRaWANClass(type) {\n var lorawan_class_map = {\n 0: \"Class A\",\n 1: \"Class B\",\n 2: \"Class C\",\n 3: \"Class CtoB\",\n };\n return getValue(lorawan_class_map, type);\n}\n\nfunction readYesNoStatus(type) {\n var yes_no_map = { 0: \"no\", 1: \"yes\" };\n return getValue(yes_no_map, type);\n}\n\nfunction readEnableStatus(status) {\n var status_map = { 0: \"disable\", 1: \"enable\" };\n return getValue(status_map, status);\n}\n\nfunction readTemperatureDataSource(type) {\n var source_map = { 0: \"internal\", 1: \"ntc\", 2: \"lorawan\", 3: \"d2d\" };\n return getValue(source_map, type);\n}\n\nfunction readMissingDataAction(type) {\n var action_map = { 0: \"hold\", 1: \"off_or_fan_control\", 2: \"switch_to_internal\" };\n return getValue(action_map, type);\n}\n\nfunction readTemperatureControlStatus(type) {\n var status_map = { 0: \"standby\", 1: \"heating\", 2: \"cooling\" };\n return getValue(status_map, type);\n}\n\nfunction readTemperatureControlMode(type) {\n var mode_map = { 0: \"fan\", 1: \"heating\", 2: \"cooling\" };\n return getValue(mode_map, type);\n}\n\nfunction readValveStatus(type) {\n var status_map = { 0: \"off\", 100: \"on\" };\n return getValue(status_map, type);\n}\n\nfunction readFanMode(type) {\n var mode_map = { 0: \"auto\", 1: \"low\", 2: \"medium\", 3: \"high\" };\n return getValue(mode_map, type);\n}\n\nfunction readPlanId(type) {\n var plan_id_map = { 0: \"plan_1\", 1: \"plan_2\", 2: \"plan_3\", 3: \"plan_4\", 4: \"plan_5\", 5: \"plan_6\", 6: \"plan_7\", 7: \"plan_8\", 8: \"plan_9\", 9: \"plan_10\", 10: \"plan_11\", 11: \"plan_12\", 12: \"plan_13\", 13: \"plan_14\", 14: \"plan_15\", 15: \"plan_16\", 255: \"no_plan\" };\n return getValue(plan_id_map, type);\n}\n\nfunction readFanStatus(type) {\n var status_map = { 0: \"off\", 1: \"low\", 2: \"medium\", 3: \"high\" };\n return getValue(status_map, type);\n}\n\nfunction readTemperatureAlarmType(type) {\n var type_map = {\n 0: \"collection error\", // 0x00\n 1: \"lower range error\", // 0x01\n 2: \"over range error\", // 0x02\n 3: \"no data\", // 0x03\n 16: \"below threshold temperature alarm release\", // 0x10\n 17: \"below threshold temperature alarm\", // 0x11\n 18: \"above threshold temperature alarm release\", // 0x12\n 19: \"above threshold temperature alarm\", // 0x13\n 20: \"between threshold temperature alarm release\", // 0x14\n 21: \"between threshold temperature alarm\", // 0x15\n 22: \"outside threshold temperature alarm release\", // 0x16\n 23: \"outside threshold temperature alarm\", // 0x17\n 32: \"continuous low temperature alarm release\", // 0x20\n 33: \"continuous low temperature alarm\", // 0x21\n 34: \"continuous high temperature alarm release\", // 0x22\n 35: \"continuous high temperature alarm\", // 0x23\n 48: \"freeze alarm release\", // 0x30\n 49: \"freeze alarm\", // 0x31\n 50: \"window open alarm release\", // 0x32\n 51: \"window open alarm\", // 0x33\n };\n return getValue(type_map, type);\n}\n\nfunction hasTemperature(alarm_type) {\n return alarm_type === 0x10 // (below threshold) temperature alarm release\n || alarm_type === 0x11 // (below threshold) temperature alarm\n || alarm_type === 0x12 // (above threshold) temperature alarm release\n || alarm_type === 0x13 // (above threshold) temperature alarm\n || alarm_type === 0x14 // (between threshold) continuous temperature alarm release\n || alarm_type === 0x15 // (between threshold) continuous temperature alarm\n || alarm_type === 0x16 // (outside threshold) continuous temperature alarm release\n || alarm_type === 0x17 // (outside threshold) continuous temperature alarm\n || alarm_type === 0x20 // continuous low temperature alarm release\n || alarm_type === 0x21 // continuous low temperature alarm\n || alarm_type === 0x22 // continuous high temperature alarm release\n || alarm_type === 0x23 // continuous high temperature alarm\n || alarm_type === 0x30 // freeze alarm release\n || alarm_type === 0x31 // freeze alarm\n || alarm_type === 0x32 // window open alarm release\n || alarm_type === 0x33 // window open alarm\n}\n\nfunction readHumidityAlarm(type) {\n var type_map = {\n 0: \"collection error\", // 0x00\n 1: \"lower range error\", // 0x01\n 2: \"over range error\", // 0x02\n 3: \"no data\", // 0x03\n };\n return getValue(type_map, type);\n}\n\nfunction readTargetTemperatureAlarm(type) {\n var type_map = {\n 3: \"no data\", // 0x03\n };\n return getValue(type_map, type);\n}\n\nfunction readTimeUnitType(type) {\n var unit_map = { 0: \"second\", 1: \"minute\" };\n return getValue(unit_map, type);\n}\n\nfunction readTemperatureUnit(type) {\n var unit_map = { 0: \"celsius\", 1: \"fahrenheit\" };\n return getValue(unit_map, type);\n}\n\nfunction readSupportMode(type) {\n var mode_map = { 3: \"fan_and_heating\", 5: \"fan_and_cooling\", 7: \"fan_and_heating_and_cooling\" };\n return getValue(mode_map, type);\n}\n\nfunction readSystemStatus(type) {\n var status_map = { 0: \"off\", 1: \"on\" };\n return getValue(status_map, type);\n}\n\nfunction readTargetTemperatureResolution(type) {\n var resolution_map = { 0: 0.5, 1: 1 };\n return getValue(resolution_map, type);\n}\n\nfunction readMathConditionType(type) {\n var condition_map = { 0: \"disable\", 1: \"below\", 2: \"above\", 3: \"between\", 4: \"outside\" };\n return getValue(condition_map, type);\n}\n\nfunction readValveInterfaceMode(type) {\n var mode_map = { 0: \"four_pipe_two_wire\", 1: \"two_pipe_two_wire\", 2: \"two_pipe_three_wire\" };\n return getValue(mode_map, type);\n}\n\nfunction readValve(type) {\n var valve_map = { 0: \"valve_1\", 1: \"valve_2\" };\n return getValue(valve_map, type);\n}\n\nfunction readDIType(type) {\n var type_map = { 0: \"card_control\", 1: \"magnet_detection\" };\n return getValue(type_map, type);\n}\n\nfunction readMagnetDetectionMode(type) {\n var mode_map = { 0: \"normally_close\", 1: \"normally_open\" };\n return getValue(mode_map, type);\n}\n\nfunction readCardControlMode(type) {\n var mode_map = { 0: \"power\", 1: \"plan\" };\n return getValue(mode_map, type);\n}\n\nfunction readWindowOpeningDetectionType(type) {\n var type_map = { 0: \"temperature_detection\", 1: \"magnet_detection\" };\n return getValue(type_map, type);\n}\n\nfunction readD2DTriggerSource(type) {\n var source_map = { 0: \"plan_1\", 1: \"plan_2\", 2: \"plan_3\", 3: \"plan_4\", 4: \"plan_5\", 5: \"plan_6\", 6: \"plan_7\", 7: \"plan_8\", 8: \"plan_9\", 9: \"plan_10\", 10: \"plan_11\", 11: \"plan_12\", 12: \"plan_13\", 14: \"plan_15\", 15: \"plan_16\", 16: \"system_status_off\", 17: \"system_status_on\" };\n return getValue(source_map, type);\n}\n\nfunction readOpenWindowAlarm(type) {\n var alarm_map = { 0: \"release\", 1: \"trigger\" };\n return getValue(alarm_map, type);\n}\n\nfunction readD2DTriggerTarget(type) {\n var trigger_target_map = { 0: \"plan_1\", 1: \"plan_2\", 2: \"plan_3\", 3: \"plan_4\", 4: \"plan_5\", 5: \"plan_6\", 6: \"plan_7\", 7: \"plan_8\", 8: \"plan_9\", 9: \"plan_10\", 10: \"plan_11\", 11: \"plan_12\", 12: \"plan_13\", 14: \"plan_15\", 15: \"plan_16\", 16: \"system_status_off\", 17: \"system_status_on\" };\n return getValue(trigger_target_map, type);\n}\n\nfunction readTemperatureControlWithStandbyFanMode(type) {\n var mode_map = { 0: \"low\", 1: \"stop\" };\n return getValue(mode_map, type);\n}\n\nfunction readValveOpeningNegativeValveMode(type) {\n var mode_map = { 0: \"low\", 1: \"stop\" };\n return getValue(mode_map, type);\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 readCmdResult(type) {\n var result_map = { 0: \"success\", 1: \"parsing error\", 2: \"order error\", 3: \"password error\", 4: \"read params error\", 5: \"write params error\", 6: \"read execution error\", 7: \"write execution error\", 8: \"read apply error\", 9: \"write apply error\", 10: \"associative error\" };\n return getValue(result_map, type);\n}\n\nfunction readCmdName(type) {\n var name_map = {\n \"60\": { \"level\": 1, \"name\": \"collection_interval\" },\n \"62\": { \"level\": 1, \"name\": \"reporting_interval\" },\n \"63\": { \"level\": 1, \"name\": \"temperature_unit\" },\n \"64\": { \"level\": 1, \"name\": \"support_mode\" },\n \"65\": { \"level\": 1, \"name\": \"intelligent_display_enable\" },\n \"66\": { \"level\": 1, \"name\": \"screen_object_settings\" },\n \"67\": { \"level\": 1, \"name\": \"system_status\" },\n \"68\": { \"level\": 1, \"name\": \"temperature_control_mode\" },\n \"69\": { \"level\": 1, \"name\": \"target_temperature_resolution\" },\n \"6a\": { \"level\": 1, \"name\": \"target_temperature_tolerance\" },\n \"6b\": { \"level\": 1, \"name\": \"heating_target_temperature\" },\n \"6c\": { \"level\": 1, \"name\": \"cooling_target_temperature\" },\n \"6d\": { \"level\": 1, \"name\": \"heating_target_temperature_range\" },\n \"6e\": { \"level\": 1, \"name\": \"cooling_target_temperature_range\" },\n \"6f\": { \"level\": 1, \"name\": \"dehumidify_config\" },\n \"70\": { \"level\": 1, \"name\": \"target_humidity_range\" },\n \"72\": { \"level\": 1, \"name\": \"fan_mode\" },\n \"73\": { \"level\": 1, \"name\": \"fan_speed_config\" },\n \"74\": { \"level\": 1, \"name\": \"fan_delay_config\" },\n \"75\": { \"level\": 1, \"name\": \"child_lock_settings\" },\n \"76\": { \"level\": 1, \"name\": \"temperature_alarm_settings\" },\n \"77\": { \"level\": 1, \"name\": \"high_temperature_alarm_settings\" },\n \"78\": { \"level\": 1, \"name\": \"low_temperature_alarm_settings\" },\n \"79\": { \"level\": 1, \"name\": \"temperature_calibration_settings\" },\n \"7a\": { \"level\": 1, \"name\": \"humidity_calibration_settings\" },\n \"7b\": { \"level\": 3, \"name\": \"plan_config\" },\n \"7c\": { \"level\": 1, \"name\": \"valve_interface_settings\" },\n \"80\": { \"level\": 1, \"name\": \"di_setting_enable\" },\n \"81\": { \"level\": 1, \"name\": \"di_settings\" },\n \"82\": { \"level\": 1, \"name\": \"window_opening_detection_enable\" },\n \"83\": { \"level\": 1, \"name\": \"window_opening_detection_settings\" },\n \"84\": { \"level\": 1, \"name\": \"freeze_protection_settings\" },\n \"85\": { \"level\": 1, \"name\": \"temperature_source_settings\" },\n \"86\": { \"level\": 1, \"name\": \"d2d_pairing_enable\" },\n \"87\": { \"level\": 3, \"name\": \"d2d_pairing_settings\" },\n \"88\": { \"level\": 1, \"name\": \"d2d_master_enable\" },\n \"89\": { \"level\": 2, \"name\": \"d2d_master_settings\" },\n \"8a\": { \"level\": 1, \"name\": \"d2d_slave_enable\" },\n \"8b\": { \"level\": 2, \"name\": \"d2d_slave_settings\" },\n \"8c\": { \"level\": 3, \"name\": \"timed_system_control_settings\" },\n \"8d\": { \"level\": 1, \"name\": \"temporary_unlock_settings\" },\n \"8e\": { \"level\": 1, \"name\": \"temperature_control_with_standby_fan_mode\" },\n \"8f\": { \"level\": 1, \"name\": \"valve_opening_negative_valve_mode\" },\n \"90\": { \"level\": 1, \"name\": \"relay_changes_report_enable\" },\n \"c4\": { \"level\": 1, \"name\": \"auto_provisioning_enable\" },\n \"c5\": { \"level\": 1, \"name\": \"history_transmit_settings\" },\n \"c6\": { \"level\": 1, \"name\": \"daylight_saving_time\" },\n \"c7\": { \"level\": 1, \"name\": \"time_zone\" },\n \"b6\": { \"level\": 0, \"name\": \"reconnect\" },\n \"b8\": { \"level\": 0, \"name\": \"synchronize_time\" },\n \"b9\": { \"level\": 0, \"name\": \"query_device_status\" },\n \"ba\": { \"level\": 0, \"name\": \"fetch_history\" },\n \"bb\": { \"level\": 0, \"name\": \"fetch_history\" },\n \"bc\": { \"level\": 0, \"name\": \"stop_transmit_history\" },\n \"bd\": { \"level\": 0, \"name\": \"clear_history\" },\n \"be\": { \"level\": 0, \"name\": \"reboot\" },\n \"5b\": { \"level\": 0, \"name\": \"temperature\" },\n \"5c\": { \"level\": 0, \"name\": \"humidity\" },\n \"5d\": { \"level\": 0, \"name\": \"opening_window_alarm\" },\n \"5e\": { \"level\": 0, \"name\": \"insert_plan_id\" },\n \"5f\": { \"level\": 0, \"name\": \"clear_plan\" },\n }\n\n var data = name_map[type];\n if (data === undefined) return \"unknown\";\n return data.name;\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 readFloat16LE(bytes) {\n var bits = (bytes[1] << 8) | bytes[0];\n var sign = bits >>> 15 === 0 ? 1.0 : -1.0;\n var e = (bits >>> 10) & 0x1f;\n var m = e === 0 ? (bits & 0x3ff) << 1 : (bits & 0x3ff) | 0x400;\n var f = sign * m * Math.pow(2, e - 25);\n\n var n = Number(f.toFixed(2));\n return n;\n}\n\nfunction readFloatLE(bytes) {\n var bits = (bytes[3] << 24) | (bytes[2] << 16) | (bytes[1] << 8) | bytes[0];\n var sign = bits >>> 31 === 0 ? 1.0 : -1.0;\n var e = (bits >>> 23) & 0xff;\n var m = e === 0 ? (bits & 0x7fffff) << 1 : (bits & 0x7fffff) | 0x800000;\n var f = sign * m * Math.pow(2, e - 150);\n return f;\n}\n\nfunction readString(bytes) {\n var str = \"\";\n var i = 0;\n var byte1, byte2, byte3, byte4;\n while (i < bytes.length) {\n byte1 = bytes[i++];\n if (byte1 <= 0x7f) {\n str += String.fromCharCode(byte1);\n } else if (byte1 <= 0xdf) {\n byte2 = bytes[i++];\n str += String.fromCharCode(((byte1 & 0x1f) << 6) | (byte2 & 0x3f));\n } else if (byte1 <= 0xef) {\n byte2 = bytes[i++];\n byte3 = bytes[i++];\n str += String.fromCharCode(((byte1 & 0x0f) << 12) | ((byte2 & 0x3f) << 6) | (byte3 & 0x3f));\n } else if (byte1 <= 0xf7) {\n byte2 = bytes[i++];\n byte3 = bytes[i++];\n byte4 = bytes[i++];\n var codepoint = ((byte1 & 0x07) << 18) | ((byte2 & 0x3f) << 12) | ((byte3 & 0x3f) << 6) | (byte4 & 0x3f);\n codepoint -= 0x10000;\n str += String.fromCharCode((codepoint >> 10) + 0xd800);\n str += String.fromCharCode((codepoint & 0x3ff) + 0xdc00);\n }\n }\n return str;\n}\n\nfunction readHexString(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 readHexStringLE(bytes) {\n var temp = [];\n for (var idx = bytes.length - 1; idx >= 0; idx--) {\n temp.push((\"0\" + (bytes[idx] & 0xff).toString(16)).slice(-2));\n }\n return temp.join(\"\");\n}\n\nfunction getValue(map, key) {\n if (RAW_VALUE) return key;\n var value = map[key];\n if (!value) value = \"unknown\";\n return value;\n}",
"environment": "javascript",
"storage": "",
"version": "1.0"
},
"flows": {
"milesight_wt304_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,
"enableExtraTextColor": false,
"enableIconColor": false,
"enableIconSize": false,
"extraText": "",
"extraTextColor": "#1E313E",
"extraTextColorConditions": [],
"extraTextConditions": [],
"extraTextPosition": "above-value",
"extraTextSize": "18px",
"extraTextWeight": "font-light",
"icon": "",
"iconColor": "#1E313E",
"iconColorConditions": [],
"iconConditions": [],
"iconGap": "8px",
"iconPosition": "before-value",
"iconSize": "65px",
"iconVerticalOffset": "0px",
"link": "",
"textAlign": "center",
"textColor": "#1E313E",
"textColorConditions": [],
"textSize": "65px",
"textWeight": "font-light",
"unit": "ºC",
"unitSize": "18px"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "milesight_wt304_data",
"mapping": "temperature",
"tags": {
"device": [],
"group": []
}
},
"color": "#d1311f",
"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": "Humidity"
},
"properties": {
"decimalPlaces": 1,
"enableExtraTextColor": false,
"enableIconColor": false,
"enableIconSize": false,
"extraText": "",
"extraTextColor": "#1E313E",
"extraTextColorConditions": [],
"extraTextConditions": [],
"extraTextPosition": "above-value",
"extraTextSize": "18px",
"extraTextWeight": "font-light",
"icon": "",
"iconColor": "#1E313E",
"iconColorConditions": [],
"iconConditions": [],
"iconGap": "8px",
"iconPosition": "before-value",
"iconSize": "65px",
"iconVerticalOffset": "0px",
"link": "",
"textAlign": "center",
"textColor": "#1E313E",
"textColorConditions": [],
"textSize": "65px",
"textWeight": "font-light",
"unit": "%",
"unitSize": "18px"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "milesight_wt304_data",
"mapping": "humidity",
"tags": {
"device": [],
"group": []
}
},
"color": "#329fcd",
"name": "Humidity",
"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": "Target Temperature"
},
"properties": {
"decimalPlaces": 1,
"enableExtraTextColor": false,
"enableIconColor": false,
"enableIconSize": false,
"extraText": "",
"extraTextColor": "#1E313E",
"extraTextColorConditions": [],
"extraTextConditions": [],
"extraTextPosition": "above-value",
"extraTextSize": "18px",
"extraTextWeight": "font-light",
"icon": "",
"iconColor": "#1E313E",
"iconColorConditions": [],
"iconConditions": [],
"iconGap": "8px",
"iconPosition": "before-value",
"iconSize": "65px",
"iconVerticalOffset": "0px",
"link": "",
"textAlign": "center",
"textColor": "#1E313E",
"textColorConditions": [],
"textSize": "65px",
"textWeight": "font-light",
"unit": "ºC",
"unitSize": "18px"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "milesight_wt304_data",
"mapping": "target_temperature",
"tags": {
"device": [],
"group": []
}
},
"color": "#f39c12",
"name": "Target Temperature",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "text"
},
{
"layout": {
"col": 0,
"row": 5,
"sizeX": 6,
"sizeY": 10
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "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 },\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": [
{
"aggregation": {},
"bucket": {
"backend": "mongodb",
"id": "milesight_wt304_data",
"mapping": "temperature",
"tags": {
"device": [],
"group": []
}
},
"color": "#d1311f",
"name": "Temperature",
"source": "bucket",
"timespan": {
"magnitude": "hour",
"mode": "relative",
"period": "latest",
"value": 24
}
},
{
"aggregation": {},
"bucket": {
"backend": "mongodb",
"id": "milesight_wt304_data",
"mapping": "humidity",
"tags": {
"device": [],
"group": []
}
},
"color": "#329fcd",
"name": "Humidity",
"source": "bucket",
"timespan": {
"magnitude": "hour",
"mode": "relative",
"period": "latest",
"value": 24
}
}
],
"type": "apex_charts"
},
{
"layout": {
"col": 0,
"row": 15,
"sizeX": 2,
"sizeY": 5
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "Temperature Control"
},
"properties": {
"decimalPlaces": 0,
"enableExtraTextColor": false,
"enableIconColor": false,
"enableIconSize": false,
"extraText": "Status",
"extraTextColor": "#7f8c8d",
"extraTextColorConditions": [],
"extraTextConditions": [],
"extraTextPosition": "above-value",
"extraTextSize": "14px",
"extraTextWeight": "font-light",
"icon": "",
"iconColor": "#1E313E",
"iconColorConditions": [],
"iconConditions": [],
"iconGap": "8px",
"iconPosition": "above-value",
"iconSize": "50px",
"iconVerticalOffset": "0px",
"link": "",
"textAlign": "center",
"textColor": "#1E313E",
"textColorConditions": [],
"textSize": "28px",
"textWeight": "font-light",
"unit": "",
"unitSize": "18px"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "milesight_wt304_data",
"mapping": "temperature_control_status",
"tags": {
"device": [],
"group": []
}
},
"color": "#e74c3c",
"name": "Control Status",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "text"
},
{
"layout": {
"col": 2,
"row": 15,
"sizeX": 2,
"sizeY": 5
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "Temperature Control Mode"
},
"properties": {
"decimalPlaces": 0,
"enableExtraTextColor": false,
"enableIconColor": false,
"enableIconSize": false,
"extraText": "Mode",
"extraTextColor": "#7f8c8d",
"extraTextColorConditions": [],
"extraTextConditions": [],
"extraTextPosition": "above-value",
"extraTextSize": "14px",
"extraTextWeight": "font-light",
"icon": "",
"iconColor": "#1E313E",
"iconColorConditions": [],
"iconConditions": [],
"iconGap": "8px",
"iconPosition": "above-value",
"iconSize": "50px",
"iconVerticalOffset": "0px",
"link": "",
"textAlign": "center",
"textColor": "#1E313E",
"textColorConditions": [],
"textSize": "28px",
"textWeight": "font-light",
"unit": "",
"unitSize": "18px"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "milesight_wt304_data",
"mapping": "temperature_control_mode",
"tags": {
"device": [],
"group": []
}
},
"color": "#9b59b6",
"name": "Control Mode",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "text"
},
{
"layout": {
"col": 4,
"row": 15,
"sizeX": 2,
"sizeY": 5
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "Fan Mode"
},
"properties": {
"decimalPlaces": 0,
"enableExtraTextColor": false,
"enableIconColor": false,
"enableIconSize": false,
"extraText": "Mode",
"extraTextColor": "#7f8c8d",
"extraTextColorConditions": [],
"extraTextConditions": [],
"extraTextPosition": "above-value",
"extraTextSize": "14px",
"extraTextWeight": "font-light",
"icon": "",
"iconColor": "#1E313E",
"iconColorConditions": [],
"iconConditions": [],
"iconGap": "8px",
"iconPosition": "above-value",
"iconSize": "50px",
"iconVerticalOffset": "0px",
"link": "",
"textAlign": "center",
"textColor": "#1E313E",
"textColorConditions": [],
"textSize": "28px",
"textWeight": "font-light",
"unit": "",
"unitSize": "18px"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "milesight_wt304_data",
"mapping": "fan_mode",
"tags": {
"device": [],
"group": []
}
},
"color": "#16a085",
"name": "Fan Mode",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "text"
},
{
"layout": {
"col": 0,
"row": 20,
"sizeX": 2,
"sizeY": 5
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "Fan Status"
},
"properties": {
"decimalPlaces": 0,
"enableExtraTextColor": false,
"enableIconColor": false,
"enableIconSize": false,
"extraText": "Status",
"extraTextColor": "#7f8c8d",
"extraTextColorConditions": [],
"extraTextConditions": [],
"extraTextPosition": "above-value",
"extraTextSize": "14px",
"extraTextWeight": "font-light",
"icon": "",
"iconColor": "#1E313E",
"iconColorConditions": [],
"iconConditions": [],
"iconGap": "8px",
"iconPosition": "above-value",
"iconSize": "50px",
"iconVerticalOffset": "0px",
"link": "",
"textAlign": "center",
"textColor": "#1E313E",
"textColorConditions": [],
"textSize": "28px",
"textWeight": "font-light",
"unit": "",
"unitSize": "18px"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "milesight_wt304_data",
"mapping": "fan_status",
"tags": {
"device": [],
"group": []
}
},
"color": "#27ae60",
"name": "Fan Status",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "text"
},
{
"layout": {
"col": 2,
"row": 20,
"sizeX": 2,
"sizeY": 5
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "Valve Status"
},
"properties": {
"decimalPlaces": 0,
"enableExtraTextColor": false,
"enableIconColor": false,
"enableIconSize": false,
"extraText": "Status",
"extraTextColor": "#7f8c8d",
"extraTextColorConditions": [],
"extraTextConditions": [],
"extraTextPosition": "above-value",
"extraTextSize": "14px",
"extraTextWeight": "font-light",
"icon": "",
"iconColor": "#1E313E",
"iconColorConditions": [],
"iconConditions": [],
"iconGap": "8px",
"iconPosition": "above-value",
"iconSize": "50px",
"iconVerticalOffset": "0px",
"link": "",
"textAlign": "center",
"textColor": "#1E313E",
"textColorConditions": [],
"textSize": "28px",
"textWeight": "font-light",
"unit": "",
"unitSize": "18px"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "milesight_wt304_data",
"mapping": "valve_status",
"tags": {
"device": [],
"group": []
}
},
"color": "#2980b9",
"name": "Valve Status",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "text"
},
{
"layout": {
"col": 4,
"row": 20,
"sizeX": 2,
"sizeY": 5
},
"panel": {
"color": "#ffffff",
"currentColor": "#ffffff",
"showOffline": {
"type": "none"
},
"title": "System Status"
},
"properties": {
"decimalPlaces": 0,
"enableExtraTextColor": false,
"enableIconColor": false,
"enableIconSize": false,
"extraText": "System",
"extraTextColor": "#7f8c8d",
"extraTextColorConditions": [],
"extraTextConditions": [],
"extraTextPosition": "above-value",
"extraTextSize": "14px",
"extraTextWeight": "font-light",
"icon": "",
"iconColor": "#1E313E",
"iconColorConditions": [],
"iconConditions": [],
"iconGap": "8px",
"iconPosition": "above-value",
"iconSize": "50px",
"iconVerticalOffset": "0px",
"link": "",
"textAlign": "center",
"textColor": "#1E313E",
"textColorConditions": [],
"textSize": "28px",
"textWeight": "font-light",
"unit": "",
"unitSize": "18px"
},
"sources": [
{
"bucket": {
"backend": "mongodb",
"id": "milesight_wt304_data",
"mapping": "system_status",
"tags": {
"device": [],
"group": []
}
},
"color": "#34495e",
"name": "System Status",
"source": "bucket",
"timespan": {
"mode": "latest"
}
}
],
"type": "text"
}
]
}
]
}
}
]
}
}
]
}
}