local device = {} device.model = "Y1_IN" device.vendor = "Tuya" device.description = "Smart human presence sensor 24G" 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 = "keep_sensitivity", property = "keep_sensitivity", access = 3, min = 0, max = 10, value_step = 1, description = "Keep sensitivity", }, { type = "numeric", name = "trigger_sensitivity", property = "trigger_sensitivity", access = 3, min = 1, max = 20, value_step = 1, description = "Trigger sensitivity", }, { type = "numeric", name = "fading_time", property = "fading_time", access = 3, unit = "s", min = 1, max = 60, value_step = 1, description = "Presence timeout", }, { type = "numeric", name = "target_distance", property = "target_distance", access = 1, unit = "m", description = "Distance to target", }, { 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 = 102, name = "fading_time", converter = "raw" }, { dp = 103, name = "illuminance", converter = "raw" }, { dp = 110, name = "keep_sensitivity", converter = "raw" }, { dp = 114, name = "trigger_sensitivity", converter = "raw" }, { dp = 182, name = "target_distance", converter = "divideBy10" }, } 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_bmdsp6bs", }, } return device