local device = {} device.model = "TS0301_usalx0e0" device.vendor = "Tuya" device.description = "Cover motor" device.zigbeeModel = {} device.fingerprint = { { model = "TS0301", manufacturer = "_TZE210_usalx0e0", }, } device.exposes = { { type = "numeric", name = "battery", property = "battery", access = 5, unit = "%", min = 0, max = 100, description = "Remaining battery in %", category = "diagnostic", }, { type = "cover", features = { { type = "enum", name = "state", property = "state", access = 3, values = { "OPEN", "CLOSE", "STOP" }, }, { type = "numeric", name = "position", property = "position", access = 3, unit = "%", min = 0, max = 100, description = "Position of this cover", }, }, }, { type = "enum", name = "reverse_direction", property = "reverse_direction", access = 3, values = { "forward", "back" }, description = "Reverse the motor direction", }, } -- Tuya MCU datapoint device (cluster 0xEF00). The standard window-covering -- cluster (0x0102) advertised in the endpoint descriptor is non-functional on -- these _TZE2xx_ motors; control and reporting both go through datapoints. -- -- This _TZE210_usalx0e0 variant has OPEN/CLOSE swapped versus the generic -- TS0301.lua: on this MCU dp1 value 0 = CLOSE and 1 = OPEN (the generic uses -- OPEN=0/CLOSE=1), which made the UI "close" open the cover and vice versa. device.tuyaDatapoints = { { dp = 1, name = "state", converter = "lookup", lookup = { CLOSE = 0, OPEN = 1, STOP = 2 } }, { dp = 2, name = "position", converter = "coverPosition" }, { dp = 3, name = "position", converter = "coverPosition" }, { dp = 5, name = "reverse_direction", converter = "lookup", lookup = { forward = 0, back = 1 } }, } -- Battery is still reported over the standard genPowerCfg cluster. device.fromZigbee = { "battery" } -- Wake the Tuya MCU on configure so it starts reporting its datapoints. device.tuya = { magicPacket = true } 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