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

Fix '<' not supported between instances of 'str' and 'int' error #1774

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CM707
Copy link

@CM707 CM707 commented Aug 28, 2024

Appears to fix the lights not working issue in #1772

@JampireX
Copy link

I have a similar error in another lines:

Error while setting up localtuya platform for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 364, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/localtuya/common.py", line 96, in async_setup_entry
    entity_class(
  File "/config/custom_components/localtuya/light.py", line 156, in __init__
    self._max_mired = color_util.color_temperature_kelvin_to_mired(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/color.py", line 638, in color_temperature_kelvin_to_mired
    return math.floor(1000000 / kelvin_temperature)
                      ~~~~~~~~^~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for /: 'int' and 'str'

Fixed it by adding same int() converting to lines 157 and 160:

self._config.get(CONF_COLOR_TEMP_MIN_KELVIN, DEFAULT_MIN_KELVIN)

self._config.get(CONF_COLOR_TEMP_MAX_KELVIN, DEFAULT_MAX_KELVIN)

  self._max_mired = color_util.color_temperature_kelvin_to_mired(
      int(self._config.get(CONF_COLOR_TEMP_MIN_KELVIN, DEFAULT_MIN_KELVIN))
  )
  self._min_mired = color_util.color_temperature_kelvin_to_mired(
      int(self._config.get(CONF_COLOR_TEMP_MAX_KELVIN, DEFAULT_MAX_KELVIN))
  )

Maybe it helps someone

@adriaanos
Copy link

Added both of these to my localtuya and restarted it. All working again so thank you very much

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

Successfully merging this pull request may close these issues.

3 participants