Coroutine raised StopIteration when adjusting Gree A/C
See original GitHub issueThe problem
I intermittently get this log output when I make a change to the Gree’s state via Home Assistant, whether via Lovelace or automation:
2022-05-19 12:39:51 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 270, in _async_refresh
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 330, in _handle_coordinator_update
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 533, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 573, in _async_write_ha_state
attr.update(self.state_attributes or {})
File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 272, in state_attributes
self.current_temperature,
File "/usr/src/homeassistant/homeassistant/components/gree/climate.py", line 162, in current_temperature
return self.coordinator.device.current_temperature
File "/usr/local/lib/python3.9/site-packages/greeclimate/device.py", line 372, in current_temperature
return self._convert_to_units(prop - TEMP_OFFSET, bit)
File "/usr/local/lib/python3.9/site-packages/greeclimate/device.py", line 331, in _convert_to_units
f = next(t for t in TEMP_TABLE if t["temSet"] == value and t["temRec"] == bit)
StopIteration
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 137, in _handle_refresh_interval
await self._async_refresh(log_failures=True, scheduled=True)
RuntimeError: coroutine raised StopIteration
The change does still take effect.
What version of Home Assistant Core has the issue?
2022.5.3
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Container
Integration causing the issue
Gree
Link to integration documentation on our website
https://www.home-assistant.io/integrations/gree/
Diagnostics information
I don’t see an option on either integration; I’m happy to provide it if I’m just missing it
Example YAML snippet
No response
Anything in the logs that might be useful for us?
2022-05-19 12:39:51 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 270, in _async_refresh
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 330, in _handle_coordinator_update
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 533, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 573, in _async_write_ha_state
attr.update(self.state_attributes or {})
File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 272, in state_attributes
self.current_temperature,
File "/usr/src/homeassistant/homeassistant/components/gree/climate.py", line 162, in current_temperature
return self.coordinator.device.current_temperature
File "/usr/local/lib/python3.9/site-packages/greeclimate/device.py", line 372, in current_temperature
return self._convert_to_units(prop - TEMP_OFFSET, bit)
File "/usr/local/lib/python3.9/site-packages/greeclimate/device.py", line 331, in _convert_to_units
f = next(t for t in TEMP_TABLE if t["temSet"] == value and t["temRec"] == bit)
StopIteration
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 137, in _handle_refresh_interval
await self._async_refresh(log_failures=True, scheduled=True)
RuntimeError: coroutine raised StopIteration
Additional information
No response
Issue Analytics
- State:
- Created a year ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Python: Coroutines - StopIteration exception - Stack Overflow
The send() method returns the next value yielded by the generator, or raises StopIteration if the generator exits without yielding another ...
Read more >Coroutines.pdf - Dabeaz
meant for coroutines are sometimes described as a way to tweak generators that are in the process of producing an iteration pattern (i.e.,...
Read more >3. Data model - Python 3.7.0a2 documentation
Coroutine objects are awaitable objects. A coroutine's execution can be controlled by calling __await__() and iterating over the result. When the coroutine has ......
Read more >Harvard 2020-CS107 / AC207 / CSCI E-207 | Lecture 18
... StopIteration Traceback (most recent call last) ... Setting the GENERATOR flag means that Python remembers to create a generator, not a function....
Read more >Coroutines - Softpanorama
Coroutines are classic programming-in-the-large methodology that most know ... + + Note that return isn't always equivalent to raising StopIteration: the + ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@home-assistant unassign mikrotik
I made an update to greeclimate 1.2.0 that I think will prevent the exception. Still might be an issue with state, but it’ll log as a warning and fallback to the set-point temperature if it happens with that change.