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
72.59k stars 30.36k forks source link

Flux LED MagicHome delay and unstable state #55631

Closed PecceG2 closed 3 years ago

PecceG2 commented 3 years ago

The problem

When using the flux_led plugin, the lamps, RGB and RGBW led strips of different brands present a significant delay when changing the color, state or brightness.

Beyond the delay, the lamp status remains poorly set to HomeAssistant, showing wrong colors, or inverted on / off status.

Sometimes, to change the state, it is necessary to execute the same command (shutdown, for example) more than once.

What is version of Home Assistant Core has the issue?

core-2021.8.8

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

flux_led

Link to integration documentation on our website

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

Example YAML snippet

light:
  - platform: flux_led
    devices:
        10.10.0.2:
            name: "Lamp01"
            mode: "rgb"
        10.10.0.3:
            name: "Lamp02"
            mode: "rgbw"

Anything in the logs that might be useful for us?

Logger: homeassistant.helpers.entity
Source: helpers/entity.py:657
First occurred: 0:15:56 (3 occurrences)
Last logged: 0:16:26

Update of light.Lamp01 is taking over 10 seconds

Additional information

No response

probot-home-assistant[bot] commented 3 years ago

flux_led documentation flux_led source (message by IssueLinks)

PecceG2 commented 3 years ago

Related links: https://community.home-assistant.io/t/setup-of-light-platform-flux-led-is-taking-over-10-seconds/234956 https://community.home-assistant.io/t/magiclight-not-working-properly/34205 https://community.home-assistant.io/t/errors-and-disconnects-with-flux-led-magiclight-component/39818

PecceG2 commented 3 years ago

The undocumented option "scan_interval" will be the solution, I am yet to test with this.

- platform: flux_led
  scan_interval: 30
  automatic_add: True
  devices:
    192.168.0.43:
      name: lamppost
      mode: 'rgbw'

This same issue was covered long ago here: #10911 , but it was closed by the author because it appears to be a network issue, and not Home Assistant.

a-waider commented 3 years ago

Same here. I'm certain it's not a network error in my case because the magic home app and the underlying python module flux_led works just fine. From that I conclude that it has to be related to the home assistant integration.

PecceG2 commented 3 years ago

I tried to use the Flux Led package for Python and it works perfect (https://github.com/Danielhiversen/flux_led). With this software I have no delay problems (if I call it directly from Home Assistant OS), thus ruling out network problems.

I also tried blocking communication to the internet (Highly recommended) since I saw connections to Alibaba servers (China, 47.88.30.119 port: 8816) for each change I made in the lamp, this did not improve the Home Assistant times at all, but hey! Privacy slightly improved.

PecceG2 commented 3 years ago

Has anyone tried @CorneliousJD solution? I'm about to test to see if this can solve the problem of the original Home Assistant integration. https://github.com/CorneliousJD/Flux_LED

PecceG2 commented 3 years ago

After many tests, including touching the source code, I conclude with two results: 1) The home assistant's flux_led integration works better than it sounds, although it sometimes crashes. The delays that are generated are due to specific environments where it does things that it should not.

2) Setting the following parameter in the configuration: scan_interval: 0.2 The problem can be largely corrected and reacts reasonably again, BUT if you have a device with which you cannot connect (for example, a disconnected device) it takes 4 more seconds for each change.

Final reasoning: If you have flux_led devices that HomeAssistant cannot communicate with (for example, disconnected devices), just delete them from the settings. Besides that, add the parameter scan_interval in a value between 0.2 and 0.5, leaving the configuration in this way:

light:
  - platform: flux_led
    scan_interval: 0.2
    devices:
        10.10.0.2:
            name: "Light01"
            mode: "rgb"
        10.10.0.3:
            name: "Light02"
            mode: "rgb"

With the latter, the flux_led integration is working decent (but not perfect).

a-waider commented 3 years ago

I can confirm that after making the suggested changes the flux_led integration works. The mentioned problem when a controller is not available still exisits, espessially when the controller itself has a unstable connection.

Something I noticed is a problem with different versions of the led controllers. Some firmware versions e.g. v8 and v9 are not available after controlled via HA and waiting some time. The controller with firmware version v10 works as expected. I'm not going into further testing here.