@sparkydave Ok I think i have the brilliant fan switch cracked!
Use the following TuyaMCU settings
9 => Light Switch
10 => Dimmer
12 => Global fan on/off
There is an additional dpid #2 which never seems to have its value changed in my testing and didnt seem to do anything
Dpid 3 is used for the fan speed, when changing the fan speed the Dpid 12 must be on or it will have no effect.
{"TuyaMCU":[{"fnId":11,"dpId":9},{"fnId":21,"dpId":10},{"fnId":12,"dpId":1}]}
Update MQTT with current fan status
Rule1 on TuyaReceived#Data=55AA03070005030400010016 DO publish2 stat/Event/speed 1 endon on TuyaReceived#Data=55AA03070005030400010117 DO publish2 stat/Event/speed 2 endon on TuyaReceived#Data=55AA03070005030400010218 DO publish2 stat/Event/speed 3 endon
Set fan speed based on MQTT message, note this will also turn the fan on when setting the speed
Rule2 on Event#1 DO Backlog Power2 1; TuyaSend4 3, 0 endon on Event#2 DO Backlog Power2 1; TuyaSend4 3, 1 endon on Event#3 DO Backlog Power2 1; TuyaSend4 3, 2 endon
I dont have a fan actually connected to test this and have been using a cheap LED bulb so its hard to confirm but looking at the response from the MCU I’m pretty sure its correct.