local device = {} device.model = "E8332DST350ZB" device.vendor = "Schneider Electric" device.description = "Wiser AvatarOn 2G dimmer switch" device.zigbeeModel = { "E8332DST350ZB" } -- Two dimmable channels on endpoints 10 (l1) and 11 (l2). Core control is -- standard ZCL genOnOff + genLevelCtrl; the LED indicator_mode lives in the -- Schneider Visa config cluster (0xFC04), attribute indicatorMode (0x0002). -- NOTE: z2m tags the E8332 as ENUM8 (0x30) with map [2,0,3,1], but the real -- device rejects an ENUM8 write with ZCL status 0x8D (INVALID_DATA_TYPE). This -- firmware uses UINT8 (0x20) — same as the E8331 — so we use the E8331 encoding -- ([0,1,2,3]). indicator_mode is a single device-level setting, written on the -- first gang (endpoint 10). local IND_EP = 10 local INDICATOR_FROM = { [0] = "reverse_with_load", [1] = "consistent_with_load", [2] = "always_off", [3] = "always_on" } local INDICATOR_TO = { reverse_with_load = 0, consistent_with_load = 1, always_off = 2, always_on = 3 } device.exposes = { { type = "light", endpoint = "l1", features = { { type = "binary", name = "state", property = "state_l1", access = 7, value_on = "ON", value_off = "OFF", description = "On/off state of this light", endpoint = "l1", }, { type = "numeric", name = "brightness", property = "brightness_l1", access = 7, min = 0, max = 254, description = "Brightness of this light", endpoint = "l1", }, }, }, { type = "light", endpoint = "l2", features = { { type = "binary", name = "state", property = "state_l2", access = 7, value_on = "ON", value_off = "OFF", description = "On/off state of this light", endpoint = "l2", }, { type = "numeric", name = "brightness", property = "brightness_l2", access = 7, min = 0, max = 254, description = "Brightness of this light", endpoint = "l2", }, }, }, { type = "enum", name = "indicator_mode", property = "indicator_mode", access = 7, description = "Set indicator mode for switch", category = "config", values = { "reverse_with_load", "consistent_with_load", "always_off", "always_on" }, }, } device.fromZigbee = { "on_off", "brightness", { -- Visa config cluster: reflect indicator mode changed externally. The Lua -- fromZigbee msg carries no attribute id, so guard on the valid range. cluster = 0xFC04, convert = function(msg) if not msg.is_attribute then return nil end local v = msg.payload and msg.payload[1] local mode = v and INDICATOR_FROM[v] if mode == nil then return nil end return { indicator_mode = mode } end, }, } device.toZigbee = { "on_off", "brightness", { key = "indicator_mode", convert = function(value, endpoint) local n = INDICATOR_TO[value] if n == nil then return nil end -- Visa config cluster 0xFC04, indicatorMode attr 0x0002 (UINT8), -- device-level: written on the first gang (endpoint 10). return { cluster = 0xFC04, endpoint = IND_EP, isAttribute = true, attrId = 0x0002, attrType = 0x20, manufacturerCode = 0x105E, payload = { n } } end, }, } device.configure = { bind = { "genOnOff", "genLevelCtrl" }, reporting = { { cluster = "genOnOff", attribute = "onOff", min = 0, max = 3600, change = 0, }, { cluster = "genLevelCtrl", attribute = "currentLevel", min = 1, max = 3600, change = 1, }, }, } device.meta = { multiEndpoint = true } device.endpoint = { l1 = 10, l2 = 11, } return device