home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.03k stars 29.69k forks source link

LIFX Integration failing Setup during Initialize step when adding bulbs #122274

Closed shadowcman closed 1 month ago

shadowcman commented 1 month ago

The problem

I'm attempting to add two LIFX Bulbs (A19 bulbs, firmware 4.3 ) to Home Assistant for the first time. Bulbs were successfully set up via the LIFX app and the LIFX HA integration detects both bulbs. When adding the bulbs to Home Assistant the initial configuration takes over 60 seconds but says "Success! Created configuration for Bulb1". This happens for both bulbs.

Success

The LIFX Integration then says "Initializing" for several minutes before failing.

initializing

failed setup

Things I've tried: 1.) Restart Home Assistant 2.) Restart Router 3.) Remove and re-pair lights in LIFX app

Logs are below:

Logger: homeassistant.config_entries Source: config_entries.py:586 First occurred: 3:14:38 PM (5 occurrences) Last logged: 3:31:47 PM

Error setting up entry Bulb1 for lifx Error setting up entry Bulb2 for lifx Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/lifx/init.py", line 217, in async_setup_entry await coordinator.async_config_entry_first_refresh() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 277, in async_config_entry_first_refresh await self._async_refresh( File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 312, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/lifx/coordinator.py", line 289, in _async_update_data responses = await async_multi_execute_lifx_with_retries( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/lifx/util.py", line 224, in async_multi_execute_lifx_withretries , pending = await asyncio.wait(futures, timeout=timeout_per_attempt) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/tasks.py", line 464, in wait return await _wait(fs, timeout, return_when, loop) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/tasks.py", line 550, in _wait await waiter asyncio.exceptions.CancelledError

What version of Home Assistant Core has the issue?

core-2024.7.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

lifx

Link to integration documentation on our website

https://www.home-assistant.io/integrations/lifx

Diagnostics information

Logger: homeassistant.config_entries Source: config_entries.py:586 First occurred: 3:14:38 PM (5 occurrences) Last logged: 3:31:47 PM

Error setting up entry Bulb1 for lifx Error setting up entry Bulb2 for lifx Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/lifx/init.py", line 217, in async_setup_entry await coordinator.async_config_entry_first_refresh() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 277, in async_config_entry_first_refresh await self._async_refresh( File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 312, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/lifx/coordinator.py", line 289, in _async_update_data responses = await async_multi_execute_lifx_with_retries( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/lifx/util.py", line 224, in async_multi_execute_lifx_withretries , pending = await asyncio.wait(futures, timeout=timeout_per_attempt) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/tasks.py", line 464, in wait return await _wait(fs, timeout, return_when, loop) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/tasks.py", line 550, in _wait await waiter asyncio.exceptions.CancelledError

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.config_entries
Source: config_entries.py:586
First occurred: 3:14:38 PM (5 occurrences)
Last logged: 3:31:47 PM

Error setting up entry Bulb1 for lifx
Error setting up entry Bulb2 for lifx
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/lifx/__init__.py", line 217, in async_setup_entry
    await coordinator.async_config_entry_first_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 277, in async_config_entry_first_refresh
    await self._async_refresh(
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 312, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/lifx/coordinator.py", line 289, in _async_update_data
    responses = await async_multi_execute_lifx_with_retries(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/lifx/util.py", line 224, in async_multi_execute_lifx_with_retries
    _, pending = await asyncio.wait(futures, timeout=timeout_per_attempt)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/tasks.py", line 464, in wait
    return await _wait(fs, timeout, return_when, loop)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/tasks.py", line 550, in _wait
    await waiter
asyncio.exceptions.CancelledError

Additional information

No response

home-assistant[bot] commented 1 month ago

Hey there @djelibeybi, mind taking a look at this issue as it has been labeled with an integration (lifx) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `lifx` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign lifx` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


lifx documentation lifx source (message by IssueLinks)

Djelibeybi commented 1 month ago

The fact that its looking for extended color zones and multizone effects implies that either the detection is getting it wrong, or the logic for updating data is wrong. Can you please take a screenshot of the Light Settings page from the LIFX app for one of these two bulbs?

shadowcman commented 1 month ago

The fact that its looking for extended color zones and multizone effects implies that either the detection is getting it wrong, or the logic for updating data is wrong. Can you please take a screenshot of the Light Settings page from the LIFX app for one of these two bulbs?

Screenshot_20240721_203212_LIFX

About my home network, both the bulbs and my Home Assistant server are on the same network with the same subnet address, no VLANS.

Djelibeybi commented 1 month ago

@bdraco the only thing I can think of that might cause this is the use of @cached_property on is_extended_multizone in coordinator.py but I have no idea how to test this theory. Any suggestions? The code shouldn't be trying to set those two messages unless that property is true.

I could just revert back to using features["..."] for the _async_update_data method, but I'm not confident it'll necessarily fix the problem.

bdraco commented 1 month ago

The op is running 2024.7.0 according to the text above.

The only changes for 2024.7.0 are:

% git diff -w 2024.6.3..2024.7.0 -- homeassistant/components/lifx
diff --git a/homeassistant/components/lifx/light.py b/homeassistant/components/lifx/light.py
index 90632f82d9e..caa1140b099 100644
--- a/homeassistant/components/lifx/light.py
+++ b/homeassistant/components/lifx/light.py
@@ -25,6 +25,7 @@ from homeassistant.helpers import entity_platform
 import homeassistant.helpers.config_validation as cv
 from homeassistant.helpers.entity_platform import AddEntitiesCallback
 from homeassistant.helpers.event import async_call_later
+from homeassistant.helpers.typing import VolDictType

 from .const import (
     _LOGGER,
@@ -53,7 +54,7 @@ LIFX_STATE_SETTLE_DELAY = 0.3

 SERVICE_LIFX_SET_STATE = "set_state"

-LIFX_SET_STATE_SCHEMA = {
+LIFX_SET_STATE_SCHEMA: VolDictType = {
     **LIGHT_TURN_ON_SCHEMA,
     ATTR_INFRARED: vol.All(vol.Coerce(int), vol.Clamp(min=0, max=255)),
     ATTR_ZONES: vol.All(cv.ensure_list, [cv.positive_int]),
@@ -63,7 +64,7 @@ LIFX_SET_STATE_SCHEMA = {

 SERVICE_LIFX_SET_HEV_CYCLE_STATE = "set_hev_cycle_state"

-LIFX_SET_HEV_CYCLE_STATE_SCHEMA = {
+LIFX_SET_HEV_CYCLE_STATE_SCHEMA: VolDictType = {
     ATTR_POWER: vol.Required(cv.boolean),
     ATTR_DURATION: vol.All(vol.Coerce(float), vol.Clamp(min=0, max=86400)),
 }

I think something else is going on

Djelibeybi commented 1 month ago

Ah, good catch. I was looking at the new code, not the current code. I have an A21 that I'll delete from my production instance to see if I can reproduce the issue.

Djelibeybi commented 1 month ago

Ok, so I tried 2024.7.0 and it detected my A21 1600lm US bulb without a problem.

@shadowcman can you confirm whether your bulbs have both or either a location and group configured or neither? I'm trying to think of things that I have configured that you may not.

This should also be a Matter-enabled bulb, so could you confirm whether or not you have used its Matter functionality to add it to Google or Alexa or HomeKit?

shadowcman commented 1 month ago

Ok, so I tried 2024.7.0 and it detected my A21 1600lm US bulb without a problem.

@shadowcman can you confirm whether your bulbs have both or either a location and group configured or neither? I'm trying to think of things that I have configured that you may not.

This should also be a Matter-enabled bulb, so could you confirm whether or not you have used its Matter functionality to add it to Google or Alexa or HomeKit?

Both Bulbs are part of the same location and group. Yes, they are Matter bulbs and I have not attempted to connect them to Alexa or Google Home or HomeKit. After unboxing the brand new bulbs I immediately paired them with the LIFX android app, added a location and group for them, then attempted to add them to Home Assistant.

shadowcman commented 1 month ago

Ok, so I tried 2024.7.0 and it detected my A21 1600lm US bulb without a problem.

@shadowcman can you confirm whether your bulbs have both or either a location and group configured or neither? I'm trying to think of things that I have configured that you may not.

This should also be a Matter-enabled bulb, so could you confirm whether or not you have used its Matter functionality to add it to Google or Alexa or HomeKit?

Is there a way to add the bulbs to the LIFX app without a Location or Group? The app made it seem like it was mandatory that it have both configured.

Update: Nevermind, I was able to re-add the bulbs to the LIFX app without a Location/Group but Home Assistant still fails to set them up after detecting them in the LIFX integration.

Djelibeybi commented 1 month ago

@shadowcman is it possible to get a diagnostic output from the failed bulb or does it not provide that option? I'm not sure how much discovery needs to succeed before Home Assistant allows you to download it. If you can download the diagnostic data, that could be useful.

If not, could you enable debug logging, delete a bulb and then wait for it to be rediscovered and try to add it? Then upload the debug logs for that period?

shadowcman commented 1 month ago

@shadowcman is it possible to get a diagnostic output from the failed bulb or does it not provide that option? I'm not sure how much discovery needs to succeed before Home Assistant allows you to download it. If you can download the diagnostic data, that could be useful.

If not, could you enable debug logging, delete a bulb and then wait for it to be rediscovered and try to add it? Then upload the debug logs for that period?

KeyError: 'lifx' 2024-07-23 18:21:36.593 ERROR (MainThread) [aiohttp.server] Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request resp = await request_handler(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle resp = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware response = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle result = await handler(request, **request.match_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 95, in delete result = await hass.config_entries.async_remove(entry_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1729, in async_remove del self._entries[entry.entry_id]


  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1546, in __delitem__
    self._unindex_entry(entry_id)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1533, in _unindex_entry
    self._domain_index[domain].remove(entry)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'lifx'
2024-07-23 18:21:48.930 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 95, in delete
    result = await hass.config_entries.async_remove(entry_id)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1729, in async_remove
    del self._entries[entry.entry_id]
        ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1546, in __delitem__
    self._unindex_entry(entry_id)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1533, in _unindex_entry
    self._domain_index[domain].remove(entry)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'lifx'
2024-07-23 18:23:21.116 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 95, in delete
    result = await hass.config_entries.async_remove(entry_id)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1729, in async_remove
    del self._entries[entry.entry_id]
        ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1546, in __delitem__
    self._unindex_entry(entry_id)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1533, in _unindex_entry
    self._domain_index[domain].remove(entry)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'lifx'
2024-07-23 18:23:24.399 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 95, in delete
    result = await hass.config_entries.async_remove(entry_id)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1729, in async_remove
    del self._entries[entry.entry_id]
        ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1546, in __delitem__
    self._unindex_entry(entry_id)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1533, in _unindex_entry
    self._domain_index[domain].remove(entry)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'lifx'
2024-07-23 18:24:22.394 INFO (MainThread) [alexapy.alexaapi] Backing off _static_request(...) for 0.1s (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests)
2024-07-23 18:24:22.602 INFO (MainThread) [alexapy.alexaapi] Backing off _static_request(...) for 1.4s (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests)
2024-07-23 18:25:39.543 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 95, in delete
    result = await hass.config_entries.async_remove(entry_id)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1729, in async_remove
    del self._entries[entry.entry_id]
        ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1546, in __delitem__
    self._unindex_entry(entry_id)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1533, in _unindex_entry
    self._domain_index[domain].remove(entry)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'lifx'
2024-07-23 18:25:48.438 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 95, in delete
    result = await hass.config_entries.async_remove(entry_id)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1729, in async_remove
    del self._entries[entry.entry_id]
        ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1546, in __delitem__
    self._unindex_entry(entry_id)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1533, in _unindex_entry
    self._domain_index[domain].remove(entry)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^
shadowcman commented 1 month ago

Other LIFX entries I found in the log:

2024-07-23 18:46:55.990 DEBUG (MainThread) [homeassistant.components.lifx] Finished fetching Light1 (11.11.11.115) data in 90.023 seconds (success: False) 2024-07-23 18:48:31.472 DEBUG (MainThread) [homeassistant.components.lifx] Finished fetching Light1 (11.11.11.115) data in 90.029 seconds (success: False) 2024-07-23 18:50:11.966 DEBUG (MainThread) [homeassistant.components.lifx] Finished fetching Light1 (11.11.11.115) data in 90.025 seconds (success: False) 2024-07-23 18:52:02.055 DEBUG (MainThread) [homeassistant.components.lifx] Finished fetching Light1 (11.11.11.115) data in 90.026 seconds (success: False) 2024-07-23 18:54:12.193 DEBUG (MainThread) [homeassistant.components.lifx] Finished fetching Light1 (11.11.11.115) data in 90.028 seconds (success: False)

Djelibeybi commented 1 month ago

I went back to check the code and we don't actually log enough (even in debug mode) to have been useful in this case. And the diagnostics will only work when the bulb is successfully discovered.

@bdraco is there a way to see the version of aiolifx installed by Home Assistant via the UI or a service call? It's a long shot, but I'm wondering if something broke in one of the versions released as maintainership changed.

bdraco commented 1 month ago
docker exec -it homeassistant /bin/bash
pip show aiolifx
shadowcman commented 1 month ago

I went back to check the code and we don't actually log enough (even in debug mode) to have been useful in this case. And the diagnostics will only work when the bulb is successfully discovered.

@bdraco is there a way to see the version of aiolifx installed by Home Assistant via the UI or a service call? It's a long shot, but I'm wondering if something broke in one of the versions released as maintainership changed.

image

Djelibeybi commented 1 month ago

That gives me an idea. Try this:

docker exec -it homeassistant aiolifx

It should give you a list of your bulbs. Use the arrow keys to select one, then select "Info". You may have to scroll up to see the start of the output, but it would be really useful to see all of it.

Djelibeybi commented 1 month ago

For example, my A21's output looks like this:

Desk Lamp
    MAC Address: d0:73:d5:xx:xx:x
    IP Address: 192.168.xx.yy
    Port: 56700
    Power: Unknown
    Location: Home
    Group: Bedroom

Vendor: 1
    Product: Product(id=169, name='LIFX A21 1600lm US', buttons=False, chain=False, color=True, extended_multizone=False, hev=False, infrared=False, matrix=False, multizone=False, relays=False, max_kelvin=9000, min_kelvin=1500, min_ext_mz_firmware=None, min_ext_mz_firmware_components=None, temperature_range=None)
    Version: 17368064
shadowcman commented 1 month ago

For example, my A21's output looks like this:

Desk Lamp
    MAC Address: d0:73:d5:xx:xx:x
    IP Address: 192.168.xx.yy
    Port: 56700
    Power: Unknown
    Location: Home
    Group: Bedroom

Vendor: 1
    Product: Product(id=169, name='LIFX A21 1600lm US', buttons=False, chain=False, color=True, extended_multizone=False, hev=False, infrared=False, matrix=False, multizone=False, relays=False, max_kelvin=9000, min_kelvin=1500, min_ext_mz_firmware=None, min_ext_mz_firmware_components=None, temperature_range=None)
    Version: 17368064

image

Djelibeybi commented 1 month ago

That's exactly what I needed to see. It seems aiolifx is reporting the wrong capabilities for that device, so I just need to track down why.

Djelibeybi commented 1 month ago

This is a bug with the upstream LIFX product definitions which I've reported: https://github.com/LIFX/products/issues/31

I'll manually fix aiolifx in the interim.

shadowcman commented 1 month ago

This is a bug with the upstream LIFX product definitions which I've reported: LIFX/products#31

I'll manually fix aiolifx in the interim.

Thanks for the help, I really appreciate all the work!

Djelibeybi commented 1 month ago

You're welcome. This was a particularly weird case and certainly the first instance where the upstream LIFX definition was the actual root cause. I'll note that they've already fixed their product definition too.

@bdraco do you know when this fix might appear in a GA release of Home Assistant?

bdraco commented 1 month ago

Its tentatively scheduled for July 26th.

Djelibeybi commented 1 month ago

Awesome, thanks!