sampsyo / hass-smartthinq

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

KeyError: 'AI' #42

Closed dacrypt closed 4 years ago

dacrypt commented 4 years ago
Update of climate.ar_condicionado is taking over 10 seconds
10:35 PM __main__.py (WARNING) - message first occurred at 10:13 PM and shows up 2 times
'AI'
10:15 PM custom_components/smartthinq/climate.py (ERROR) - message first occurred at 10:09 PM and shows up 5 times
Error doing job: Task exception was never retrieved
10:14 PM custom_components/smartthinq/climate.py (ERROR) - message first occurred at 10:10 PM and shows up 5 times
Setup of climate platform smartthinq is taking over 10 seconds.
10:01 PM __main__.py (WARNING)

2020-01-20 22:01:42 WARNING (MainThread) [homeassistant.components.climate] Setup of climate platform smartthinq is taking over 10 seconds.
2020-01-20 22:09:26 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.2936089392] 'AI'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 134, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1226, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1251, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 201, in handle_service
    self._platforms.values(), func, call, service_name, required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 335, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 368, in _handle_service_platform_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    state = self.state
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 165, in state
    return self.hvac_mode
  File "/config/custom_components/smartthinq/climate.py", line 185, in hvac_mode
    return MODES[mode.name]
KeyError: 'AI'
2020-01-20 22:09:29 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.2936089392] 'AI'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 134, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1226, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1251, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 201, in handle_service
    self._platforms.values(), func, call, service_name, required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 335, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 368, in _handle_service_platform_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    state = self.state
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 165, in state
    return self.hvac_mode
  File "/config/custom_components/smartthinq/climate.py", line 185, in hvac_mode
    return MODES[mode.name]
KeyError: 'AI'
2020-01-20 22:10:51 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    state = self.state
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 165, in state
    return self.hvac_mode
  File "/config/custom_components/smartthinq/climate.py", line 185, in hvac_mode
    return MODES[mode.name]
KeyError: 'AI'
2020-01-20 22:11:52 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    state = self.state
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 165, in state
    return self.hvac_mode
  File "/config/custom_components/smartthinq/climate.py", line 185, in hvac_mode
    return MODES[mode.name]
KeyError: 'AI'
2020-01-20 22:12:45 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.2936089392] 'AI'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 134, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1226, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1251, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 201, in handle_service
    self._platforms.values(), func, call, service_name, required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 335, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 368, in _handle_service_platform_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    state = self.state
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 165, in state
    return self.hvac_mode
  File "/config/custom_components/smartthinq/climate.py", line 185, in hvac_mode
    return MODES[mode.name]
KeyError: 'AI'
2020-01-20 22:13:03 WARNING (MainThread) [homeassistant.helpers.entity] Update of climate.ar_condicionado is taking over 10 seconds
2020-01-20 22:13:04 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    state = self.state
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 165, in state
    return self.hvac_mode
  File "/config/custom_components/smartthinq/climate.py", line 185, in hvac_mode
    return MODES[mode.name]
KeyError: 'AI'
2020-01-20 22:13:54 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    state = self.state
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 165, in state
    return self.hvac_mode
  File "/config/custom_components/smartthinq/climate.py", line 185, in hvac_mode
    return MODES[mode.name]
KeyError: 'AI'
2020-01-20 22:14:55 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    state = self.state
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 165, in state
    return self.hvac_mode
  File "/config/custom_components/smartthinq/climate.py", line 185, in hvac_mode
    return MODES[mode.name]
KeyError: 'AI'
2020-01-20 22:15:35 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.2936089392] 'AI'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 134, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1226, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1251, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 201, in handle_service
    self._platforms.values(), func, call, service_name, required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 335, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 368, in _handle_service_platform_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    state = self.state
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 165, in state
    return self.hvac_mode
  File "/config/custom_components/smartthinq/climate.py", line 185, in hvac_mode
    return MODES[mode.name]
KeyError: 'AI'
2020-01-20 22:15:47 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.2936089392] 'AI'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 134, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1226, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1251, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 201, in handle_service
    self._platforms.values(), func, call, service_name, required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 335, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 368, in _handle_service_platform_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 284, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    state = self.state
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 165, in state
    return self.hvac_mode
  File "/config/custom_components/smartthinq/climate.py", line 185, in hvac_mode
    return MODES[mode.name]
KeyError: 'AI'
2020-01-20 22:35:24 WARNING (MainThread) [homeassistant.helpers.entity] Update of climate.ar_condicionado is taking over 10 seconds```
dacrypt commented 4 years ago

I think the AI mode that my AC unit report seems to be missing and generating this error.

After reading https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/climate/const.py

# The temperature is set based on a schedule, learned behavior, AI or some
# other related mechanism. User is not able to adjust the temperature
HVAC_MODE_AUTO = 'auto'

I ended up modifying climate.py (line 24), and managed to get rid of the error just adding the following modification:

MODES = {
    'AI': c_const.HVAC_MODE_AUTO,
    'HEAT': c_const.HVAC_MODE_HEAT,
    'COOL': c_const.HVAC_MODE_COOL,
    'FAN': c_const.HVAC_MODE_FAN_ONLY,
    'DRY': c_const.HVAC_MODE_DRY,
    'ACO': c_const.HVAC_MODE_HEAT_COOL,
}

This should be fixed better since AI mode should allow to set a mode ranging from -2 to 2 (https://www.lg.com/in/support/product-help/CT20150054-20150225230433-others)

sampsyo commented 4 years ago

OK, cool! I think we should apply this even if it’s only a partial solution for the “AI” mode. Would you mind opening a pull request?

dacrypt commented 4 years ago

OK, cool! I think we should apply this even if it’s only a partial solution for the “AI” mode. Would you mind opening a pull request?

there you go -> #43