Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error adding entity fan.ceiling_fan_with_light for domain fan with platform tuya #117991

Open
sdmorris1950 opened this issue May 23, 2024 · 3 comments
Assignees

Comments

@sdmorris1950
Copy link

The problem

I have a Tuya ceiling fan with a light. I can control both the fan speed, timer and direction in the Tuya app and with Alexa. However, when I added it to HA, I can control the light, but the fan is listed as unavailable with the message "This entity is no longer being provided by the Tuya integration." The entity is entity fan.ceiling_fan_with_light.

I have attached the log for the error and the diagnostic

fan.ceiling_fan_with_light log.txt
tuya-befa4c451b1ff6e4eb2455af72e6c599-Ceiling Fan With Light-4f572d2bc74121abdfe7a26be516a4e5.json

What version of Home Assistant Core has the issue?

core-2024.5.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Tuya

Link to integration documentation on our website

No response

Diagnostics information

tuya-befa4c451b1ff6e4eb2455af72e6c599-Ceiling Fan With Light-4f572d2bc74121abdfe7a26be516a4e5.json

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.fan
Source: helpers/entity_platform.py:580
integration: Fan (documentation, issues)
First occurred: 16:00:15 (1 occurrences)
Last logged: 16:00:15

Error adding entity fan.ceiling_fan_with_light for domain fan with platform tuya
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 580, in _async_add_entities
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 892, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1359, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1009, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1132, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1069, in __async_calculate_state
    if state_attributes := self.state_attributes:
                           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/fan/__init__.py", line 420, in state_attributes
    data[ATTR_PERCENTAGE] = self.percentage
                            ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/tuya/fan.py", line 254, in percentage
    return ordered_list_item_to_percentage(self._speeds.range, value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/percentage.py", line 33, in ordered_list_item_to_percentage
    raise ValueError(f'The item "{item}" is not in "{ordered_list}"')
ValueError: The item "3" is not in "['1', '2', '3', '4', '5', '6']"

Additional information

No response

@home-assistant
Copy link

Hey there @tuya, @zlinoliver, @frenck, mind taking a look at this issue as it has been labeled with an integration (tuya) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of tuya can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign tuya Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


tuya documentation
tuya source
(message by IssueLinks)

@DukeBlackadder
Copy link

DukeBlackadder commented Jun 13, 2024

I have almost the exact same issue. A Tuya ceiling fan with a light. It used to work fine, but now I get the same error as you for the light entity. Fan control works as usual.

Maybe worth to mention is that I also see the same issue with LocalTuya. Remote control and Tuya app control works fine, so there is not a broken ceiling fan.

@chpeck
Copy link

chpeck commented Jun 17, 2024

Seems like a mismatch in types.

Was able to work around with

`--- fan.py
+++ fan.py.orig
@@ -250,7 +250,7 @@
if self._speeds is not None:
if (value := self.device.status.get(self._speeds.dpcode)) is None:
return None

  •        return ordered_list_item_to_percentage(self._speeds.range, str(value))                                                                               
    
  •        return ordered_list_item_to_percentage(self._speeds.range, value)   
                                                                               
       return None          
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants