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
73.66k stars 30.8k forks source link

Lifx Integration sending multiple 0,0,0,0. Values for setting colour #125105

Closed joelegg closed 2 months ago

joelegg commented 2 months ago

The problem

I'm experiencing a recurring issue with the LIFX integration in Home Assistant where I receive a TimeoutError when attempting to set color zones on my LIFX lights. The issue manifests as a request timeout error, specifically when trying to apply multiple color zones using the LIFX light component. This error occurs multiple times and results in an exception, causing the command to fail entirely.

Error Log:

The following error is logged:

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:241
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: September 2, 2024, at 8:35:27 AM (3 occurrences)
Last logged: September 2, 2024, at 11:40:20 AM

[140116203311680] Unexpected exception
[140116054360560] Unexpected exception

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/lifx/light.py", line 484, in set_color
    await self.coordinator.async_set_extended_color_zones(
  File "/usr/src/homeassistant/homeassistant/components/lifx/coordinator.py", line 419, in async_set_extended_color_zones
    await async_execute_lifx(
  File "/usr/src/homeassistant/homeassistant/components/lifx

What version of Home Assistant Core has the issue?

Haos

What was the last working version of Home Assistant Core?

2024-8-3

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

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:241
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: September 2, 2024, at 8:35:27 AM (3 occurrences)
Last logged: September 2, 2024, at 11:40:20 AM

[140116203311680] Unexpected exception
[140116054360560] Unexpected exception

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/lifx/light.py", line 484, in set_color
    await self.coordinator.async_set_extended_color_zones(
  File "/usr/src/homeassistant/homeassistant/components/lifx/coordinator.py", line 419, in async_set_extended_color_zones
    await async_execute_lifx(
  File "/usr/src/homeassistant/homeassistant/components/lifx/util.py", line 188, in async_execute_lifx
    await async_multi_execute_lifx_with_retries(
  File "/usr/src/homeassistant/homeassistant/components/lifx/util.py", line 239, in async_multi_execute_lifx_with_retries
    raise TimeoutError(f"{failed_methods} timed out after {attempts} attempts")

TimeoutError: functools.partial(<bound method Light.set_extended_color_zones of <aiolifx.aiolifx.Light object at 0x7f6f687940e0>>, colors=[...]) timed out after 5 attempts

Additional information

No response

home-assistant[bot] commented 2 months 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)

joelegg commented 2 months ago

I am sitting each individual bulb in one call so perhaps I could break the call out

I have many individual downloads I have not grouped them. I just tried using groups and I get the same error.

Djelibeybi commented 2 months ago

Could you please paste the YAML you're using that's causing the issue and the type of LIFX multizone lights you're targetting, i.e. is it a Lightstrip, Beam, Neon or String?

joelegg commented 2 months ago

sure thing thanks for your reply

alias: 'Pantry Light Automation'
description: 'Controls pantry lights based on motion and mode'
mode: restart
trigger:
  - platform: state
    entity_id: binary_sensor.pantry_occupancy
    to: 'on'
  - platform: state
    entity_id: binary_sensor.pantry_occupancy
    to: 'off'
    for: '00:02:00'

condition:
  - condition: state
    entity_id: input_boolean.enable_theme_lighting
    state: 'off'

action:
  - choose:
      - conditions:
          - condition: state
            entity_id: binary_sensor.pantry_occupancy
            state: 'on'
        sequence:
          - choose:
              - conditions:
                  - condition: state
                    entity_id: input_select.mode
                    state: 'Day'
                sequence:
                  - service: light.turn_on
                    data:
                      entity_id:
                        - light.pantry_1
                        - light.pantry_2
                      brightness: 254
                      color_temp: 200
                      transition: 1
              - conditions:
                  - condition: state
                    entity_id: input_select.mode
                    state: 'Evening'
                sequence:
                  - service: light.turn_on
                    data:
                      entity_id:
                        - light.pantry_1
                        - light.pantry_2
                      brightness: 200
                      color_temp: 550
                      transition: 1
              - conditions:
                  - condition: state
                    entity_id: input_select.mode
                    state: 'Morning'
                sequence:
                  - service: light.turn_on
                    data:
                      entity_id:
                        - light.pantry_1
                        - light.pantry_2
                      brightness: 125
                      color_temp: 500
                      transition: 1
              - conditions:
                  - condition: state
                    entity_id: input_select.mode
                    state: 'Asleep'
                sequence:
                  - service: light.turn_on
                    data:
                      entity_id:
                        - light.pantry_1
                        - light.pantry_2
                      brightness: 20
                      color_temp: 1000
                      transition: 1
      - conditions:
          - condition: state
            entity_id: binary_sensor.pantry_occupancy
            state: 'off'
            for: '00:02:00'
        sequence:
          - service: light.turn_off
            data:
              entity_id:
                - light.pantry_1
                - light.pantry_2
              transition: 5  # Increased transition time for turning off the lights
          - service: logbook.log
            data:
              name: "Pantry Lights"
              message: "Lights turned off due to no motion detected for 2 minutes."

this is with the GU10 downlights.

thanks

joelegg commented 2 months ago

similar issue with someone else some time ago: https://community.home-assistant.io/t/what-is-timeout-setting-power-error-lifx-error/502069

its' odd as updating the lifx light manually in HA with the devie directly works very fast. but the atuomations just seem to be slow

I originally had this issue in node red too but moved to automations calling the lifx lan integration and same issue. just not consistant.

Djelibeybi commented 2 months ago

I'm not seeing any reason why this would be calling set_extended_color_zones though. These are all just light.turn_on calls. There don't seem to be any lifx.set_state calls, which (I thought) were the only way to trigger set_extended_color_zones.

Djelibeybi commented 2 months ago

Can you please paste the diagnostic output from both of those bulbs? We had an issue a while back where the LIFX-provided product definitions were incorrect and a bulb was marked as having multiple zones when it didn't and this feels like the same problem.

Essentially, there's no reason why we should be anywhere near that function with GU10 bulbs, so something else is going on here.

joelegg commented 2 months ago

good point! very odd.

I do have many lifx lights. (60) including z strip. but in this case its only calling pantry 1 and 2.

joelegg commented 2 months ago

config_entry-lifx-01J60EVR5X4G3DSK8MH33MXKNE.json config_entry-lifx-01J60EXY0JFHFWAN3PJWK492AF.json

sure here you go - thank you

Djelibeybi commented 2 months ago

Ok, so both of those bulbs are reporting the correct capabilities. Neither of them have either multizone or extended_multizone features flagged as enabled incorrectly.

Did this just start happening out of the blue or has this automation always had this problem?

Djelibeybi commented 2 months ago

Do you have any automations that target your Z Strip? I suspect that the last error shown in the interface is not being caused by this automation.

joelegg commented 2 months ago

I didn't have this issue prior no. not sure when it started as i moved to a fresh install as we lived away without HA for a while.

lighting is run for z strip via node red. As when i hit this issue in node red i moved a couple to ha automations to see if it was a node red issue.

Djelibeybi commented 2 months ago

If this is reproducible, can you please enable debug logging, trigger it and then disable logging and upload the log? I can't work out why Home Assistant would be instantiating these as Multizone lights.

joelegg commented 2 months ago

you want me to that in ha? sure

Djelibeybi commented 2 months ago

Are you driving the lighting changes from Node-RED via Home Assistant or some other plugin?

joelegg commented 2 months ago

in home asissant for the one i'm having this issue with (but i also had the same issue occuring in node red)

Djelibeybi commented 2 months ago

I'm also concerned about how long it takes your config entries to set up. Almost all of mine are < 2 seconds. Most of yours are over 10.

joelegg commented 2 months ago

what do you mean by that sorry?

Djelibeybi commented 2 months ago

If you look at all the config_entry_setup values in your .json files, they are all very high, many over 20 seconds. Which does correlate with timeout errors as that's longer than the integration would try to send messages.

I don't know why it's trying to use the extended color zones function, but it does look like your Home Assistant instance and your bulbs are really having a hard time communicating.

joelegg commented 2 months ago

yeah the color zones function is odd.

I have unifi firewalls going on here with Iot vlan etc. and they are talking but yes that could also be it. i'll take a good look

joelegg commented 2 months ago

i also thought that perhaps it was a ram/cpu issue with the VMM i'm running ha on (synology nas 1019+) so i increaed that.

i can't reproduce it tho (it did happen once afer i increase the ram and cpu count tho) but yeah its running quite fast now.

i've introduced too many variables :)

Djelibeybi commented 2 months ago

I use Ubiquiti gear as well. Your Home Assistant instance and LIFX bulbs should be on the same VLAN and the Wi-Fi the bulbs are connected to should have all features disabled except BSS Transition and be set to WPA2 Only.

Djelibeybi commented 2 months ago

Also, if your Synology is multi-homed, make sure the NIC connected to the VLAN the bulbs are on is marked as the active network connection in Settings -> System -> Network.

joelegg commented 2 months ago

Ah so you have your vlan for Home assistant on the same network lifx (iot in this case ). Rather than opening up sharing rules. Got it! I can tweak this shortly. Thanks so much I really appreciate your advice.

Djelibeybi commented 2 months ago

If you're going to move your bulbs, keep in mind that it could take some time for Home Assistant to discover their new IP address. It's a lot faster if you delete them first, then let Home Assistant rediscover them completely. Just make a note of the entity IDs beforehand and if necessary, change them back to the same one afterwards and all your automations should keep working as before.

Djelibeybi commented 2 months ago

BTW, could you let me know what Node-RED node you're using to automate your LIFX bulbs? I'd like to check it out to see if it could be involved in any way, i.e. by being too chatty or something.

joelegg commented 2 months ago

The bulbs are already on iot. I just need to work out how to move my virtual machine which has a unique IP connected to unifi to the iot vlan.

joelegg commented 2 months ago

Yep I'll send the node over shortly

joelegg commented 2 months ago

ok it just replicated the error with debug logging on - but i dont see any lifx logs in system - logs? just normal logs?

Djelibeybi commented 2 months ago

Moving Home Assistant to a different VLAN will require it to have a different IP address, so you'll have to decide which is easier: changing the IP address of Home Assistant or reconfiguring your bulbs. My advice would be to move a couple of bulbs to the same VLAN as Home Assistant to see if that makes any significant difference before doing all of them or moving Home Assistant itself.

Or, if your Synology allows for this, create another vNIC on that VLAN so your Home Assistant instance is connected to both VLANs. Though, this does require some advanced networking config on Home Assistant that isn't exposed via the web interface.

Djelibeybi commented 2 months ago

There should be a bunch of LIFX entries in the debug output. If there are no debug entries, then debug logging wasn't enabled for the LIFX integration.

joelegg commented 2 months ago

i just use the standard call service node: image

Djelibeybi commented 2 months ago

Ok, so that's using Home Assistant as well, not a Node-RED specific method. Moving automation back and forth in this case wouldn't make a difference as both are relying on Home Assistant. On the plus side, debug logging on Home Assistant will show us what happens for both automation types.

joelegg commented 2 months ago

image enabled lifx debug but i'm no t seeing any logs in there when the issue occured again

joelegg commented 2 months ago

the errore occured at 853 a

image

Djelibeybi commented 2 months ago

When you disable debug logging, it should download the logs for the period.

joelegg commented 2 months ago
2024-09-03 08:40:46.844 DEBUG (MainThread) [homeassistant.components.lifx] Finished fetching Dining Room 2 (192.168.2.160) data in 23.682 seconds (success: True)
2024-09-03 08:40:47.664 ERROR (MainThread) [homeassistant.components.automation.pantry_light_automation] Pantry Light Automation: Choose at step 1: choice 2: Error executing script. Error for call_service at pos 1: Timeout setting power for None
2024-09-03 08:40:47.665 ERROR (MainThread) [homeassistant.components.automation.pantry_light_automation] Pantry Light Automation: Error executing script. Error for choose at pos 1: Timeout setting power for None
2024-09-03 08:40:47.668 ERROR (MainThread) [homeassistant.components.automation.pantry_light_automation] Error while executing automation automation.pantry_light_automation: Timeout setting power for None
2024-09-03 08:40:49.417 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140020071381696] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/lifx/light.py", line 303, in set_color
    await self.coordinator.async_set_color(merged_hsbk, duration)
  File "/usr/src/homeassistant/homeassistant/components/lifx/coordinator.py", line 379, in async_set_color
    await async_execute_lifx(
  File "/usr/src/homeassistant/homeassistant/components/lifx/util.py", line 188, in async_execute_lifx
    await async_multi_execute_lifx_with_retries(
  File "/usr/src/homeassistant/homeassistant/components/lifx/util.py", line 239, in async_multi_execute_lifx_with_retries
    raise TimeoutError(f"{failed_methods} timed out after {attempts} attempts")
TimeoutError: functools.partial(<bound method Light.set_color of <aiolifx.aiolifx.Light object at 0x7f58f89a2000>>, [0, 0, 65278, 5000], duration=0) timed out after 5 attempts

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 241, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2763, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2806, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 626, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/usr/src/homeassistant/homeassistant/components/lifx/light.py", line 204, in async_turn_on
    await self.set_state(**{**kwargs, ATTR_POWER: True})
  File "/usr/src/homeassistant/homeassistant/components/lifx/light.py", line 261, in set_state
    await self.set_color(hsbk, kwargs, duration=fade)
  File "/usr/src/homeassistant/homeassistant/components/lifx/light.py", line 305, in set_color
    raise HomeAssistantError(f"Timeout setting color for {self.name}") from ex
homeassistant.exceptions.HomeAssistantError: Timeout setting color for None
Djelibeybi commented 2 months ago

Ok, so that's more like what I expected to see. The log in your original post was caused by your Z strip (I'm fairly sure). We need to get your bulbs responding a lot faster than they are now, because given the setup times, there's definitely a lot of network traffic or delay somewhere. I've got a Synology but I've never used the VMM service, so I have no idea how much (if any) network delay that adds to the stack.

joelegg commented 2 months ago

yeah that could be it. i was running it in docker originally on my synology but had lots of trouble getting z2m going. so i just spun up a vmm.

I am tempted to just buy a dedicated pc to run home assisant as i have 2 RU's spare on my rack. and HOME ASSISTANT is super important lol

Djelibeybi commented 2 months ago

I have mine running as a VM on Proxmox on a Beelink Mini-PC with a bunch of other things running as LXD instances, including Z2M, Node-RED, Scrypted, etc. Highly recommended, especially as mini-PCs are shipping with 2.5GB LAN ports these days.

joelegg commented 2 months ago

I looked into proxmox looks great. I would want to mount it tho. so need to find a min ipc that is rack mountable without any custom mounts.

just trying to move my nas over to iot lan now.

Djelibeybi commented 2 months ago

Good luck! And that problem sounds like a perfect reason to buy a new 3D printer, even if you already have one. 😉

joelegg commented 2 months ago

ok i've moved over. lifx integration is not liking the move tho. its not finding the lifx lights now. I have firewall allow rule for ha IP to the IOT network.

Djelibeybi commented 2 months ago

You can't move Home Assistant to another VLAN without changing its IP address. It has to have an IP address on that VLAN, otherwise it can't communicate with the network to which it's connected.

The point of putting things on the same VLAN is to remove the firewall and routing requirements, which is achieved by having everything on the same IP subnet.

joelegg commented 2 months ago

yeah i moved it over and home assistant now has ip address that is on IOT vlan. i moved the whole nas over to IOT vlan (I run plex and ha on nas)

Djelibeybi commented 2 months ago

If Home Assistant and the LIFX bulbs are on the same IP subnet, there is no firewall between them, unless you're running one specifically on your NAS.

Check Settings -> System -> Network to ensure that Home Assistant has noticed the changed IP address.

joelegg commented 2 months ago

yep it has. for some reason lifx app itself is showing all the lifx lights offline. so i've stuffed something somewhere all i did was move the nas over to the vlan. and update its up. i can access the nas etc fine. but the lifx lights have gone away. still looking into it.

Djelibeybi commented 2 months ago

That is ... odd. Switch your phone to the IoT VLAN to see if that helps. If so, it means the bulbs are having a hard time connecting to the LIFX Cloud (which is what the app falls back to if a direct connection to a bulb fails).

joelegg commented 2 months ago

ok done that. and most are offline - only one is showing as online. very odd.

Djelibeybi commented 2 months ago

That is indeed quite odd. I'm not sure what to suggest here, as I don't know how your VLANs are configured, but I'd check things like your Ubiquiti logs to see if DHCP is working, etc.