Local Tuya - Fan Controller

Hey Stephen,

You’ll have to tell me how you managed to get the slider to move in 18% increments as that was something I wasn’t able to do.

I ended up configuring the fan as a light in Local Tuya. Assign DP 3 (or whatever DP is the speed control in your device) as Brightness when adding the light control. Set Brightness Lower Value as 1 and Brightness Upper Value as 6. This will cause the brightness slider to control the speed. In my case, I set it from 1 to 5 and hence my brightness slider % to fan speed mappings work as follows:

Slider 1% = Speed 1
Slider 25% = Speed 2
Slider 50% = Speed 3
Slider 75% = Speed 4
Slider 100% = Speed 5

Yes, this makes your entity of the type “light” rather than “fan” but apart from this, it works perfectly. No hassles for me so far.

Hope this helps you out.

1 Like

Thanks for your reply

I’ll give it a go

As to the slide increments, I set HA up for entity customisations.

Then I set the following. As you can see I refined the percentage steps

Ah wow. Thanks so much @goldeagle2005 . I just installed a few DC smart fans, and have been having some trouble getting the speed control to work, but your light brightness hack was brilliant.
@Stephen_McKenzie , would you mind sharing some more details on your entity customisation for the speed control? Sorry, I’m still wrapping my head around how HA works, specifically when it comes to customisation like this.

1 Like

Glad it worked for you @daichisuba.

One more thing if it helps. You can also configure a sensor in Local Tuya corresponding to the DP which will display the current speed. Since it is local, any speed change you make via the physical switch will reflect immediately in your dashboard.

Would be amazing if you can share your setup, I’m battling this with a DC SKYFAN. Trying to get it working correctly

Same.

Weeks of guessing and playing with it and then upon stumbling into this thread, I decided to give it another go and I figured out why it wasn’t working but I still don’t know why it doesn’t work in my previous configuration. Here’s what I learned:

If I use this EXACT setup, it works:

For some reason, even though I know my fans respond to high med low, when those settings were in these fields, it would never work. As soon as I changed to 1,2,3 it started working. I tried the small, mid, large and got the same non-results. Now that I have the setting, I am going to copy it to all my other ceiling fans. The light and 3 step speeds and on/off now work with my local tuya fans with this config.

So, I know this config works, but I still don’t know why if you use high, med, low it does nothing. At this point it doesn’t matter to me but it’s something I never considered to alter because I know these fans have always responded to high, med, low.

I hope this helps some other local tuya ceiling fan user and saves the headache of trying all the combinations.

2 Likes

Interesting! Just tried that on one of my Tuya ceiling fans and it didn’t allow me to adjust the speed, just on/off still.

1 Like

It’s unfortunate that is always going to be the case with Tuya …

As it is a platform, with no set standards in place … these various settings are always going to be hit and miss on different manufacturers.

Hello,

I am back again with my fan controllers and local tuya. I got it all set up and working right but then I later realized two fans were not working correctly despite them all being the same. I went through the setup and removal of these two problematic fans multiple times and I finally noticed something different but I don’t know what’s causing it in 2/6 fans.

First, all these controllers were bought at the same time about 3 years ago. They’ve all worked the same all this time. It’s only in the Local Tuya app that I’m having an issue. The fans otherwise work fine and as long as I don’t want to control fan speed, technically the fan controller still works (on/off).

This is what I noticed:
On a successfully running fan:


it says at the top editing an entitiy with DPS 1 and the fan speed control dps is 3 (value: 2). This configuration works flawlessly on 4 fans. No problem here.

Now, move onto the Bedroom and Den fans and when I try to set them up, they BOTH look like this every time despite them being the same device:


You’ll notice that at the top of this one, it recognizes it as a fan, but then doesn’t give me the option for 3(value: 2) which is required to give me the fan speeds.

I don’t understand why only these two are having issues. It’s consistent every time I set them up. Do you folks have any ideas or know where I might look to determine the cause/why it’s reading these similar devices differently?

long shot … on the Tuya app … is there a firmware update for the other 2 fans?

I just confirmed that all 6 fans are on the most recent/same firmware and tried installation again. Same results.

more long shots … there was a recent update to Local Tuya that broke some of my fans … and I had to re-install … did you do the update?

I think that’s the update that caused a few of my fans to break, I reconfigured them and copied them down and I thought they were working for a few days (despite me noticing the difference in the setup) and then realized some days later that the setups were behaving differently.

So I am on the most recent local tuya. Today, trying to fool with it and clicking too much I clicked ‘restore defaults’ in the API Explorer which I idiotically thought would be basic settings. No, wiped them out of Tuya completely; no worries, I readded them, they now have a new ID and local key but I still get the same results on both of these and none of the others.

I just got it to work accidentally on purpose?

I had another local tuya control issue with some light scenes. Long story short, through that exercise, I got deep enough into the local tuya code to be dangerous and I provided a silly workaround which I am prefacing by saying is not the correct approach but is working without adverse effects.

