local device = {} device.model = "rtsc11r" device.vendor = "Tuya" device.description = "5.8G human presence sensor with relay" 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_delay", property = "detection_delay", access = 3, unit = "s", min = 0, max = 10, value_step = 0.1, description = "Detection delay", }, { type = "numeric", name = "detection_distance", property = "detection_distance", access = 1, unit = "cm", min = 0, max = 1000, value_step = 1, description = "Distance of detected person", }, { type = "numeric", name = "sensitivity", property = "sensitivity", access = 3, min = 0, max = 10, value_step = 1, description = "Detection sensitivity", }, { type = "numeric", name = "keep_time", property = "keep_time", access = 3, unit = "s", min = 5, max = 3600, value_step = 1, description = "Detection keep time", }, { type = "numeric", name = "minimum_range", property = "minimum_range", access = 3, unit = "m", min = 0, max = 1000, value_step = 50, description = "Minimum detection range", }, { type = "numeric", name = "maximum_range", property = "maximum_range", access = 3, unit = "m", min = 50, max = 1000, value_step = 50, description = "Maximum detection range", }, { 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" } device.tuyaDatapoints = { { dp = 1, name = "presence", converter = "trueFalse1" }, { dp = 12, name = "detection_delay", converter = "divideBy10" }, { dp = 19, name = "detection_distance", converter = "raw" }, { dp = 20, name = "illuminance", converter = "raw" }, { dp = 101, name = "sensitivity", converter = "divideBy10" }, { dp = 102, name = "keep_time", converter = "raw" }, { dp = 111, name = "minimum_range", converter = "divideBy100" }, { dp = 112, name = "maximum_range", converter = "divideBy100" }, } device.configure = { bind = { "ssIasZone", "msOccupancySensing", "msIlluminanceMeasurement" }, reporting = { { 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 = "_TZE204_mhxn2jso", }, } return device