local device = {} device.model = "ZG-103Z" device.vendor = "Tuya" device.description = "Vibration sensor" device.zigbeeModel = { "ZG-103Z" } device.exposes = { { type = "binary", name = "vibration", property = "vibration", access = 1, value_on = true, value_off = false, description = "Indicates whether the device detected vibration", }, { type = "binary", name = "tilt", property = "tilt", access = 1, value_on = true, value_off = false, description = "Indicates whether the device detected tilt", }, { type = "numeric", name = "x", property = "x", access = 1, min = 0, max = 256, value_step = 1, description = "X coordinate", }, { type = "numeric", name = "y", property = "y", access = 1, min = 0, max = 256, value_step = 1, description = "Y coordinate", }, { type = "numeric", name = "z", property = "z", access = 1, min = 0, max = 256, value_step = 1, description = "Z coordinate", }, { 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 = "enum", name = "sensitivity", property = "sensitivity", access = 3, description = "Vibration detection sensitivity", values = { "low", "middle", "high" }, }, } device.fromZigbee = { "battery" } device.tuyaDatapoints = { { dp = 1, name = "vibration", converter = "trueFalseEnum1" }, { dp = 7, name = "tilt", converter = "trueFalseEnum1" }, { dp = 101, name = "x", converter = "raw" }, { dp = 102, name = "y", converter = "raw" }, { dp = 103, name = "z", converter = "raw" }, { dp = 104, name = "sensitivity", converter = "lookup", lookup = { low = 0, middle = 1, high = 2 } }, { dp = 105, name = "battery", converter = "raw" }, } device.configure = { bind = { "genPowerCfg" }, reporting = { { cluster = "genPowerCfg", attribute = "batteryPercentageRemaining", min = 3600, max = 65000, change = 0, }, { cluster = "genPowerCfg", attribute = "batteryVoltage", min = 3600, max = 65000, change = 0, }, }, } return device