local device = {} device.model = "ZG-223Z" device.vendor = "HOBEIAN" device.description = "Rainwater detection sensor" device.zigbeeModel = { "ZG-223Z" } device.exposes = { { type = "enum", name = "rainwater", property = "rainwater", access = 1, description = "Sensor rainwater status", values = { "none", "raining" }, }, { type = "numeric", name = "illuminance", property = "illuminance", access = 1, unit = "lx", description = "Measured illuminance", }, { type = "numeric", name = "sensitivity", property = "sensitivity", access = 3, min = 0, max = 9, value_step = 1, description = "The larger the value, the more sensitive it is (refresh and update only while active)", }, { type = "numeric", name = "illuminance_sampling", property = "illuminance_sampling", access = 3, unit = "minutes", min = 1, max = 480, value_step = 1, description = "Brightness acquisition interval (refresh and update only while active)", }, { type = "numeric", name = "battery", property = "battery", access = 1, unit = "%", min = 0, max = 100, description = "Remaining battery in %, can take up to 24 hours before reported", category = "diagnostic", }, } device.fromZigbee = { "illuminance", "battery" } device.tuyaDatapoints = { { dp = 1, name = "rainwater", converter = "lookup", lookup = { none = 0, raining = 1 } }, { dp = 102, name = "illuminance", converter = "raw" }, { dp = 104, name = "battery", converter = "raw" }, { dp = 2, name = "sensitivity", converter = "raw" }, { dp = 101, name = "illuminance_sampling", converter = "raw" }, } device.configure = { bind = { "msIlluminanceMeasurement", "genPowerCfg" }, reporting = { { cluster = "msIlluminanceMeasurement", attribute = "measuredValue", min = 10, max = 3600, change = 5, }, { cluster = "genPowerCfg", attribute = "batteryPercentageRemaining", min = 3600, max = 65000, change = 0, }, { cluster = "genPowerCfg", attribute = "batteryVoltage", min = 3600, max = 65000, change = 0, }, }, } return device