local device = {} device.model = "TS0301" device.vendor = "Tuya" device.description = "Cover motor" device.zigbeeModel = { "TS0301" } 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. device.tuyaDatapoints = { { dp = 1, name = "state", converter = "lookup", lookup = { OPEN = 0, CLOSE = 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