local device = {} device.model = "CTL-R1-TY-Zigbee" device.vendor = "Tuya" device.description = "24G radar human presence motion sensor." device.exposes = { { type = "numeric", name = "illuminance", property = "illuminance", access = 1, unit = "lx", description = "Measured illuminance", }, { type = "binary", name = "presence", property = "presence", access = 1, value_on = true, value_off = false, description = "Indicates whether the device detected presence", }, { type = "numeric", name = "presence_sensitivity", property = "presence_sensitivity", access = 3, unit = "%", min = 0, max = 100, value_step = 1, description = "Presence sensitivity", }, { type = "numeric", name = "detection_range", property = "detection_range", access = 3, unit = "m", min = 1.5, max = 4.5, value_step = 0.1, description = "Detection range", }, { type = "numeric", name = "detection_delay", property = "detection_delay", access = 3, unit = "s", min = 1, max = 600, value_step = 1, description = "Presence detection delay", }, { type = "numeric", name = "illuminance_treshold_max", property = "illuminance_treshold_max", access = 3, unit = "lx", min = 0, max = 2000, value_step = 1, description = "The max illuminance threshold to turn on the light", }, { type = "numeric", name = "illuminance_treshold_min", property = "illuminance_treshold_min", access = 3, unit = "lx", min = 0, max = 2000, value_step = 1, description = "The min illuminance threshold to turn on the light", }, { type = "binary", name = "presence_illuminance_switch", property = "presence_illuminance_switch", access = 3, value_on = true, value_off = false, description = "Whether to enable 'light_switch' illumination is between min/max threshold", }, { type = "binary", name = "light_switch", property = "light_switch", access = 1, value_on = "ON", value_off = "OFF", description = "This state will determine the light on/off based on the lighting threshold and presence sensing", }, { type = "binary", name = "light_linkage", property = "light_linkage", access = 3, value_on = true, value_off = false, description = "Light linkage", }, { type = "enum", name = "detection_method", property = "detection_method", access = 3, description = "When 'only_move' is used, presence will only be triggered when there is movement", values = { "only_move", "exist_move" }, }, { type = "enum", name = "indicator_light", property = "indicator_light", access = 3, description = "Controls when the indicator light is turned on", values = { "presence", "off", "on" }, }, { type = "binary", name = "identify", property = "identify", access = 3, value_on = true, value_off = false, description = "After turning on, the indicator light quickly flashes, used to locate devices", }, { 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 = { "illuminance", "ias_zone", "occupancy" } device.tuyaDatapoints = { { dp = 1, name = "presence", converter = "trueFalse1" }, { dp = 2, name = "presence_sensitivity", converter = "raw" }, { dp = 4, name = "detection_range", converter = "divideBy10" }, { dp = 101, name = "illuminance", converter = "raw" }, { dp = 102, name = "illuminance_treshold_max", converter = "raw" }, { dp = 103, name = "illuminance_treshold_min", converter = "raw" }, { dp = 104, name = "detection_delay", converter = "raw" }, { dp = 109, name = "presence_illuminance_switch", converter = "trueFalseEnum1" }, { dp = 105, name = "light_switch", converter = "onOff" }, { dp = 106, name = "light_linkage", converter = "trueFalseEnum1" }, { dp = 107, name = "indicator_light", converter = "lookup", lookup = { presence = 0, off = 1, on = 2 } }, { dp = 108, name = "detection_method", converter = "lookup", lookup = { only_move = 0, exist_move = 1 } }, { dp = 113, name = "find_switch", converter = "raw" }, } device.configure = { bind = { "msIlluminanceMeasurement", "ssIasZone", "msOccupancySensing" }, reporting = { { cluster = "msIlluminanceMeasurement", attribute = "measuredValue", min = 10, max = 3600, change = 5, }, { cluster = "msOccupancySensing", attribute = "occupancy", min = 0, max = 3600, change = 0, }, }, } device.fingerprint = { { model = "TS0601", manufacturer = "_TZE204_e9ajs4ft", }, } return device