local device = {} device.model = "ZD24_Presence_Sensor" device.vendor = "Tuya" device.description = "PIR 24GHz human presence sensor" device.exposes = { { type = "binary", name = "presence", property = "presence", access = 1, value_on = true, value_off = false, description = "Indicates whether the device detected presence", }, { 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 = "motion_state", property = "motion_state", access = 1, description = "Human body motion state", values = { "none", "static", "small", "large" }, }, { type = "numeric", name = "distance", property = "distance", access = 1, unit = "m", description = "Target distance", }, { type = "binary", name = "init", property = "init", access = 3, value_on = "ON", value_off = "OFF", description = "Initialize", }, { type = "numeric", name = "fading_time", property = "fading_time", access = 3, unit = "s", min = 10, max = 3600, value_step = 1, description = "Presence keep time", }, { type = "numeric", name = "motion_detection_sensitivity", property = "motion_detection_sensitivity", access = 3, min = 1, max = 10, value_step = 1, description = "Motion detection sensitivity", }, { type = "numeric", name = "static_detection_sensitivity", property = "static_detection_sensitivity", access = 3, min = 1, max = 10, value_step = 1, description = "Static detection sensitivity", }, { type = "enum", name = "motion_detection_mode", property = "motion_detection_mode", access = 3, description = "Motion detection mode", values = { "pir_and_radar", "only_radar", "pir_or_radar" }, }, { type = "binary", name = "occupancy", property = "occupancy", access = 1, value_on = true, value_off = false, description = "Indicates whether the device detected occupancy", }, { 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 = { "ias_zone", "occupancy", "illuminance", "battery" } device.tuyaDatapoints = { { dp = 1, name = "presence", converter = "trueFalse1" }, { dp = 4, name = "distance", converter = "raw" }, { dp = 11, name = "motion_state", converter = "lookup", lookup = { none = 0, static = 1, small = 2, large = 3 } }, { dp = 12, name = "fading_time", converter = "raw" }, { dp = 15, name = "motion_detection_sensitivity", converter = "raw" }, { dp = 16, name = "static_detection_sensitivity", converter = "raw" }, { dp = 20, name = "illuminance", converter = "raw" }, { dp = 81, name = "battery", converter = "raw" }, { dp = 101, name = "init", converter = "onOff" }, { dp = 102, name = "motion_detection_mode", converter = "raw" }, } device.configure = { bind = { "ssIasZone", "msOccupancySensing", "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, }, }, } device.fingerprint = { { model = "TS0601", manufacturer = "_TZE284_bw4ayyeh", }, } return device