MagicLight/Flux WiFi Color LED Light Component

Hello All - I’m fairly new to Home Assistant, but I just wanted to thank the creator of the flux_led.py module, if he’s on here. It was a huge help. I implemented the crossfade.py code into my local ledenet-api ruby module. My problem with these were that it didn’t seem possible to fade them in and out, and I’d nearly given up hope, but I found that code, and it was a godsend.

I’ve implemented it as a mqtt light device in home assistant, and it has been working flawlessly for nearly 2 weeks straight now. Granted my use case here is very simple, but still, you saved me so much time, so I’m quite thankful.

As for how I’m using it, I have the UFO wifi module in my office with a 2100K white led strip in the Blue (B) input of the hub, and a 3000K kelvin white led strip in the Red ®. Green and Warm white are not in use. I control them using a zwave minimote with buttons 1 and 2 toggling between the two strips or toggling on and off depending on what is active. Buttons 3 and 4 are dimmers that changes the brightness +/- 5%.

Again, thanks for making my dream of the $40 - $50 wifi (reliably) controllable led light strip a reality.

1 Like

Hello @Danielhiversen,
Are you thinking to submit a PR to support the RGB for HA 0.26?
Is there anything else I could test here?
Best Regards,
mmello

I am on holiday but will soon make a pr for it

Thanks @Danielhiversen

Enjoy and have fun!

A new PR to support color and brightness: https://github.com/home-assistant/home-assistant/pull/2750

Specially thanks to @mplawner who donated three flux bulbs to me, so I have now tested it here and it seems to work fine.

1 Like

Hi Daniel - Finally got to start playing with the flux_light component. I’m running 26.1.

Running from command line (hass) I found that it takes quite some time to refresh the status.
Below are my two tests and results.
(Note: I have access to the light via a command line switch component as well as via the flux light component. The command line switch is using the original python script).

Test 1: Turn on light - Refresh time ~ 3.5 minutes
Turn on Lamppost via Flux component (light.flux_lamppost)
INFO:homeassistant.core:Bus:Handling <Event call_service[L]: service=turn_on, service_data=entity_id=light.flux_lamppost, domain=homeassistant, service_call_id=1979305328-2> INFO:homeassistant.core:Bus:Handling <Event call_service[L]: service=turn_on, service_data=entity_id=['light.flux_lamppost'], domain=light, service_call_id=1979305328-3> INFO:homeassistant.core:Bus:Handling <Event service_executed[L]: service_call_id=1979305328-3> INFO:homeassistant.core:Bus:Handling <Event service_executed[L]: service_call_id=1979305328-2>

Status Updated via Command Line component (switch.lamppost) - Immediate
INFO:homeassistant.components.switch.command_line:Running state command: /usr/local/bin/flux_led.py 192.168.0.129 -i | awk '/ON/{ print "on" }' INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=<state switch.lamppost=on; icon=mdi:lightbulb, friendly_name=Lamp Post @ 2016-08-14T12:26:31.101703-04:00>, entity_id=switch.lamppost, old_state=<state switch.lamppost=off; icon=mdi:lightbulb, friendly_name=Lamp Post @ 2016-08-14T12:24:08.387352-04:00>>

Status Updated via Flux component (light.flux_lamppost) - After ~3.5 minutes
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=<state light.flux_lamppost=on; friendly_name=flux_lamppost, brightness=255, rgb_color=(255, 255, 255) @ 2016-08-14T12:27:30.844486-04:00>, entity_id=light.flux_lamppost, old_state=<state light.flux_lamppost=off; friendly_name=flux_lamppost @ 2016-08-14T12:24:19.443840-04:00>>

Test 2: Turn off light - Refresh time ~ 7 minutes
Turn off Lamppost via Flux component (light.flux_lamppost)
INFO:homeassistant.core:Bus:Handling <Event call_service[L]: service=turn_off, service_data=entity_id=light.flux_lamppost, domain=homeassistant, service_call_id=1979305328-4> INFO:homeassistant.core:Bus:Handling <Event call_service[L]: service=turn_off, service_data=entity_id=['light.flux_lamppost'], domain=light, service_call_id=1979305328-5> INFO:homeassistant.core:Bus:Handling <Event service_executed[L]: service_call_id=1979305328-5> INFO:homeassistant.core:Bus:Handling <Event service_executed[L]: service_call_id=1979305328-4>

Status Updated via Command Line component (switch.lamppost) - Immediate
INFO:homeassistant.components.switch.command_line:Running state command: /usr/local/bin/flux_led.py 192.168.0.129 -i | awk '/ON/{ print "on" }' INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=<state switch.lamppost=off; icon=mdi:lightbulb, friendly_name=Lamp Post @ 2016-08-14T12:33:31.454867-04:00>, entity_id=switch.lamppost, old_state=<state switch.lamppost=on; icon=mdi:lightbulb, friendly_name=Lamp Post @ 2016-08-14T12:26:31.101703-04:00>>

Status Updated via Flux component (light.flux_lamppost) - After ~7 minutes
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=<state light.flux_lamppost=off; friendly_name=flux_lamppost @ 2016-08-14T12:39:00.751824-04:00>, entity_id=light.flux_lamppost, old_state=<state light.flux_lamppost=on; friendly_name=flux_lamppost, brightness=255, rgb_color=(255, 255, 255) @ 2016-08-14T12:27:30.844486-04:00>>

Ok, there is some conflicts if several units talks to the bulbs at the same time (Eg.: the App, light.flux_lampost, switch.lamppost …)
I am trying to solve the problem, but for now try to limit the number of active units talking to the bulbs.

