local device = {} device.model = "TS0601_fan_switch" device.vendor = "Tuya" device.description = "Fan switch" device.exposes = { { type = "switch", features = { { type = "binary", name = "state", property = "state", access = 3, value_on = "ON", value_off = "OFF", description = "On/off state of the switch", }, }, }, { type = "enum", name = "power_on_behavior", property = "power_on_behavior", access = 3, description = "Controls the behavior when the device is powered on after power loss", category = "config", values = { "off", "on" }, }, { type = "numeric", name = "countdown", property = "countdown", access = 3, unit = "s", min = 0, max = 43200, value_step = 1, description = "Max ON time in seconds", }, { type = "numeric", name = "fan_speed", property = "fan_speed", access = 3, min = 1, max = 5, value_step = 1, description = "Speed off the fan", }, } device.tuyaDatapoints = { { dp = 1, name = "state", converter = "onOff" }, { dp = 2, name = "countdown", converter = "countdown" }, { dp = 3, name = "fan_speed", converter = "lookup", lookup = { 1 = 0, 2 = 1, 3 = 2, 4 = 3, 5 = 4 } }, { dp = 11, name = "power_on_behavior", converter = "lookup", lookup = { off = 0, on = 1 } }, } device.fingerprint = { { model = "TS0601", manufacturer = "_TZE200_r32ctezx", }, { model = "TS0601", manufacturer = "_TZE204_r32ctezx", }, } return device