local device = {} device.model = "SMKG-2KNL-SD" device.vendor = "Tuya" device.description = "Smart leakage protector 63a with leakage monitoring" device.exposes = { { type = "switch", features = { { type = "binary", name = "state", property = "state", access = 3, value_on = "ON", value_off = "OFF", description = "On/off state of the switch", }, }, }, { type = "numeric", name = "voltage", property = "voltage", access = 1, unit = "V", description = "Measured electrical potential value", }, { type = "numeric", name = "current", property = "current", access = 1, unit = "A", description = "Instantaneous measured electrical current", }, { type = "numeric", name = "power", property = "power", access = 1, unit = "W", description = "Instantaneous measured power", }, { type = "numeric", name = "energy", property = "energy", access = 1, unit = "kWh", description = "Sum of consumed energy", }, { type = "numeric", name = "temperature", property = "temperature", access = 1, unit = "°C", description = "Measured temperature value", }, { type = "numeric", name = "leakage_current", property = "leakage_current", access = 1, unit = "mA", description = "Real-time leakage current (DP 53)", }, { type = "numeric", name = "over_voltage_threshold", property = "over_voltage_threshold", access = 3, unit = "V", min = 220, max = 265, }, { type = "numeric", name = "under_voltage_threshold", property = "under_voltage_threshold", access = 3, unit = "V", min = 76, max = 240, }, { type = "numeric", name = "over_current_threshold", property = "over_current_threshold", access = 3, unit = "A", min = 1, max = 63, }, { type = "numeric", name = "leakage_threshold", property = "leakage_threshold", access = 3, unit = "mA", min = 10, max = 100, }, { type = "numeric", name = "temp_threshold", property = "temp_threshold", access = 3, unit = "°C", min = 40, max = 150, }, { type = "numeric", name = "fault_code", property = "fault_code", access = 1, description = "0 = OK", }, } device.fromZigbee = { "electrical", "metering", "temperature" } device.tuyaDatapoints = { { dp = 1, name = "state", converter = "onOff" }, { dp = 20, name = "voltage", converter = "divideBy10" }, { dp = 18, name = "current", converter = "divideBy100" }, { dp = 19, name = "power", converter = "divideBy10" }, { dp = 17, name = "energy", converter = "divideBy100" }, { dp = 47, name = "temperature", converter = "raw" }, { dp = 53, name = "leakage_current", converter = "raw" }, { dp = 41, name = "leakage_threshold", converter = "raw" }, { dp = 42, name = "over_voltage_threshold", converter = "raw" }, { dp = 43, name = "under_voltage_threshold", converter = "raw" }, { dp = 44, name = "over_current_threshold", converter = "raw" }, { dp = 45, name = "temp_threshold", converter = "raw" }, { dp = 9, name = "fault_code", converter = "raw" }, } device.configure = { bind = { "haElectricalMeasurement", "seMetering", "msTemperatureMeasurement" }, reporting = { { cluster = "haElectricalMeasurement", attribute = "activePower", min = 5, max = 3600, change = 1, }, { cluster = "haElectricalMeasurement", attribute = "rmsVoltage", min = 5, max = 3600, change = 5, }, { cluster = "haElectricalMeasurement", attribute = "rmsCurrent", min = 5, max = 3600, change = 100, }, { cluster = "seMetering", attribute = "currentSummDelivered", min = 5, max = 3600, change = 1, }, { cluster = "msTemperatureMeasurement", attribute = "measuredValue", min = 10, max = 3600, change = 100, }, }, } device.fingerprint = { { model = "TS0601", manufacturer = "_TZE284_5m4nchbm", }, } return device