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

API Difference Causing issues w/ Home Assistant Integration #11

Open
EvanSchalton opened this issue Mar 13, 2024 · 3 comments
Open

API Difference Causing issues w/ Home Assistant Integration #11

EvanSchalton opened this issue Mar 13, 2024 · 3 comments

Comments

@EvanSchalton
Copy link

In the Tuya IOT platform console when I call the Query Devices in Home endpoint https://openapi.tuyaus.com/v1.0/homes/{home_id}/devices or the Get Device Status or Get Device Details https://openapi.tuyaus.com/v1.0/devices/{device_id}/status, https://openapi.tuyaus.com/v1.0/devices/{device_id} I get all of the fields for the device including the fields added by setting the Select Control Instruction Mode to DP Instruction instead of Standard Instruction

However, the apigw api used in the repo only returns the Standard Instructions

@gautamkrishnar
Copy link

gautamkrishnar commented Mar 18, 2024

Hi, I am also getting issues like the following one:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 576, in _async_add_entities
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 865, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1328, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 992, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1113, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1052, in __async_calculate_state
    attr.update(self.state_attributes or {})
                ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 1202, in state_attributes
    data[ATTR_BRIGHTNESS] = self.brightness
                            ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/tuya/light.py", line 648, in brightness
    brightness = self._brightness.remap_value_to(brightness)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/tuya/base.py", line 63, in remap_value_to
    return remap_value(value, self.min, self.max, to_min, to_max, reverse)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/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 -: 'str' and 'int'
2024-03-18 23:37:25.678 ERROR (MainThread) [homeassistant.components.light] Error adding entity light.bathroom_light for domain light with platform tuya
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 576, in _async_add_entities
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 865, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1328, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 992, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1113, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1052, in __async_calculate_state
    attr.update(self.state_attributes or {})
                ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 1202, in state_attributes
    data[ATTR_BRIGHTNESS] = self.brightness
                            ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/tuya/light.py", line 648, in brightness
    brightness = self._brightness.remap_value_to(brightness)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/tuya/base.py", line 63, in remap_value_to
    return remap_value(value, self.min, self.max, to_min, to_max, reverse)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/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 -: 'str' and 'int'

This could be maybe due to this bug.

Ref: home-assistant/core#111839

cc: @shihuimiao

@sliekens
Copy link

+1 for adding non-standardized data points

Many Smartlife features are currently unavailable in HA because they rely on data points outside the standard set.

@vogt31337
Copy link

+1

the api version seems to be quite outdated: It uses v1.0 as an endpoint, probably a reason why newer features are not available in HA. Current version seems to be v2.0, which would bring a lot of interesting enhancements.

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

No branches or pull requests

4 participants