local device = {} device.model = "ZG-204ZK" device.vendor = "HOBEIAN" device.description = "24Ghz human presence sensor" device.zigbeeModel = { "ZG-204ZK" } 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 = "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 = "numeric", name = "fading_time", property = "fading_time", access = 3, unit = "s", min = 10, max = 28800, value_step = 1, description = "Presence keep time", }, { type = "numeric", name = "detection_distance", property = "detection_distance", access = 3, unit = "m", min = 0, max = 5, value_step = 0.01, description = "Detection distance", }, { type = "numeric", name = "static_detection_sensitivity", property = "static_detection_sensitivity", access = 3, min = 0, max = 10, value_step = 1, description = "Static detection sensitivity", }, { type = "numeric", name = "motion_detection_sensitivity", property = "motion_detection_sensitivity", access = 3, min = 0, max = 10, value_step = 1, description = "Motion detection sensitivity", }, { type = "binary", name = "indicator", property = "indicator", access = 3, value_on = "ON", value_off = "OFF", description = "LED indicator mode", }, { type = "binary", name = "anti_interference", property = "anti_interference", access = 3, value_on = "ON", value_off = "OFF", description = "Anti interference function", }, { 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", "battery" } device.tuyaDatapoints = { { dp = 1, name = "presence", converter = "trueFalse1" }, { dp = 102, name = "fading_time", converter = "raw" }, { dp = 4, name = "detection_distance", converter = "divideBy100" }, { dp = 2, name = "static_detection_sensitivity", converter = "raw" }, { dp = 107, name = "indicator", converter = "onOff" }, { dp = 123, name = "motion_detection_sensitivity", converter = "raw" }, { dp = 121, name = "battery", converter = "raw" }, { dp = 122, name = "anti_interference", converter = "onOff" }, } device.configure = { bind = { "ssIasZone", "msOccupancySensing", "genPowerCfg" }, reporting = { { cluster = "msOccupancySensing", attribute = "occupancy", min = 0, max = 3600, change = 0, }, { cluster = "genPowerCfg", attribute = "batteryPercentageRemaining", min = 3600, max = 65000, change = 0, }, { cluster = "genPowerCfg", attribute = "batteryVoltage", min = 3600, max = 65000, change = 0, }, }, } return device