dolezsa / thermal_comfort

Thermal Comfort sensor for HA (absolute humidity, heat index, dew point, thermal perception)
Other
584 stars 109 forks source link

2.0.0 - Error doing job: Task exception was never retrieved #244

Closed VDRainer closed 1 year ago

VDRainer commented 1 year ago

Since Update to 2.0.0 my log fills with:

2023-01-09 10:49:26.550 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/home/homeassi/.homeassistant/custom_components/thermal_comfort/sensor.py", line 694, in temperature_state_listener
    await self._new_temperature_state(event.data.get("new_state"))
  File "/home/homeassi/.homeassistant/custom_components/thermal_comfort/sensor.py", line 698, in _new_temperature_state
    hass = async_get_hass()
  File "/srv/ha/lib/python3.10/site-packages/homeassistant/core.py", line 197, in async_get_hass
    return _cv_hass.get()
LookupError: <ContextVar name='current_entry' at 0x7f37a0712980>
2023-01-09 10:50:22.112 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/home/homeassi/.homeassistant/custom_components/thermal_comfort/sensor.py", line 694, in temperature_state_listener
    await self._new_temperature_state(event.data.get("new_state"))
  File "/home/homeassi/.homeassistant/custom_components/thermal_comfort/sensor.py", line 698, in _new_temperature_state
    hass = async_get_hass()
  File "/srv/ha/lib/python3.10/site-packages/homeassistant/core.py", line 197, in async_get_hass
    return _cv_hass.get()
LookupError: <ContextVar name='current_entry' at 0x7f37a0712980>
2023-01-09 10:50:22.117 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/home/homeassi/.homeassistant/custom_components/thermal_comfort/sensor.py", line 694, in temperature_state_listener
    await self._new_temperature_state(event.data.get("new_state"))
  File "/home/homeassi/.homeassistant/custom_components/thermal_comfort/sensor.py", line 698, in _new_temperature_state
    hass = async_get_hass()
  File "/srv/ha/lib/python3.10/site-packages/homeassistant/core.py", line 197, in async_get_hass
    return _cv_hass.get()
LookupError: <ContextVar name='current_entry' at 0x7f37a0712980>

After HA Restart a few of the TC Device Sensors show the state 'unknown'. 20230109_110116 After reloading the TC Device they seem to work ok.

EDIT: HA 2023.1.2 Core in Python 3.10.8 venv

rautesamtr commented 1 year ago

I wasn't able to reproduce this myself but i can try to push a possible bugfix.

Are you able to to modify your local source yourself to give it a try or do you need a release?

Can you change this line: https://github.com/dolezsa/thermal_comfort/blob/8dfd711a7009c0049b5958888f1c8b0f1f4487f3/custom_components/thermal_comfort/sensor.py#L698

to

hass = self.hass

This change would make sense anyway but would be nice to have feedback before pushing it.

VDRainer commented 1 year ago

@rautesamtr , Thanks for your fast reply. The change to hass = self.hass fixed the issue for me. No errors in the log and the TC Devices are all 'online' after HA Restart.