Home Assistant Community

Flux_led ability to control speed and more effect

#1

I’d like to request some more feature for the flux_led component
It seems absurd that we are not able to control the speed of the effects from HA, while it is totally possible from the MagicHome app… also, it would be awesome if we could have more effects

Flux_LED - Programs working, but can't control speed strobe speed?
#2

Would like to see this functionality too. The default strobe speed is too slow. Also the app allows you to change the strobe speed so it should be ported to HA.

1 Like
#3

Still not available in .83.2…next update??

#4

I don’t think it’s even been taken into consideration by the developers, it’s not voted enough to be seen

#5

In case someone takes a look at this request.

flux_led.py sends effects like so:

if effect in EFFECT_MAP:
self._bulb.setPresetPattern(EFFECT_MAP[effect], 50)

the 50, in this case is a speed setting. This need to be a variable the user can change between 1-100.

Sadly, I do not have the knowledge to fix this in python, or I would put in a pull request.

#6

So changing this value changes the strobe speed? Have you tried this?

#7

Yes. I copied the contents of flux_led.py and made a custom component called custom_components/light/led_flux.py

Then, changed the domain to ‘led_flux’ instead of flux_led. Now I have a light component called led_flux.

Since, I only want effects to blink quickly, I set the speed to 100 and it works for my setup.

#8

sweet…I’ll try this

#9

can you share the code?

#10

I messed with this a bit today.

light.turn_on can’t have any more attribute types attached to it without changing a LOT of code. The thing that most likely would have to happen is to have flux_led do something similar to LIFX by creating a new service type just for setting the effect and speed and I may give that a shot later this weekend.

However, as a super quick workaround, I went with just upping the speed if it was a strobe effect and leaving it as 50 for everything else.

        # Effect selection                                                   
        if effect in EFFECT_MAP:                                             
            speed = 50                                                       
            if "strobe" in effect:                                           
                speed = 100                                                  
            self._bulb.setPresetPattern(EFFECT_MAP[effect], speed)           
            return                                                           

I’ll post back if I do something a little more significant with going the service route instead.

1 Like
#11

@tedkulp @trektronic
I saw both your comments about modifying the actual python…
Seems like this is part of the issue #19504 as well.

do I add custom_components/light/led_flux.py to deps?

@tedkulp I like your setup however an update or reinstall would wipe all these changes, right?

#12

I have done what @trektronic suggested above, and it works perfectly. Just keep in mind that the speed is static, so you cannot change it in the UI. If you need to change the speed of the strobe, you’ll need to change the value in the python file.

Updates don’t affect py files in the custom_components folder. There may be breaking changes that may affect the component as a whole, in which case you’ll need to pull the updated official flux led component, and make the modifications in the same area, rename it, and add it to your custom_components folder.

1 Like
#13

Hi, did you get an answer to this? I’m finding that the effect speed is too slow to be useful. I’d like to have a go at doing something like this, but I don’t know how to create a custom component from the original file (or even where the file can be found).

#14

Go to github and download the original component file. It’s callled light.py now.
Make the changes indicated in the posts above. Create a custom components folder and name it ‘led_flux’. Copy the modified light.py file into the folder, and then add the component to your config.yaml

1 Like
#15

Hey Mirai, thanks for the advice. Do I create the folder in the config directory?

Thanks for getting back to me. Greatly appreciated.

#16

Yes…you need to create config\custom_components. As far as what to call the components directory is up to you, but don’t call it the same name as the official component or it will conflict. As mentioned above, might want to try config\custom_components\led_flux\light.py.

EDIT: I just tried this on my DEV machine and it seems that this hack doesn’t work any more. I guess we’ll have to do a pull request for an adjustable strobe function. :frowning:

1 Like
#17

so, I had a hard time finding my custom folder as well…the folder is basically THE one with all the code for the components, etc.

Assuming you have the same installation as me: raspberry + virtual enviroment…
my folder was located at:
/srv/homeassistant/lib/python3.5/site-packages/homeassistant/custom_components
… and within…flux_led

What I did was:
-clone that folder with a “new component name” - i did led_flux:

use command:

sudo cp -R origin destination
sudo cp -R /srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/flux_led /srv/homeassistant/lib/python3.5/site-packages/homeassistant/custom_components/led_flux

Now you can add led_flux to your lights.yaml and use the same options from flux_led
Then you can modify the file for the speed.

sudo nano /srv/homeassistant/lib/python3.5/site-packages/homeassistant/custom_components/led_flux/light.py

search for the following line:

self._bulb.setPresetPattern(EFFECT_MAP[effect], 50)

change 50 to whatever you want…
higher number means faster blinking…
smaller = slower

Enjoy.

#18

BTW… after my instructions above…dont forget to keep in mind @Mirai_Hayashi about the component updates needed:
"Updates don’t affect py files in the custom_components folder. There may be breaking changes that may affect the component as a whole, in which case you’ll need to pull the updated official flux led component, and make the modifications in the same area, rename it, and add it to your custom_components folder. "

#19

Yes…this is why this hack no longer works. The py script has changed quite a lot, as well as the domain architecture, so someone who knows how to edit python needs to look into this and let us know how we can get this to work with v.92+

#20

Even having the option of setting speed globally in the configuration.yaml would be a big step forward.

I wonder if handing control via IFTTT would be an option.