local device = {} device.model = "ZG-302ZL" device.vendor = "HOBEIAN" device.description = "Motion sensing switch" device.zigbeeModel = { "ZG-302ZL" } device.exposes = { { type = "binary", name = "presence", property = "presence", access = 1, value_on = true, value_off = false, description = "Indicates whether the device detected presence", }, { type = "binary", name = "switch_1", property = "switch_1", access = 3, value_on = "ON", value_off = "OFF", description = "Switch2", }, { type = "binary", name = "switch_2", property = "switch_2", access = 3, value_on = "ON", value_off = "OFF", description = "Switch2", }, { type = "binary", name = "switch_3", property = "switch_3", access = 3, value_on = "ON", value_off = "OFF", description = "Switch3", }, { type = "numeric", name = "sensitivity", property = "sensitivity", access = 3, min = 0, max = 19, value_step = 1, description = "detection sensitivity", }, { type = "binary", name = "backlight", property = "backlight", access = 3, value_on = "ON", value_off = "OFF", description = "backlight", }, { type = "numeric", name = "trigger_hold", property = "trigger_hold", access = 3, unit = "s", min = 5, max = 28800, value_step = 1, description = "Trigger hold(second)", }, { type = "enum", name = "power_outage_memory", property = "power_outage_memory", access = 7, description = "Recover state after power outage", category = "config", values = { "on", "off", "restore" }, }, { type = "enum", name = "auto_on", property = "auto_on", access = 3, description = "When somebody passes in front of their sensors, the lights turn", values = { "off", "all", "ch1", "ch2", "ch3", "ch1_and_ch2", "ch2_and_ch3", "ch1_and_ch3", }, }, { type = "enum", name = "auto_off", property = "auto_off", access = 3, description = "No one turns off the lights", values = { "off", "all", "ch1", "ch2", "ch3", "ch1_and_ch2", "ch2_and_ch3", "ch1_and_ch3", }, }, { 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" } device.tuyaDatapoints = { { dp = 101, name = "presence", converter = "trueFalse1" }, { dp = 102, name = "sensitivity", converter = "raw" }, { dp = 1, name = "switch_1", converter = "onOff" }, { dp = 2, name = "switch_2", converter = "onOff" }, { dp = 3, name = "switch_3", converter = "onOff" }, { dp = 16, name = "backlight", converter = "onOff" }, { dp = 103, name = "trigger_hold", converter = "raw" }, { dp = 14, name = "power_outage_memory", converter = "lookup", lookup = { off = 0, on = 1, restore = 2 } }, { dp = 104, name = "auto_on", converter = "lookup", lookup = { off = 0, all = 1, ch2 = 2, ch3 = 3, ch1_and_ch2 = 4, ch2_and_ch3 = 5, ch1_and_ch3 = 6 } }, { dp = 105, name = "auto_off", converter = "lookup", lookup = { off = 0, all = 1, ch2 = 2, ch3 = 3, ch1_and_ch2 = 4, ch2_and_ch3 = 5, ch1_and_ch3 = 6 } }, } device.configure = { bind = { "ssIasZone", "msOccupancySensing" }, reporting = { { cluster = "msOccupancySensing", attribute = "occupancy", min = 0, max = 3600, change = 0, }, }, } device.meta = { multiEndpoint = true } return device