Harmony Hub Climate Component for A/C integration

Hi,
I tried to configure this integration but I have this type of error in My home-assistant.log:

2021-07-04 18:36:58 ERROR (MainThread) [homeassistant.components.climate] Error adding entities for domain climate with platform harmony_ac
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 383, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 588, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 614, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/harmony_ac/climate.py", line 155, in async_added_to_hass
    self._current_fan_mode = last_state.attributes['fan_mode']
KeyError: 'fan_mode'
2021-07-04 18:36:58 ERROR (MainThread) [homeassistant.components.climate] Error while setting up harmony_ac platform for climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 258, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 383, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 588, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 614, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/harmony_ac/climate.py", line 155, in async_added_to_hass
    self._current_fan_mode = last_state.attributes['fan_mode']
KeyError: 'fan_mode'

Can someone help me to resolve this issue?

HA Version core-2021.6.6

Thanks in advance.

There is a key error: ‘fan_mode’. In your configuration you should have fan_modes (with an ‘s’ at the end). I guess this might cause the error.

This is my configuration:

  - platform: harmony_ac
    name: Condizionatore Piano Terra
    remote_entity: remote.harmony_hub
    device_id: 75313445
    min_temp: 23
    max_temp: 30
    target_temp: 27
    target_temp_step: 1
    temp_sensor: sensor.temperature_158d00025ee70a
    customize:
      operations:
        - cool
        - dry
      no_temp_operations:
        - dry
      fan_modes:
        - auto
        - night

As you can see fan_modes entry is correct.

“night” doesn’t seem to be a valid option for fan modes. Only auto, low, mid, high are accepted as per the documentation.

Thanks suxlala.
I tried to change my configuration:

  - platform: harmony_ac
    name: Condizionatore Piano Terra
    remote_entity: remote.harmony_hub
    device_id: 75313445
    min_temp: 23
    max_temp: 30
    target_temp: 27
    target_temp_step: 1
    temp_sensor: sensor.temperature_158d00025ee70a
    customize:
      operations:
        - cool
        - dry
      no_temp_operations:
        - dry
      fan_modes:
        - auto
#        - night

but the error seems to be the same:

2021-07-05 17:18:33 ERROR (MainThread) [homeassistant.components.climate] Error adding entities for domain climate with platform harmony_ac
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 383, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 588, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 614, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/harmony_ac/climate.py", line 155, in async_added_to_hass
    self._current_fan_mode = last_state.attributes['fan_mode']
KeyError: 'fan_mode'
2021-07-05 17:18:34 ERROR (MainThread) [homeassistant.components.climate] Error while setting up harmony_ac platform for climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 258, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 383, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 588, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 614, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/harmony_ac/climate.py", line 155, in async_added_to_hass
    self._current_fan_mode = last_state.attributes['fan_mode']
KeyError: 'fan_mode'

Sorry @sverri then I have no clue about this error. I have a very similar config and it works fine.

Sorry @suxlala which is your HA configuration?
I have a rasperry pi with Hassio and HA Version core-2021.6.6.
Is the same for you?

I’m on a NUC with Hassio core 2021.6.6.
So I don’t think the config would be the issue. Have you tried to remove and reinstall, reboot, clear cache etc?

Thanks again @suxlala.
I have cancelled Climate integration from Hacs rebooted HA and reinstalled.
The error seems to be generated when the component try to get the last_state that should be null while it result “Not None”.