-- Dooya DT72TV tubular motor (_TZE200_8viydiwr). -- Split from the generic TS0601_cover_1. Position is split across two datapoints: -- dp2 = setpoint (write target). Its echo also gives instant feedback on a -- position-set, so it stays readable. -- dp3 = delayed position feedback. During normal movement this firmware -- reports the previous target, so accepting it would make the display -- lag one command behind. It is useful only after STOP, where it gives -- the true resting position. -- Open/close position is also reflected optimistically on command ack in the -- gateway (publish_module), and dp3 confirms it at settle. -- dp1 control enum is 0=open/1=stop/2=close, but the device reports its state -- inverted (2=open, 0=closed), so dp1 uses an explicit reverseLookup to decode -- reports correctly while keeping commands (encode) unchanged. local device = {} device.model = "TS0601_cover_dooya" device.vendor = "Dooya" device.description = "Tubular motor (dp2 setpoint + dp3 settled feedback)" device.fingerprint = { { model = "TS0601", manufacturer = "_TZE200_8viydiwr", }, } 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 = "composite", name = "options", property = "options", access = 3, features = { { type = "numeric", name = "motor_speed", property = "motor_speed", access = 3, min = 0, max = 255, description = "Motor speed", }, { type = "binary", name = "reverse_direction", property = "reverse_direction", access = 3, value_on = true, value_off = false, description = "Reverse the motor direction", }, }, }, } device.tuyaDatapoints = { -- Control uses 0=open/1=stop/2=close (the lookup below; commands work), but -- this device REPORTS its resting state inverted: 2 when open, 0 when closed. -- reverseLookup decodes reports back correctly without touching the encode -- map, so the shown state matches reality while control stays correct. { dp = 1, name = "state", converter = "lookup", lookup = { OPEN = 0, STOP = 1, CLOSE = 2 }, reverseLookup = { [0] = "CLOSE", [1] = "STOP", [2] = "OPEN" } }, -- dp2 = position setpoint: SET writes here, and its echo shows the commanded -- target instantly. { dp = 2, name = "position", converter = "coverPosition" }, -- Ignore delayed normal-movement reports; accept one DP3 only after STOP. { dp = 3, name = "position", converter = "coverPosition", access = "r", readPolicy = "stop_only" }, } return device