xZetsubou / hass-localtuya

🔹 A Home Assistant integration to handle Tuya devices locally "fork from localtuya"

Home Page:https://xzetsubou.github.io/hass-localtuya/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: LocalTuya does not change fan speed

Lurker00 opened this issue · comments

LocalTuya Version

2024.6.0

Home Assistant Version

2024.6.1

Environment

  • Does the device work using the Home Assistant Tuya Cloud component?
  • Is this device connected to another local integration, including Home Assistant and any other tools?
  • The devices are within the same HA subnet, and they get discovered automatically when I add them

What happened?

I have a WiFi fan, with 3 speeds, integers as a list. When I change the speed, the log shows that percentage is correctly translated into the list value, but the speed does not change. You can see on screenshots that the speed control is medium or high, but the value remains 33%. If I change the speed from SmartLife, HA displays 66% or 100% as appropriate.

So, actually, HA/LocalTuya can only turn the fan off or on at the low speed.

Screenshots

Снимок экрана 2024-06-08 125310

Снимок экрана 2024-06-08 125342

Steps to reproduce.

Change fan speed from HA.

Relevant log output

2024-06-08 12:46:42.790 INFO (MainThread) [custom_components.localtuya.fan] Fan async_set_percentage from list: 66 > 2
2024-06-08 12:47:09.071 INFO (MainThread) [custom_components.localtuya.fan] Fan async_set_percentage from list: 100 > 3
2024-06-08 12:49:11.351 INFO (MainThread) [custom_components.localtuya.fan] Fan async_set_percentage from list: 66 > 2
2024-06-08 12:49:28.339 INFO (MainThread) [custom_components.localtuya.fan] Fan async_set_percentage from list: 100 > 3

Diagnostics information.

localtuya-944c1616039a1d1ec6b9745179bff74e-Iot Fan Tower T1 -db41ae908ba13db49c2a0f489757fa32.json

Re-configure the device and choose the DP Value on fan step "str" instead of "int"

It works now! Now I see, that the device_cloud_info defines fan_speed as a string:

        "3": {
          "code": "fan_speed",
          "custom_name": "",
          "dp_id": 3,
          "time": 1717689204394,
          "value": "3",
          "type": "Enum",
          "values": "{\"type\": \"enum\", \"range\": [\"1\", \"2\", \"3\"]}",
          "id": 3,
          "accessMode": "rw"
        },

but it was mistakenly interpreted as int:

          "fan_speed_ordered_list": "1,2,3",
          "fan_dps_type": "int",

It's not about the auto configuration, I mean I don't even understand what's the point of having the user to choose the type of the DP, As far as I saw if the speed DP is defined as "ordered list" and it always "String" and if it' defined as min/max it always "Integer"

I haven't made changes for fan but I may actually force the DP to be string type if speed defined as list, 🤔

It's not about the auto configuration

I can't say for sure that I never touched those settings. OK, it works now and it is good! Thank you!

Not related, but while I can ask you without creating a ticket...

Is it correct that _async_reconnect stops on the first met disabled device?

async def _async_reconnect(now):
"""Try connecting to devices not already connected to."""
reconnect_devices = []
for host, dev in hass_localtuya.devices.items():
dev_id = dev._device_config.id
if check_if_device_disabled(hass, entry, dev_id):
return
if not dev.connected:
asyncio.create_task(dev.async_connect())

I have some disabled devices and now I wonder if they may prevent reconnecting to other devices.

It does may break the reconnect process, thank you for pointing that It should be continue instead of return.

This issue was closed because it was resolved on the release: 2024.7.0