local device = {} device.model = "TS0601_cover_12" device.vendor = "Tuya" device.description = "Curtain motor" device.exposes = { { 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 = "motor_direction", property = "motor_direction", access = 3, description = "Motor direction", values = { "forward", "back" }, }, { type = "enum", name = "work_state", property = "work_state", access = 1, description = "Current work state", values = { "opening", "closing" }, }, { type = "numeric", name = "total_time", property = "total_time", access = 1, unit = "ms", description = "Total running time in milliseconds", }, { type = "enum", name = "situation_set", property = "situation_set", access = 3, description = "Set fully open or fully close position", values = { "fully_close", "fully_open" }, }, { type = "text", name = "fault", property = "fault", access = 1, description = "Fault details", }, { type = "numeric", name = "battery", property = "battery", access = 1, unit = "%", min = 0, max = 100, description = "Remaining battery in %, can take up to 24 hours before reported", category = "diagnostic", }, } device.fromZigbee = { "battery" } device.tuyaDatapoints = { { dp = 1, name = "state", converter = "lookup", lookup = { OPEN = 0, STOP = 1, CLOSE = 2 } }, { dp = 2, name = "position", converter = "coverPosition" }, { dp = 3, name = "position", converter = "coverPosition" }, { dp = 5, name = "motor_direction", converter = "lookup", lookup = { forward = 0, back = 1 } }, { dp = 7, name = "work_state", converter = "lookup", lookup = { opening = 0, closing = 1 } }, { dp = 10, name = "total_time", converter = "raw" }, { dp = 11, name = "situation_set", converter = "lookup", lookup = { fully_close = 0, fully_open = 1 } }, { dp = 12, name = "fault", converter = "raw" }, { dp = 103, name = "battery", converter = "raw" }, } 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, }, }, } device.fingerprint = { { model = "TS0601", manufacturer = "_TZE200_mlglxwp3", }, } return device