From ded9c231002b29889ab938fdda650553fa2bdf9b Mon Sep 17 00:00:00 2001 From: Naoki Sawada Date: Mon, 1 Jul 2024 23:29:06 +0900 Subject: [PATCH] Fix #147 index error when swing_modes is empty (#148) Fixed index error when fan_modes or swing_modes is empty --- custom_components/tasmota_irhvac/climate.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/custom_components/tasmota_irhvac/climate.py b/custom_components/tasmota_irhvac/climate.py index 53df2d6..c916f89 100644 --- a/custom_components/tasmota_irhvac/climate.py +++ b/custom_components/tasmota_irhvac/climate.py @@ -618,12 +618,14 @@ def __init__( new_fan_list.append(val) self._attr_fan_modes = new_fan_list if len(new_fan_list) else None self._attr_fan_mode = ( - self._attr_fan_modes[0] if isinstance(self._attr_fan_modes, list) else None + self._attr_fan_modes[0] + if isinstance(self._attr_fan_modes, list) and len(self._attr_fan_modes) + else None ) self._attr_swing_modes = config.get(CONF_SWING_LIST) self._attr_swing_mode = ( self._attr_swing_modes[0] - if isinstance(self._attr_swing_modes, list) + if isinstance(self._attr_swing_modes, list) and len(self._attr_swing_modes) else None ) self._attr_preset_modes = (