home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.67k stars 30.43k forks source link

Tuya ceiling fan - does not support light #64762

Closed fOmey closed 2 years ago

fOmey commented 2 years ago

The problem

I recently installed a ceiling fan and the light feature is missing from the tuya component.

FanCapture1

FanCapture2

FanCapture3

I've added the following to light.py and I'm able to toggle the light on/off, however unable to control brightness / colour temp.

    # Fan
    # https://developer.tuya.com/en/docs/iot/categoryfs?id=Kaiuz1xweel1c
    "fs": (
        TuyaLightEntityDescription(
            key=DPCode.LIGHT,
            brightness=DPCode.BRIGHT_VALUE,
            color_temp=DPCode.TEMP_VALUE,
        ),
    ),

What version of Home Assistant Core has the issue?

core-2021.12.10

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

https://www.home-assistant.io/integrations/tuya/

Example YAML snippet

No response

Anything in the logs that might be useful for us?

[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
     
2022-01-23 22:58:09 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
     
2022-01-23 22:58:09 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration tuya which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2022-01-23 22:58:14 WARNING (MainThread) [slixmpp.stringprep] Using slower stringprep, consider compiling the faster cython/libidn one.
2022-01-23 22:58:16 WARNING (MainThread) [slixmpp.basexmpp] Legacy XMPP 0.9 protocol detected.
2022-01-23 22:58:21 ERROR (SyncWorker_1) [homeassistant] Error doing job: Task was destroyed but it is pending!
2022-01-23 23:00:10 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.load_1m (None) does not match the unit of already compiled statistics ( ). Generation of long term statistics will be suppressed unless the unit changes back to  
2022-01-23 23:00:10 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.load_5m (None) does not match the unit of already compiled statistics ( ). Generation of long term statistics will be suppressed unless the unit changes back to  
2022-01-23 23:00:10 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.load_15m (None) does not match the unit of already compiled statistics ( ). Generation of long term statistics will be suppressed unless the unit changes back to  
2022-01-23 23:03:08 ERROR (MainThread) [homeassistant.util.logging] Exception in async_write_ha_state when dispatching 'tuya_entry_update_bf645c91669b5005aaa5ot': ()
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 505, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 540, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 896, in state_attributes
    data[ATTR_BRIGHTNESS] = self.brightness
  File "/config/custom_components/tuya/light.py", line 542, in brightness
    brightness = self._brightness.remap_value_to(brightness)
  File "/config/custom_components/tuya/base.py", line 62, in remap_value_to
    return remap_value(value, self.min, self.max, to_min, to_max, reverse)
  File "/config/custom_components/tuya/util.py", line 16, in remap_value
    return ((value - from_min) / (from_max - from_min)) * (to_max - to_min) + to_min
TypeError: unsupported operand type(s) for -: 'int' and 'str'

2022-01-23 23:03:36 WARNING (Thread-6) [pychromecast.socket_client] [Kitchen Speaker(192.168.1.163):8009] Heartbeat timeout, resetting connection
2022-01-23 23:03:39 ERROR (MainThread) [homeassistant.util.logging] Exception in async_write_ha_state when dispatching 'tuya_entry_update_bf645c91669b5005aaa5ot': ()
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 505, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 540, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 896, in state_attributes
    data[ATTR_BRIGHTNESS] = self.brightness
  File "/config/custom_components/tuya/light.py", line 542, in brightness
    brightness = self._brightness.remap_value_to(brightness)
  File "/config/custom_components/tuya/base.py", line 62, in remap_value_to
    return remap_value(value, self.min, self.max, to_min, to_max, reverse)
  File "/config/custom_components/tuya/util.py", line 16, in remap_value
    return ((value - from_min) / (from_max - from_min)) * (to_max - to_min) + to_min
TypeError: unsupported operand type(s) for -: 'int' and 'str'

Additional information

No response

probot-home-assistant[bot] commented 2 years ago

tuya documentation tuya source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @tuya, @zlinoliver, @metisu, @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! (message by CodeOwnersMention)

fOmey commented 2 years ago

There is also missing features: natural mode, fan direction and sleep timer which are all avalible in the tuya smart / smart life tuya android app.