Flux Led/MagicLight don't work since few updated

That controller looks different to the one in the first post, have you had to replace the controllers to get the lights working properly again?

This is caused by an issue with the Home Assistant flux_led component. I was able to patch it to resolve this by doing the following:

Edit light.py in your homeassistant/components/flux_led folder and change the following:

Comment out or delete these lines in the def turn_on(self, **kwargs) method:

#        if not self.is_on:
#            self._bulb.turnOn()

Further down in this method, below these lines:

        # Preserve current brightness on color/white level change
        if brightness is None:
            brightness = self.brightness

Add in the following:

        # If these are 0 then bulb.isOn will return false, not what we want
        if hs_color is None or (hs_color[0] == 0 and hs_color[1] == 0):
            hs_color = (1, 1, 1)
        
        if brightness is None or brightness == 0:
            brightness = 100

I’ve uploaded the modified light.py with the above changes made here:

So you can either make the edits above or just download the updated light.py file from the gist above and drop it in your homeassistant/components/flux_led folder and restart HA to solve the issue. The location of your homeassistant/components/flux_led folder will vary based on your Python setup, for me it was at /srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/flux_led

The issue seems to be caused because setting the brightness or colors to zero immediately after calling self._bulb.turnOn() (which the Home Assistant component is doing) causes the state in the library to be changed to off which causes the turn on and immediately turn off behaviour.

Also, this is the configuration I have for the LED Strip in my configuration.yaml

light:
  - platform: flux_led
    devices:
      192.168.1.100:
        name: LED Strip
        protocol: 'ledenet'
        mode: rgb

This was tested under Home Assistant 0.103.0.

5 Likes

Hey @john32
I tested your script and controlling the lights works now, so thanks!
But it does not seem to be able to get a proper light name. It used to be light.mac_ip-address, but now it just says light.name in the entity list on the States page.
So if I use multiple v8’s, that might give issues since they will have the same name. Or will hassio rename duplicates?

@Glenn_Ruysschaert Great to hear that fixed it for you! I’m not to sure about the entities name issue - I did notice you can rename an entity by going to the configuration section in the web interface and then clicking on the device. I think HA will automatically add _1 _2 etc. to avoid duplicate names if you have multiple lights.

Hi @john32

First of all thanks for your help!

I’m using HASS.io and i think it’s not possible to modify the light.py file… how can i fix this issue?

Thank you so much!

1 Like

@Blai89 You can’t fix this without changing the light.py file as this is the component causing the problem. But I think you can modify the HASS.io files - someone did it here: How to edit components in Hass.io?

So you could try that. Good luck!

1 Like

Hi @john32.

I almost got it thanks to the link you sent me.

I’ve found te directory with all the components in /usr/local/lib/python3.7/site-packages/flux_led, but there is no light.py file, only main.py and this is not the same content as your file…

Again, thank you so much for your help! have a nice year!

@Blai89 See if you have /usr/local/lib/python3.7/site-packages/homeassistant/components/flux_led/light.py and replace this with the one I provided instead.

The /usr/local/lib/python3.7/site-packages/flux_led one you have found is the flux_led library used by HA but it is the HA component itself that you need to edit. I think it should be in the path I’ve given above.

Ohhh i found it! it’s in /usr/src/homeassistant

Thank you so much! with your code it works but sometimes when i turn on the leds hassio takes a few seconds to refresh de state… even so… it works!

Thank you so much!

I can’t find the homeassistant folder in my configuration so I can’t replace the light.py script. Any ideas?

At the moment I can’t even get the flux_led component to find any devices.

I installed flux_led by just doing a ‘pip3 install flux_led’ and I’m able to control the LED strip again using the cli ‘flux_led’. I tried putting the new light.py in place but its still not working. I’m guessing if the flux_led python library is updated in home assistant it will start working again correctly. For now I’ve had to make a custom shell_script in the configuration.yaml to call the flux_led python by hand and it all works again. Quite frustrating.

Hi again @john32,

After HA update the light.py file returns to the original code…

Do you know hot to avoid this? Thanks so much!

Thanks for all your help!

I can’t fix the problem.

So I decided to flash ESPhome to the wifi controllers and now I have no more problems.

@Blai89 My fix was really only a bandaid fix to get things running and an HA developer probably needs to look at this next. I had a look on github and it looks like there are a few devs aware of the issues with the flux_led component already and I would be surprised if this doesn’t get fixed soon in an update.

Until it gets fixed properly in the HA codebase you’ll have to copy over the light.py after each update for now I’m afraid.

Rather than edit the original component, make a copy as a custom component. Create the folder (if it does not exist) /config/custom_components/flux_led and then copy the original files from source in to the new folder. Then overwrite light.py with @john32’s version and restart Home Assistant.
Home Assistant will detect the flux_led component in the custom_components folder during boot and override the original component.

Many thanks @john32, the edited code worked great for me :grinning:

1 Like

I couldn’t find the original HA config files on the server. I’m not very good with linux style OS’s so that’s probably why. So, I just tried the fix suggested by @Siytek but that actually made it worse. Now I don’t have ANY control via HA. The switch still just turns on then right back off (the light doesn’t turn on at all) but now I have no controls for color at all. Not that they worked anyway…

@HotRod50m what is in your configuration.yaml file? Did you try with and without the ledenet protocol? Did it ever work for you with previous versions or are you configuring it for the first time?

Hi Team,

I have the same issue with the V8. It works good with my V6 controllers.

In order to solve it I am following your workaround. In my custom_components folder where I have other custom components that work fine, I have created a flux_led folder, I have copied the init.py and light.py files (the modified light.py) but when bootin I can see in the log that other custom components are loading and the flux_led one no. It is still taking the original one, not the custom one. Am I missing something??

image

I just now started with HA so technically it has never worked for me. I have tried both with and without ledenet.

Here is my configuration.yaml:

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

frontend:
  themes: !include themes.yaml
  
#ring:
#  username: !secret ring_username
#  password: !secret ring_password
  
device_tracker:
   - platform: unifi_direct
     host: 192.168.75.2
     username: !secret unifi_username
     password: !secret unifi_password
    
   - platform: unifi_direct
     host: 192.168.75.3
     username: !secret unifi_username
     password: !secret unifi_password
     
tuya:
  username: !secret tuya_username
  password: !secret tuya_password
  country_code: "1"
  
light:
  - platform: flux_led
    automatic_add: false
    devices:
      192.168.100.40:
        name: Bedroom 1
        mode: "rgbw"
      192.168.100.41:
        name: Bedroom 2
        mode: "rgbw"
      192.168.100.42:
        name: Office 1
        mode: "rgb"
      192.168.100.43:
        name: Office 2
        mode: "rgb"
      192.168.100.44:
        name: Living Room
        mode: "rgb"
      192.168.100.45:
        name: Lamp
        mode: "rgb"
      192.168.100.46:
        name: Front Porch
        mode: "w"
      192.168.100.49:
        name: Strip
        mode: "rgb"

Try removing the speech marks, its the only difference I can see between yours and mine.

mode: rgb

To be honest I am just going to flash my MagicHome devices with Tasmota when I get chance, my Smart Life devices perform noticeably better with this firmware. Perhaps it may be the next option for you to consider if you cannot get flux_led to work.