You can also add
scan_interval: 15
to the flux_led component to set the update time to 15 seconds (default is 30s)

1 Like

Yes! That made all the difference! Thank you!

@aap82 - Could you share your config for using MQTT with these bulbs? That sounds ideal. I’d like to be able to quickly call warm or cool settings and think MQTT would be great for that. Thanks!

Is there a HA custom component for controlling the Flux LED’s yet?

@automateit https://home-assistant.io/components/light.flux_led/

You rock, dude - I’ll test that out

You use input boolean:

For anyone interested, I ended up using an ‘input_select’ so I can pull “random” as a selection in the drop down:

alias: "random_flux_rgb"
trigger:
  - platform: time
    seconds: '/45'
condition:
  - condition: state
    entity_id: input_select.rgb_light
    state: 'Random'
action:
  service: light.turn_on
  data:
    entity_id: light.livingroom_lamp
    effect: random

Still doing some tests, but so far this seems to work pretty well.

With the current version (0.34.4, and perhaps in previous versions but not in 0.28) I have found the lights become unreachable after some period of time.

I am starting to suspect that it may be connected to the loss of one of the configured lights on the network becoming unreachable after ha has started. I can’t yet pin it down, but I believe that if someone cut power to one of the flux lightbulbs by turning off the light switch, sometime after the flux_led component no longer can connect to any flux wifi light.

Below is the error in the log if I cut power to a bulb. But after 15 minutes, the others are still responsive, so my theory, admittedly, doesn’t yet have much validity - I’m sharing early at this point. I’ll check back in a while and report any changes. Not sure what to look for. Nonetheless, should the loss of one bulb really be generating this amount of errors in the log file? My logging is set to error only. A light being unreachable probably should simply be reported as “device unreachable.”

16-12-08 10:30:01 homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/home/pi/.homeassistant/deps/flux_led/__init__.py", line 812, in __readResponse
    chunk = self.__readRaw(remaining)
  File "/home/pi/.homeassistant/deps/flux_led/__init__.py", line 822, in __readRaw
    return self.socket.recv(byte_count)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/.homeassistant/deps/flux_led/__init__.py", line 486, in refreshState
    rx = self.__readResponse(14)
  File "/home/pi/.homeassistant/deps/flux_led/__init__.py", line 814, in __readResponse
    self.reconnect()
  File "/home/pi/.homeassistant/deps/flux_led/__init__.py", line 791, in reconnect
    self.socket.connect((self.ipaddr, self.port))
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity_component.py", line 386, in _update_entity_states
    yield from update_coro
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity.py", line 213, in async_update_ha_state
    yield from self.hass.loop.run_in_executor(None, self.update)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/light/flux_led.py", line 159, in update
    self._bulb.refreshState()
  File "/home/pi/.homeassistant/deps/flux_led/__init__.py", line 489, in refreshState
    self.reconnect()
  File "/home/pi/.homeassistant/deps/flux_led/__init__.py", line 791, in reconnect
    self.socket.connect((self.ipaddr, self.port))
OSError: [Errno 113] No route to host

I have found it better and easier to go into router and adding the items to the address reservation setup under lan setup. https://gyazo.com/32656e57d11c0495000a1a5c68c6b071
And then adding the Ip addresses to the config file```

  • platform: flux_led
    devices:
    192.168.1.22:
    name: Cabinet Lights
    192.168.1.56:
    name: TV Color Lights
    192.168.1.61:
    name: TV Color Lights1
    keeps mine from disappearing. even if switch is tripped and comes back because I have the mac set to the IP my config file is looking for.

Thank you so much for putting this component together - I took a gamble and bought one of these off ebay

http://www.ebay.com.au/itm/DC12-24V-Wireless-WIFI-RGB-LED-Strip-Light-Controller-Remote-For-iOS-Android-/291878792712?hash=item43f554ee08:g:LcgAAOSwNRdX3lje

$12 AUD for a Wifi LED Strip controller - Yes please!

Guess what… IT WORKS… (mostly…) I got it working at first… after playing around alot the colours starting having a tantrum (I was getting over excited most likely) but the thing I found was the brightness control in HASS didn’t work (It does work in the Magic Home App.

I might do a separate post on this - $12 for a working strip light controller that integrates into HASS (even if it doesn’t dim) is an amazing find!

There are some variants out there of these controllers that still speak the same “MagicLight/MagicHome/Flux” protocol but have a ESP8266 chip inside instead of the HF-LBJ100. http://www.banggood.com/ARILUX-AL-LC09-Super-Mini-LED-WIFI-APP-Controller-RF-Remote-Control-For-RGB-LED-Strip-DC9-28V-p-1081344.html for example…

The controller you linked looks similar to one of them.

If you open it up, and it has a ESP8266… On most the RX/TX serial programming pins are exposed on the PCB. You can use a FTDI adapter and re-program the ESP8266 with one of many Arduino sketches that turns it into a MQTT controlled light, making it much easier to get full functionality with Home Assistant. (see: Alternative firmware for Arilux AL-LC03 for use with MQTT and Home Assistant (RGB light strip controller))

It seems to be different versions of the protocol. You can have look here: Can't change LED color on MagicHome LED controller

@Danielhiversen @Charles_Brown @mplawner I am trying to configure MagicLight LED wifi controller. Is there a workaround for connecting that wifi controller to my wifi network without creating MagicLight account?

Any comment/feedback highly appreciated.