local device = {} device.model = "ZG-102ZL" device.vendor = "Tuya" device.description = "Luminance door sensor" device.zigbeeModel = { "ZG-102ZL" } device.exposes = { { type = "binary", name = "contact", property = "contact", access = 1, value_on = false, value_off = true, description = "Indicates if the contact is closed (= true) or open (= false)", }, { type = "numeric", name = "illuminance", property = "illuminance", access = 1, unit = "lx", description = "Measured illuminance", }, { 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", }, { type = "numeric", name = "illuminance_interval", property = "illuminance_interval", access = 3, unit = "minutes", min = 1, max = 720, value_step = 1, description = "Brightness acquisition interval (refresh and update only while active)", }, { type = "binary", name = "occupancy", property = "occupancy", access = 1, value_on = true, value_off = false, description = "Indicates whether the device detected occupancy", }, { type = "binary", name = "tamper", property = "tamper", access = 1, value_on = true, value_off = false, description = "Indicates whether the device is tampered", }, { type = "binary", name = "battery_low", property = "battery_low", access = 1, value_on = true, value_off = false, description = "Indicates if the battery of this device is almost empty", category = "diagnostic", }, } device.fromZigbee = { "ias_zone", "illuminance", "battery" } device.tuyaDatapoints = { { dp = 1, name = "contact", converter = "inverse" }, { dp = 101, name = "illuminance", converter = "raw" }, { dp = 2, name = "battery", converter = "raw" }, { dp = 102, name = "illuminance_interval", converter = "raw" }, } device.configure = { bind = { "ssIasZone", "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