I've noticed this issue for a while now, and not sure if anyone else took a look at this error. I'd like to note that I have a Gree Livo GEN4 system, so this might be isolated to this system. I am using HomeAssistant, with the built in Gree integration to control the units. I believe that there is some difference in the way that units are being converted between the internal system and this python package. In addition, whenever this StopIteration error is raised, this prevents climate entities from being initiated, as shown below. When using other integrations, like BetterThermostat (which change the target temperature frequently), these errors will cause HomeAssistant to eventually crash.
2024-05-14 14:59:32.495 ERROR (MainThread) [homeassistant.components.climate] Error adding entity climate.9424b87e771f for domain climate with platform gree
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1334, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1119, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1058, in async_calculate_state
attr.update(self.state_attributes or {})
^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/climate/init.py", line 328, in getattribute
return super().getattribute(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/climate/init.py", line 526, in state_attributes
self.target_temperature,
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/climate/init.py", line 328, in getattribute
return super().getattribute(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/gree/climate.py", line 150, in target_temperature
return self.coordinator.device.target_temperature
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/greeclimate/device.py", line 357, in target_temperature
return self._convert_to_units(temSet, temRec)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/greeclimate/device.py", line 350, in _convert_to_units
f = next(t for t in TEMP_TABLE if t["temSet"] == value and t["temRec"] == bit)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
StopIteration
The specific instance I've captured is this packet from the unit giving the problem:
Evidently, the unit is reporting a temSet of 25, and a temRec of 1. The generated table of this python package doesn't have this value, and will raise the StopIteration error. I confirmed that if I pick a value that is in the table, HomeAssistant stops complaining, and adds the climate entity as expected.
I created a PR that just picks the closest value in the generated table. This resolves the issue more or less, and unless someone wants to dedicate more time, this is workable for my use case.
I've noticed this issue for a while now, and not sure if anyone else took a look at this error. I'd like to note that I have a Gree Livo GEN4 system, so this might be isolated to this system. I am using HomeAssistant, with the built in Gree integration to control the units. I believe that there is some difference in the way that units are being converted between the internal system and this python package. In addition, whenever this StopIteration error is raised, this prevents climate entities from being initiated, as shown below. When using other integrations, like BetterThermostat (which change the target temperature frequently), these errors will cause HomeAssistant to eventually crash.
The specific instance I've captured is this packet from the unit giving the problem:
Evidently, the unit is reporting a temSet of 25, and a temRec of 1. The generated table of this python package doesn't have this value, and will raise the StopIteration error. I confirmed that if I pick a value that is in the table, HomeAssistant stops complaining, and adds the climate entity as expected.