Andre0512 / hon

Home Assistant integration for Haier hOn: support for Haier/Candy/Hoover home appliances like washing machines and air conditioners in 28 languages.
MIT License
1.23k stars 2.49k forks source link

Integration fails to set up on 2024.1 #140

Closed finalbillybong closed 3 months ago

finalbillybong commented 4 months ago

Logs below:

Logger: homeassistant.loader
Source: loader.py:842 
First occurred: 21:52:43 (2 occurrences) 
Last logged: 21:52:43

Unexpected exception importing platform custom_components.haier_hon.switch
Unexpected exception importing platform custom_components.haier_hon.binary_sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 842, in get_platform
    cache[full_name] = self._import_platform(platform_name)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 859, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_components/haier_hon/switch.py", line 25, in <module>
    @dataclass
     ^^^^^^^^^
  File "/usr/local/lib/python3.11/dataclasses.py", line 1230, in dataclass
    return wrap(cls)
           ^^^^^^^^^
  File "/usr/local/lib/python3.11/dataclasses.py", line 1220, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dataclasses.py", line 1027, in _process_class
    _init_fn(all_init_fields,
  File "/usr/local/lib/python3.11/dataclasses.py", line 545, in _init_fn
    raise TypeError(f'non-default argument {f.name!r} '
TypeError: non-default argument 'key' follows default argument
Logger: homeassistant.setup
Source: setup.py:403 
First occurred: 21:52:43 (2 occurrences) 
Last logged: 21:52:43

Unable to prepare setup for platform 'hon.switch': Platform not found (Exception importing custom_components.haier_hon.switch).
Unable to prepare setup for platform 'hon.binary_sensor': Platform not found (Exception importing custom_components.haier_hon.binary_sensor).
willhaggan commented 4 months ago

Same issue on 2024.1.1

Andre0512 commented 4 months ago

Hi, do you use the recent version? The error message makes no sense :thinking:

Andre0512 commented 4 months ago

Please check out v0.11.0-beta.1, maybe you can profit from another fix

finalbillybong commented 4 months ago

Please check out v0.11.0-beta.1, maybe you can profit from another fix

Thank you but I’m getting same error with this version I am afraid.

Logger: homeassistant.config_entries
Source: config_entries.py:561
First occurred: 10:21:31 (2 occurrences)
Last logged: 10:21:31

Error unloading entry xxx@xxx.com for switch
Error unloading entry xxx@xxx.com for binary_sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 561, in async_unload
    result = await component.async_unload_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/switch/__init__.py", line 105, in async_unload_entry
    return await component.async_unload_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 203, in async_unload_entry
    raise ValueError("Config entry was never loaded!")
ValueError: Config entry was never loaded!
Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:507
Integration: Sensor (documentation, issues)
First occurred: 10:19:36 (1 occurrences)
Last logged: 10:19:36

Error adding entities for domain sensor with platform hon
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1276, in add_to_platform_finish
    await self.async_internal_added_to_hass()
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 303, in async_internal_added_to_hass
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Entity sensor.tumble_dryer_suggested_load cannot be added as the entity category is set to config
Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:368
Integration: Sensor (documentation, issues)
First occurred: 10:19:36 (1 occurrences)
Last logged: 10:19:36

Error while setting up hon platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 368, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1276, in add_to_platform_finish
    await self.async_internal_added_to_hass()
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 303, in async_internal_added_to_hass
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Entity sensor.tumble_dryer_suggested_load cannot be added as the entity category is set to config
finalbillybong commented 3 months ago

Just tested 2024.1.4 and this error persists for me even with v0.11.0

Andre0512 commented 3 months ago

Hi, so your error message says that the suggested load (Load Capacity) cannot be added as the entity category is set to config. But I changed the category to diagnostic since v0.10.1, with this change and for me it's displayed in the right category, see here: image So I'm wondering if you really on the latest version, can you check if the version is correct installed and the category is set to diagnostics in sensor.py :thinking:

finalbillybong commented 3 months ago

Thanks for getting back to me on this. I am sure you're busy with other things, so I appreciate it.

I have this line in my sensor.py:

@dataclass class HonConfigSensorEntityDescription(SensorEntityDescription): entity_category: EntityCategory = EntityCategory.CONFIG option_list: Dict[str, str] = None

So that seems correct to me?

finalbillybong commented 3 months ago

I will delete the whole hon folder and manually install the latest update from here and then update HA and see what happens!

Andre0512 commented 3 months ago

I have this line in my sensor.py:

@dataclass class HonConfigSensorEntityDescription(SensorEntityDescription): entity_category: EntityCategory = EntityCategory.CONFIG option_list: Dict[str, str] = None

So that seems correct to me?

It must be EntityCategory.DIAGNOSTIC, so I think it's a problem with the update process. I don't know how this can happen, maybe a problem with HACS.

I will delete the whole hon folder and manually install the latest update from here and then update HA and see what happens!

That will fix it I think :slightly_smiling_face:

finalbillybong commented 3 months ago

Yep that did it. Thank you, @Andre0512 - I do wonder what happened though to cause this tangle....