local device = {} device.model = "ZG-204ZL" device.vendor = "Tuya" device.description = "Luminance motion sensor" device.zigbeeModel = { "ZG-204ZL" } device.exposes = { { type = "binary", name = "occupancy", property = "occupancy", access = 1, value_on = true, value_off = false, description = "Indicates whether the device detected occupancy", }, { 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 = "enum", name = "sensitivity", property = "sensitivity", access = 3, description = "PIR sensor sensitivity (refresh and update only while active)", values = { "low", "medium", "high" }, }, { type = "enum", name = "keep_time", property = "keep_time", access = 3, description = "PIR keep time in seconds (refresh and update only while active)", values = { "10", "30", "60", "120" }, }, { 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 = "contact", property = "contact", access = 1, value_on = false, value_off = true, description = "Indicates if the contact is closed or open", }, { 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 = { "occupancy", "ias_zone", "illuminance", "battery" } device.tuyaDatapoints = { { dp = 1, name = "occupancy", converter = "trueFalse0" }, { dp = 4, name = "battery", converter = "raw" }, { dp = 9, name = "sensitivity", converter = "lookup", lookup = { low = 0, medium = 1, high = 2 } }, { dp = 10, name = "keep_time", converter = "lookup", lookup = { 10 = 0, 30 = 1, 60 = 2, 120 = 3 } }, { dp = 12, name = "illuminance", converter = "raw" }, { dp = 101, name = "illuminance", converter = "raw" }, { dp = 102, name = "illuminance_interval", converter = "raw" }, } device.configure = { bind = { "msOccupancySensing", "ssIasZone", "msIlluminanceMeasurement", "genPowerCfg" }, reporting = { { cluster = "msOccupancySensing", attribute = "occupancy", min = 0, max = 3600, change = 0, }, { 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