local device = {} device.model = "ZG-204ZM" device.vendor = "Tuya" device.description = "PIR 24Ghz human presence sensor" device.zigbeeModel = { "ZG-204ZM" } device.exposes = { { type = "binary", name = "presence", property = "presence", access = 1, value_on = true, value_off = false, description = "Indicates whether the device detected presence", }, { type = "enum", name = "motion_state", property = "motion_state", access = 1, description = "Motion state", values = { "none", "large", "small", "static" }, }, { 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 = 0, max = 28800, value_step = 1, description = "Presence keep time", }, { type = "numeric", name = "static_detection_distance", property = "static_detection_distance", access = 3, unit = "m", min = 0, max = 6, value_step = 0.01, description = "Static 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 = "binary", name = "indicator", property = "indicator", access = 3, value_on = "ON", value_off = "OFF", description = "LED indicator mode", }, { type = "enum", name = "motion_detection_mode", property = "motion_detection_mode", access = 3, description = "Motion detection mode (Firmware version>=0122052017)", values = { "only_pir", "pir_and_radar", "only_radar" }, }, { type = "numeric", name = "motion_detection_sensitivity", property = "motion_detection_sensitivity", access = 3, min = 0, max = 10, value_step = 1, description = "Motion detection sensitivity (Firmware version>=0122052017)", }, { type = "numeric", name = "illuminance", property = "illuminance", access = 5, unit = "lx", description = "Measured illuminance", }, { 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", "battery" } device.tuyaDatapoints = { { dp = 1, name = "presence", converter = "trueFalse1" }, { dp = 2, name = "static_detection_sensitivity", converter = "raw" }, { dp = 4, name = "static_detection_distance", converter = "divideBy100" }, { dp = 101, name = "motion_state", converter = "lookup", lookup = { none = 0, large = 1, small = 2, static = 3 } }, { dp = 102, name = "fading_time", converter = "raw" }, { dp = 106, name = "illuminance", converter = "raw" }, { dp = 107, name = "indicator", converter = "onOff" }, { dp = 121, name = "battery", converter = "raw" }, { dp = 122, name = "motion_detection_mode", converter = "lookup", lookup = { only_pir = 0, pir_and_radar = 1, only_radar = 2 } }, { dp = 123, name = "motion_detection_sensitivity", converter = "raw" }, } device.configure = { bind = { "msIlluminanceMeasurement", "ssIasZone", "msOccupancySensing", "genPowerCfg" }, reporting = { { cluster = "msIlluminanceMeasurement", attribute = "measuredValue", min = 10, max = 3600, change = 5, }, { 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