local device = {} device.model = "TS0601-PIR-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 = "detection_distance", property = "detection_distance", access = 3, unit = "m", min = 1, max = 6, description = "Maximum detection distance", }, { type = "numeric", name = "fading_time", property = "fading_time", access = 3, unit = "s", min = 10, max = 180, value_step = 10, description = "Presence keep time", }, { type = "enum", name = "last_time", property = "last_time", access = 1, description = "Last trigger type", values = { "pir", "none" }, }, { type = "numeric", name = "static_detection_sensitivity", property = "static_detection_sensitivity", access = 3, min = 1, max = 10, description = "Static detection sensitivity", }, { type = "numeric", name = "motion_detection_sensitivity", property = "motion_detection_sensitivity", access = 3, min = 1, max = 10, description = "Motion detection sensitivity", }, { type = "numeric", name = "battery", property = "battery", access = 5, unit = "%", min = 0, max = 100, description = "Remaining battery in %", category = "diagnostic", }, { 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 = { "battery", "ias_zone", "occupancy", "illuminance" } device.tuyaDatapoints = { { dp = 1, name = "presence", converter = "trueFalse0" }, { dp = 4, name = "battery", converter = "raw" }, { dp = 12, name = "illuminance", converter = "raw" }, { dp = 101, name = "detection_distance", converter = "raw" }, { dp = 103, name = "fading_time", converter = "raw" }, { dp = 104, name = "last_time", converter = "lookup", lookup = { pir = 0, none = 1 } }, { dp = 105, name = "static_detection_sensitivity", converter = "raw" }, { dp = 106, name = "motion_detection_sensitivity", converter = "raw" }, } device.configure = { bind = { "genPowerCfg", "ssIasZone", "msOccupancySensing", "msIlluminanceMeasurement" }, reporting = { { cluster = "genPowerCfg", attribute = "batteryPercentageRemaining", min = 3600, max = 65000, change = 0, }, { cluster = "genPowerCfg", attribute = "batteryVoltage", min = 3600, max = 65000, change = 0, }, { cluster = "msOccupancySensing", attribute = "occupancy", min = 0, max = 3600, change = 0, }, { cluster = "msIlluminanceMeasurement", attribute = "measuredValue", min = 10, max = 3600, change = 5, }, }, } device.fingerprint = { { model = "TS0601", manufacturer = "_TZE200_juzago6i", }, } return device