local device = {} device.model = "E8332SRY800ZB_NEW" device.vendor = "Schneider Electric" device.description = "Wiser AvatarOn 2G onoff switch" device.zigbeeModel = { "A3N32SR800ZB_xx_C1" } -- Indicator mode lives in the Visa configuration cluster (0xFC04), -- attribute indicatorMode (0x0002, UINT8), Schneider manufacturer code 0x105E. -- Value lookup (matches z2m visaIndicatorMode([0,1,2,3])): -- reverse_with_load=0, consistent_with_load=1, always_off=2, always_on=3 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 = "switch", endpoint = "l1", features = { { type = "binary", name = "state", property = "state_l1", access = 7, value_on = "ON", value_off = "OFF", description = "On/off state of the switch", endpoint = "l1", }, }, }, { type = "switch", endpoint = "l2", features = { { type = "binary", name = "state", property = "state_l2", access = 7, value_on = "ON", value_off = "OFF", description = "On/off state of the switch", 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", { -- Visa configuration cluster: reflect indicator mode reported by the -- device (e.g. changed externally). NOTE: the Lua fromZigbee msg does -- not carry the attribute id, so we guard on the valid value 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", { key = "indicator_mode", convert = function(value, endpoint) local n = INDICATOR_TO[value] if n == nil then return nil end return { cluster = 0xFC04, endpoint = 10, -- device-level setting, written on the first gang isAttribute = true, attrId = 0x0002, -- indicatorMode attrType = 0x20, -- UINT8 manufacturerCode = 0x105E, -- Schneider Electric payload = { n }, } end, }, } device.configure = { bind = { "genOnOff" }, reporting = { { cluster = "genOnOff", attribute = "onOff", min = 0, max = 3600, change = 0, }, }, } device.meta = { multiEndpoint = true } device.endpoint = { l1 = 10, l2 = 11, } return device