Local Tuya - Fan Controller

thx @tboss !

this is really helpful!

Z

This is wild! I’ve not observed any of this except whenever I used the wrong commands in the setup. Mine have been rock solid since but your devices are obviously requiring something different. I wonder what the difference is and more importantly can we put in a PR to code against it. I am using two different tuya fan controllers.

Thank you for the detailed info.

Just installed a new fan and have come across this same issue. I have a 6 speed Fanco Infinity fan with no light.

The primary issue is identical to above where setting a speed in home assistant causes the fan to turn off and the speed in HA to revert to the previous remote setting.

If i use the tuya app or remote to change the fan speed HA reflects this change correctly.

The default tuya integration seems to have a 0-100 slider and works fine triggering the fan speed to change to the nearest appropriate value (1-6)

My fan also has a natural wind mode where it changes the speed periodically between 2 and 6. I have that working as a separate select entity also. Couldn’t see how else to do it.
image

@mjanofsky I have tread through this whole thread and I am still very confused on what is going on with my setup and I would really appreciate some help. I purchased two of these last year:

Both work with Google Assistant and the include controller. But I can’t get them to work on Local Tuya for the life of me. This is what I see when I go to add the entity:

As you can see, I’m seeing ID instead of DPS# at the top. Not sure what to do about that. Toggling the fan in Devices does absolutely nothing, regardless of whether the fan is on or not.

In order to provide full details, I am running Home Assistant on my Windows NUC via VirtualBox.
Home Assistant 2022.7.6
Supervisor 2022.07.0
Operating System 8.2
Frontend 20220707.1 - latest
Local Tuya v4.0.1

I know Local Tuya works with my smart outlets as I had added one as a switch, which worked beautifully, even as a button on my dashboard.

My goal for this ceiling fan/light control in HA is a button for the light to turn on/off and a way to adjust the fan between the off/3 speeds (4 settings I guess).

Hi there,

I was facing too the problem about the fan speed. It was not working properly when sending a percentage. Looking at the code and debugging I was able to solve the issue.

I’ve made a pull request (BUG: updating the percentage was not working by albetaCOM · Pull Request #996 · rospogrigio/localtuya · GitHub) so the issue can be solved in the next component versions.

Meantime if anyone want to do it is pretty straight forward:

  • go to edit /config/custom_components/localtuya/fan.py
  • remove from line 141
                    str(
                        percentage_to_ordered_list_item(self._ordered_list, percentage)
                    ),

and place instead

                    percentage_to_ordered_list_item(self._ordered_list, percentage)
                    ,
  • remove from line 154
                    str(
                        math.ceil(
                            percentage_to_ranged_value(self._speed_range, percentage)
                        )
                    ),

and place

                    math.ceil(
                        percentage_to_ranged_value(self._speed_range, percentage)
                    ),

Just be careful with the indentation.

I hope it is helpfull.

7 Likes

Oh man - you are a saviour !!! Thank you so much

Right so removing the str function part? nice find

Yes, that’s right. It was sending the value as a string instead of a integer.

I updated my version of the repo as well, if anyone is interested.

From there you can navigate to custom_components/localtuya and the modified file is fan.py.

1 Like

Fixed my problem. Thank you.

thanx. Fan speed is now working for me.

How do we get your file to replace the original code? (In future updates)

Hello all,
Is it possible to program the above setting via the localtuya HA integration?

I already have the lights and setup via localtuya working with HA. I just need to figure out how to add the mode: ‘normal, sleep, nature’ so that I won’t have to rely on the smart app to do so.

Any insight will be greatly appreciated.

After hours of playing around with the LocalTuya, I was finally able to get this
Smart Ceiling Fan 52’’ " to work with HA emulating the settings from the SmartHome app.

See Images
Settings to choose via LocalTuya: Select & DP2

Can you let us know how you got the lights into the app ? I have been trying to do that for a while now


If anyone is having issues with this again, having previously addressed it from this post like me… I’ve posted here what I observed: Fan Speed Control, device expect integer but fan integration send string instead for fan control · Issue #1036 · rospogrigio/localtuya · GitHub

Basically localtuya 4.1.1 has sought to address the issue, but for some reason I don’t see the new configuration option that allows you to choose str or int, and as the code assumes str type its essentially reverted to the issue state for me.

I’ve reversed the logic in fan.py as a workaround that suits my situation:

Changed line 78…

self._dps_type = int if self._config.get(CONF_FAN_DPS_TYPE) == "int" else str

To…

self._dps_type = str if self._config.get(CONF_FAN_DPS_TYPE) == "str" else int

I do see the option to choose string or int at the bottom of the fan configuration page. and int does seem to work for me where as i has the issue before same as others.

Last thing i’m trying to figure out is the fan modes. I can do it as a seperate entity but id love to have just one fan entity.

How did you get this screen to come up? I can’t find it anywhere in Local Tuya.

Hi there,

What were the steps you took to get this screen to come up. Was it YAML config or something else. I would like to do the same thing, but can’t follow your example.