local device = {} device.model = "MCCGQ01LM" device.vendor = "Xiaomi" device.description = "Mi door and window sensor" device.zigbeeModel = { "lumi.sensor_magnet" } device.exposes = { { 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 = "binary", name = "contact", property = "contact", access = 1, value_on = false, value_off = true, description = "Indicates if the contact is closed (= true) or open (= false)", }, { type = "numeric", name = "voltage", property = "voltage", access = 1, unit = "mV", description = "Voltage of the battery in millivolts", category = "diagnostic", }, { type = "numeric", name = "power_outage_count", property = "power_outage_count", access = 1, description = "Number of power outages", category = "diagnostic", }, { type = "binary", name = "occupancy", property = "occupancy", access = 1, value_on = true, value_off = false, description = "Indicates whether the device detected occupancy", }, { 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 = { "on_off", "battery", "ias_zone", "electrical" } device.configure = { bind = { "genOnOff", "genPowerCfg", "ssIasZone", "haElectricalMeasurement" }, reporting = { { cluster = "genOnOff", attribute = "onOff", 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, }, { cluster = "haElectricalMeasurement", attribute = "activePower", min = 5, max = 3600, change = 1, }, { cluster = "haElectricalMeasurement", attribute = "rmsVoltage", min = 5, max = 3600, change = 5, }, { cluster = "haElectricalMeasurement", attribute = "rmsCurrent", min = 5, max = 3600, change = 100, }, }, } return device