sampsyo / hass-smartthinq

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

Add support for ENERGY_SAVER #61

Closed dmcc closed 4 years ago

dmcc commented 4 years ago

Without this, certain models get this error:

Traceback (most recent call last):
  File "[...]/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 286, in async_update_ha_state
    self._async_write_ha_state()
  File "[...]/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    state = self.state
  File "[...]/lib/python3.6/site-packages/homeassistant/components/climate/__init__.py", line 165, in state
    return self.hvac_mode
  File "[...]/config/custom_components/smartthinq/climate.py", line 188, in hvac_mode
    return MODES[mode.name]
KeyError: 'ENERGY_SAVER'

Arguably, AUTO is the wrong mapping here, but it seemed like the best fit to me (the model in question has "energy saver", "cool", "dry", and "fan" modes).

sampsyo commented 4 years ago

Hey, thanks for pointing this out! As of #49, I think this should not cause a crash for models where this particular mode is unsupported, so this is probably safe.

In the future, however, it would probably be better to expose these things as "presets" rather than "modes": https://developers.home-assistant.io/docs/core/entity/climate/#presets

Which are more free-form. There is a built-in "eco" preset for an energy saver mode.