Remembering back how Local Tuya kept detecting two fans as fans and the rest as DPS 1 Entities. The DPS 1 Entities all worked, the imported fans all failed full control. I could not figure out why two fans are recognized differently, nor do I know how to make them be recognized differently. But what I did was change copy the requirements to match the requirements of the fans that were working.


I know the first time local tuya pushes an update, this will be borked, but if I get full local control of all my fans again, I don’t care and I will keep overwriting the code. I’m putting this here because apparently a bunch of us have tuya fans and they’re all different and they all behave differently (even if bought in the same batch) and maybe this will help somebody coming behind me.

Wowza - I have no idea what is going on here … but am happy you managed to find a temporary fix !

May I suggest a more permanent solution?

Since you have all your device details, why not use this ? Then in the Tuya app, select the options you have one at a time, run the above test.py script again after each one and take note of the DPS and it’s value. Do this for however many speed settings you have.

From here you just call service: localtuya.set_dp with the value you want to send. Done.

I have done something similar here, there’s some code there which may help you.

The initial setup probably took the longest. Going forward, this script will come in super handy on future devices.

All the best :+1:

I’ve been putting this off for weeks because I’ve invested so much time in the two remaining fans that use the same device because the integration recognizes them differently. Today, I sat down and just tried every single setting and I got it to work. I replicated it to the other fan and now all the fans work the same. I have removed the Smartlife integration from Alexa which was temporarily doing the lifting on the last 2 fans. I still don’t understand why these are different when they are all the same device; I’m just glad I finally hit the magical combination of settings to make all of them work the same.

Here were the ones that I had no trouble with:


2022-03-13 12_48_53-Greenshot

Here are the ones that I had lots of trouble with because the settings aren’t the same/intuitive:


2022-03-13 12_49_44-Greenshot

I really just hope this helps somebody in the future because this has been a 2 month journey for me.

2 Likes

thx @Sergeantpup and all

I am also spending hours to figure this out with no success

I have gotten the light and switch to both work but no matter what I tried I cannot get the fan speed to work with Home assistant

This is my current simplified configuration.yaml section anther non of the options worked for me


localtuya:
  - host: 192.168.0.194
    device_id: XX
    local_key: YYY
    friendly_name: Office fanlight
    protocol_version: "3.3"
    entities:
      - platform: light
        friendly_name: Light
        id: 15
      - platform: switch
        friendly_name: switch
        id: 1
      - platform: fan
        friendly_name: Fan
        id: 3
        fan_speed_control: 3

I have tried using fan_speed_control, fan_ordered_list, fan_speed_min/max etc with no success

I have also tried via the flow config and enabling Fan speed modes list

nothing seems to work and I always only get an entity with a switch which always beings back the fan speed to 1 no matter what

any help would be super appreciated !

Z

I think you’ve got your numbers mixed up and that would stand to reason the weird behavior

a 3 speed fan with just a basic on/off light:
Fan: DPS 1
Fan speed control: DPS 3
Fan speed mode list: (user choice)
Minimum fan speed: 1
Maximum fan speed: 3
Light: DPS 9

For a 10 speed fan with warm/cool light
Fan: DPS 1
Fan speed control: DPS 3
Fan speed mode list: User choice
Fan Direction: DPS 103
Miniumum fan speed: 1
Maximum fan speed: 10
Light warm: DPS 9
Brightness: 10
Minumum brightness: 1
Maximum brightness: 1000 (yes that’s one thousand)
Light cool: DPS 101
Brightness: 102
Minumum brightness: 1
Maximum brightness: 1000 (yes that’s one thousand)

1 Like

thx so much @Sergeantpup , im a complete neewb and can’t really code so really appreciate your help though I must say im still very confused :slight_smile:

I tried both the control flow and YAML approaches today (wasted the whole day on this :smiley: :smiley: ) but still dont fully understand

I have a 6 speed Tuya fan (with wifi Tuya and an RF remote). i managed to get the switch and light to work but as I said the fan is complete broken/dosent work here.

I have in the developer API page got all the data ie

{
    "result": {
      "category": "fs",
      "functions": [
        {
          "code": "switch",
          "dp_id": 1,
          "type": "Boolean",
          "values": "{}"
        },
        {
          "code": "mode",
          "dp_id": 2,
          "type": "Enum",
          "values": "{\"range\":[\"normal\",\"sleep\",\"nature\"]}"
        },
        {
          "code": "fan_speed",
          "dp_id": 3,
          "type": "Enum",
          "values": "{\"range\":[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\"]}"
        },

so not sure when you say DPS 1 for fan yet DPS3 for speed. in the Gui i think DPS1 is taken by the switch , or am I horribly confusing things? :slight_smile:

in the yaml I tried as you suggested to add the min/Mac speeds but all I get is a toggle that only sends the fan to 1

    entities:
      - platform: light
        friendly_name: Light
        id: 15
      - platform: switch
        friendly_name: switch
        id: 1
      - platform: fan
        friendly_name: Fan
        id: 3
        fan_speed_min: 1
        fan_speed_max: 6

really appreciate your help!

best

Z