Skip to content

ValueError in Tuya fan integration: item "1" not found in string list ['1', '2', '3', '4', '5', '6'] #149858

@RabbitEmotion

Description

@RabbitEmotion

The problem

I'm encountering a ValueError related to the Tuya fan integration in Home Assistant. It appears to be a type mismatch when converting fan speed values using ordered_list_item_to_percentage.
Traceback

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1535, in _async_process_registry_update_or_remove
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1018, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1140, in _async_write_ha_state
self.__async_calculate_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1082, in __async_calculate_state
if state_attributes := self.state_attributes:
File "/usr/src/homeassistant/homeassistant/components/fan/init.py", line 402, in state_attributes
data[ATTR_PERCENTAGE] = self.percentage
File "/usr/src/homeassistant/homeassistant/components/tuya/fan.py", line 259, in percentage
return ordered_list_item_to_percentage(self._speeds.range, value)
File "/usr/src/homeassistant/homeassistant/util/percentage.py", line 29, in ordered_list_item_to_percentage
raise ValueError(f'The item "{item}" is not in "{ordered_list}"')
ValueError: The item "1" is not in "['1', '2', '3', '4', '5', '6']"

What version of Home Assistant Core has the issue?

core-2025.7.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Tuya

Link to integration documentation on our website

No response

Diagnostics information

tuya-fan.json

Example YAML snippet

Anything in the logs that might be useful for us?

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions