vincentwolsink / home_assistant_enphase_envoy_installer

This is a HACS custom integration for Enphase Envoys with firmware version 7 and up.
Apache License 2.0
54 stars 10 forks source link

Don't cancel non-existant task #130

Closed AlexanderGrooff closed 1 month ago

AlexanderGrooff commented 1 month ago

When HA fails to start (for whatever reason), no task is created. However, it still triggers the entry.async_on_unload callback where it tries to cancel this task:

2024-05-14 05:53:12.347 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/enphase_envoy/__init__.py", line 240, in _async_stop
    await _cancel_realtime_task(task)
  File "/config/custom_components/enphase_envoy/__init__.py", line 255, in _cancel_realtime_task
    task.cancel()
    ^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'cancel'

I've added type annotations to make the problem clearer.

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

vincentwolsink commented 1 month ago

Hey @AlexanderGrooff! Thanks 👍