local device = {} device.model = "QASZP" device.vendor = "QA" device.description = "Power sensor" device.exposes = { { 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 = "reactive_power_threshold", property = "reactive_power_threshold", access = 3, unit = "W", min = 3, max = 30, value_step = 0.1, description = "Reactive power threshold. Switch turns on when real power exceeds this value", }, { type = "numeric", name = "max_effective_power", property = "max_effective_power", access = 3, unit = "W", min = 0, max = 4800, description = "Maximum effective power supported", }, { type = "enum", name = "status_report", property = "status_report", access = 3, description = "Enable threshold monitoring", values = { "ON", "OFF" }, }, { type = "enum", name = "switch_status", property = "switch_status", access = 1, description = "Switch status", values = { "ON", "OFF" }, }, } device.fromZigbee = { "electrical", "metering" } device.tuyaDatapoints = { { dp = 17, name = "energy", converter = "divideBy1000" }, { dp = 18, name = "current", converter = "divideBy1000" }, { dp = 19, name = "power", converter = "divideBy10" }, { dp = 20, name = "voltage", converter = "divideBy10" }, { dp = 101, name = "reactive_power_threshold", converter = "divideBy10" }, { dp = 102, name = "max_effective_power", converter = "divideBy10" }, { dp = 104, name = "status_report", converter = "onOff" }, { dp = 105, name = "switch_status", converter = "onOff" }, } device.configure = { bind = { "haElectricalMeasurement", "seMetering" }, 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, }, }, } device.fingerprint = { { model = "TS011F", manufacturer = "_TZ3218_kwht8j5m", }, } return device