sampsyo / hass-smartthinq

Home Assistant component for LG SmartThinQ HVAC devices
MIT License
281 stars 98 forks source link

Need a bytes-like object error #90

Closed krystof-k closed 3 years ago

krystof-k commented 3 years ago

Hey there, getting following error after setting up:

2020-11-20 13:15:43 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for smartthinq 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.
2020-11-20 13:16:10 WARNING (MainThread) [homeassistant.setup] Setup of hassio is taking over 10 seconds.
2020-11-20 13:16:10 WARNING (MainThread) [homeassistant.setup] Setup of person is taking over 10 seconds.
2020-11-20 13:16:24 WARNING (MainThread) [homeassistant.setup] Setup of input_number is taking over 10 seconds.
2020-11-20 13:16:24 WARNING (MainThread) [homeassistant.setup] Setup of media_source is taking over 10 seconds.
2020-11-20 13:16:24 WARNING (MainThread) [homeassistant.setup] Setup of tag is taking over 10 seconds.
2020-11-20 13:16:25 WARNING (MainThread) [homeassistant.setup] Setup of input_text is taking over 10 seconds.
2020-11-20 13:16:27 WARNING (MainThread) [homeassistant.setup] Setup of zone is taking over 10 seconds.
2020-11-20 13:21:03 WARNING (MainThread) [homeassistant.components.climate] Setup of climate platform smartthinq is taking over 10 seconds.
2020-11-20 13:21:05 ERROR (MainThread) [homeassistant.components.climate] Error while setting up smartthinq platform for climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 201, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 310, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 447, in _async_add_entity
    entity.entity_id = entity_registry.async_generate_entity_id(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 177, in async_generate_entity_id
    preferred_string = f"{domain}.{slugify(suggested_object_id)}"
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 47, in slugify
    return unicode_slug.slugify(text, separator=separator)  # type: ignore
  File "/usr/local/lib/python3.8/site-packages/slugify/slugify.py", line 104, in slugify
    text = _unicode(text, 'utf-8', 'ignore')
TypeError: decoding to str: need a bytes-like object, float found

Any idea? wideq lists ACs correctly. Thanks!

sampsyo commented 3 years ago

Alas, this error is coming from too deep within Home Assistant core to make it clear what the problem is. A bit of debugging to figure out where that text value is coming from would be the first step.

krystof-k commented 3 years ago

Thanks, do you have any idea where to start? I assume it is trying to generate entity ID from the AC name.

krystof-k commented 3 years ago

I think I know where the problem is: I have named the ACs like 3.12 (room number). And it interprets it as a float.

krystof-k commented 3 years ago

So probably just do something like

return str(self._device.name)

here would help, right?

sampsyo commented 3 years ago

Sure, seems worth a shot! But perhaps it would be good to go even farther, to the source, where we set that name attribute, which is always supposed to be a string but apparently is not? https://github.com/sampsyo/wideq/blob/ec0da0d4c2f8c26268e65999f5564e67165f7b3f/wideq/client.py#L295

krystof-k commented 3 years ago

Right. I'll try to open up an PR and I'm closing this. Renaming the ACs helped, unfortunately I still see only 5/7 as the two have probably FW with API v2.