MagicLight/Flux WiFi Color LED Light Component

(This is cross-posted from Development)

:bulb: If someone (within free shipping range of my Amazon Prime account - likely US) feels confident they could create this component, I’ll send them one of these light bulbs to make it easier to test.

I have a number of these lights in the house. They are all the same, under different names, all ~ $28-$35:

They use the Magic Home app to control:

And someone reverse engineered the protocol and created a nice and easy to use python script to control via command line:

I’ve integrated them crudely into my system as command line switches:

- platform: command_line
  switches:
    lamppost:
      oncmd: "/usr/local/bin/flux_led.py 192.168.0.106 --on"
      offcmd: "/usr/local/bin/flux_led.py 192.168.0.106 --off"
      statecmd: "/usr/local/bin/flux_led.py 192.168.0.106 -i | awk '/ON/{ print \"on\" }'"
      value_template: '{{ value == "on" }}'

Would it be so difficult, given the availability of the python script already written, to create a more feature rich, native LED color light?

1 Like

I do not have the lights, but I can try to implement it.
I will need help from you to test and verify the code.

1 Like

Here is something to start with: https://github.com/home-assistant/home-assistant/pull/2534

Try to put it in .homeassistant/custom_components/light

And add this to your configuration.yaml


light:
 platform: flux_led

For the moment only on/off is implemented.
Please post any error messages or problems.

1 Like

@fabaff
I see now that you have forked the flux_led repository.
Have you tried to add it to HA?

@Danielhiversen Just started to play around with it yesterday. So, no. I have two or three Wifi LED Controllers (white boxes) but no bulbs. I guess that I should try your custom component as soon as possible. Thanks for sharing.

Thanks, Daniel!

I loaded it up and here’s what I got in the logs:

16-07-13 09:38:13 homeassistant.util.package: Attempting install of https://github.com/Danielhiversen/flux_led/archive/master.zip#flux_led==0.2
16-07-13 09:38:21 homeassistant.components.light: Error while setting up platform flux_led
  File "/home/pi/.homeassistant/custom_components/light/flux_led.py", line 27, in setup_platform
  File "/home/pi/.homeassistant/deps/flux_led/__init__.py", line 779, in scan

Are you attempting to discover lights on the network? Or am I to configure IP addresses of existing bulbs?

Don’t know if this helps, but here is some more info about the bulbs which may or may not be relevant:
Looks like these bulbs have the HF-LPB100 chipset in common

Chinese LED Wifi Bulb Communication Protocol

Check your .homeassistant/deps folder and delete the two led_flux folders.
When you run Hass again it will download an updated version of the library. Please post the output in the log.

You can also try to download the new version of flux_led.py from dropbox and update your configuration file to:


light:
  platform: flux_led
  devices:
    192.168.0.106:
      name: lamppost
1 Like

Hi Daniel

I wasn’t sure, if you wanted me to, so I’m doing this in 2 steps.

Step 1 - Delete the 2 flux_led directories, restart, post log/errors.
Step 2 - Delete the 2 flux_led directories, download the updated flux_led.py from dropbox and make the changes to the configuration.yaml file, post log.

Here’s the results of Step 1:

16-07-13 16:48:40 homeassistant.loader: Loaded light.flux_led from custom_components.light.flux_led
16-07-13 16:48:40 homeassistant.util.package: Attempting install of https://github.com/Danielhiversen/flux_led/archive/master.zip#flux_led==0.2
16-07-13 16:48:47 homeassistant.components.light: Error while setting up platform flux_led
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity_component.py", line 98, in _setup_platform
    discovery_info)
  File "/home/pi/.homeassistant/custom_components/light/flux_led.py", line 27, in setup_platform
    scanner.scan(timeout=10)
  File "/home/pi/.homeassistant/deps/flux_led/__init__.py", line 781, in scan
    item['ipaddr'] = data.split(',')[0]
TypeError: Type str doesn't support the buffer API

In a few moments, I will execute Step 2.

Results of Step 2 (note: I used the name lamppost1 in case there was a conflict with the existing lamppost device)

16-07-13 16:57:09 homeassistant.loader: Loaded light.flux_led from custom_components.light.flux_led
16-07-13 16:57:09 homeassistant.util.package: Attempting install of https://github.com/Danielhiversen/flux_led/archive/master.zip#flux_led==0.2
16-07-13 16:57:16 homeassistant.components.light: Error while setting up platform flux_led
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity_component.py", line 98, in _setup_platform
    discovery_info)
  File "/home/pi/.homeassistant/custom_components/light/flux_led.py", line 33, in setup_platform
    light = FluxLight(device)
  File "/home/pi/.homeassistant/custom_components/light/flux_led.py", line 68, in __init__
    self._bulb = flux_led.WifiLedBulb(ipaddr)
  File "/home/pi/.homeassistant/deps/flux_led/__init__.py", line 452, in __init__
    self.socket.connect((self.ipaddr, self.port))
socket.gaierror: [Errno -2] Name or service not known

Just added one last step - removed the device stanza from the configuration.yaml and restarted:

16-07-13 17:01:53 homeassistant.loader: Loaded light.flux_led from custom_components.light.flux_led
16-07-13 17:01:53 homeassistant.components.light: Error while setting up platform flux_led
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity_component.py", line 98, in _setup_platform
    discovery_info)
  File "/home/pi/.homeassistant/custom_components/light/flux_led.py", line 43, in setup_platform
    scanner.scan(timeout=10)
  File "/home/pi/.homeassistant/deps/flux_led/__init__.py", line 781, in scan
    item['ipaddr'] = data.split(',')[0]
TypeError: Type str doesn't support the buffer API

Another try:

Step 1 - Delete the 2 flux_led directories, update flux_led.py from dropbox.
And add this to your configuration.yaml

light:
 platform: flux_led

restart, post log/errors.

Step 2 - Change the config to

light:
 platform: flux_led
  devices:
    192.168.0.106:
      name: lamppost1

restart, post log/errors.

Are you copying the log from the log file or from the console?
The are missing some out print from the flux library. So it would great if you could post the output from the console. But that depends of how you are running hass

Ok, yes, I was pulling info from the log. Sorry about that. Now I’m pulling from the console. (I’ve been running it as a service.)

Step 1:

INFO:homeassistant.loader:Loaded light.flux_led from custom_components.light.flux_led
INFO:homeassistant.util.package:Attempting install of https://github.com/Danielhiversen/flux_led/archive/master.zip#flux_led==0.2
INFO:pyvera.subscribe:Poll returned
INFO:pyvera.subscribe:Poll returned
b'192.168.0.106,ACCF239FDC4E,HF-LPB100-ZJ200' b'HF-A11ASSISTHREAD'
["b'192.168.0.106", 'ACCF239FDC4E', "HF-LPB100-ZJ200'"]
('192.168.0.106', 48899)
b'192.168.0.109,ACCF239FCF22,HF-LPB100-ZJ200' b'HF-A11ASSISTHREAD'
["b'192.168.0.109", 'ACCF239FCF22', "HF-LPB100-ZJ200'"]
('192.168.0.109', 48899)
b'192.168.0.128,ACCF23A10D14,HF-LPB100-ZJ200' b'HF-A11ASSISTHREAD'
["b'192.168.0.128", 'ACCF23A10D14', "HF-LPB100-ZJ200'"]
('192.168.0.128', 48899)
INFO:pyvera.subscribe:Poll returned
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.4/logging/__init__.py", line 978, in emit
    msg = self.format(record)
  File "/usr/lib/python3.4/logging/__init__.py", line 828, in format
    return fmt.format(record)
  File "/usr/lib/python3.4/logging/__init__.py", line 565, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.4/logging/__init__.py", line 328, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/usr/local/bin/hass", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/__main__.py", line 386, in main
    exit_code = setup_and_run_hass(config_dir, args)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/__main__.py", line 293, in setup_and_run_hass
    log_rotate_days=args.log_rotate_days)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/bootstrap.py", line 292, in from_config_file
    skip_pip=skip_pip)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/bootstrap.py", line 264, in from_config_dict
    _setup_component(hass, domain, config)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/bootstrap.py", line 150, in _setup_component
    if not component.setup(hass, config):
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/vera.py", line 97, in setup
    discovery.load_platform(hass, component, DOMAIN, {}, base_config)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/discovery.py", line 76, in load_platform
    bootstrap.setup_component(hass, component, hass_config)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/bootstrap.py", line 50, in setup_component
    if not _setup_component(hass, component, config):
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/bootstrap.py", line 150, in _setup_component
    if not component.setup(hass, config):
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/light/__init__.py", line 161, in setup
    component.setup(config)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity_component.py", line 53, in setup
    self._setup_platform(p_type, p_config)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity_component.py", line 98, in _setup_platform
    discovery_info)
  File "/home/pi/.homeassistant/custom_components/light/flux_led.py", line 46, in setup_platform
    _LOGGER.info("flux_led: \n\n", scanner.getBulbInfo() )
Message: 'flux_led: \n\n'
Arguments: ([{'ipaddr': "b'192.168.0.106", 'model': "HF-LPB100-ZJ200'", 'id': 'ACCF239FDC4E'}, {'ipaddr': "b'192.168.0.109", 'model': "HF-LPB100-ZJ200'", 'id': 'ACCF239FCF22'}, {'ipaddr': "b'192.168.0.128", 'model': "HF-LPB100-ZJ200'", 'id': 'ACCF23A10D14'}],)
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.4/logging/__init__.py", line 978, in emit
    msg = self.format(record)
  File "/usr/lib/python3.4/logging/__init__.py", line 828, in format
    return fmt.format(record)
  File "/usr/lib/python3.4/logging/__init__.py", line 565, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.4/logging/__init__.py", line 328, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/usr/local/bin/hass", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/__main__.py", line 386, in main
    exit_code = setup_and_run_hass(config_dir, args)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/__main__.py", line 293, in setup_and_run_hass
    log_rotate_days=args.log_rotate_days)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/bootstrap.py", line 292, in from_config_file
    skip_pip=skip_pip)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/bootstrap.py", line 264, in from_config_dict
    _setup_component(hass, domain, config)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/bootstrap.py", line 150, in _setup_component
    if not component.setup(hass, config):
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/vera.py", line 97, in setup
    discovery.load_platform(hass, component, DOMAIN, {}, base_config)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/discovery.py", line 76, in load_platform
    bootstrap.setup_component(hass, component, hass_config)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/bootstrap.py", line 50, in setup_component
    if not _setup_component(hass, component, config):
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/bootstrap.py", line 150, in _setup_component
    if not component.setup(hass, config):
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/light/__init__.py", line 161, in setup
    component.setup(config)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity_component.py", line 53, in setup
    self._setup_platform(p_type, p_config)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity_component.py", line 98, in _setup_platform
    discovery_info)
  File "/home/pi/.homeassistant/custom_components/light/flux_led.py", line 46, in setup_platform
    _LOGGER.info("flux_led: \n\n", scanner.getBulbInfo() )
Message: 'flux_led: \n\n'
Arguments: ([{'ipaddr': "b'192.168.0.106", 'model': "HF-LPB100-ZJ200'", 'id': 'ACCF239FDC4E'}, {'ipaddr': "b'192.168.0.109", 'model': "HF-LPB100-ZJ200'", 'id': 'ACCF239FCF22'}, {'ipaddr': "b'192.168.0.128", 'model': "HF-LPB100-ZJ200'", 'id': 'ACCF23A10D14'}],)
INFO:custom_components.light.flux_led:b'192.168.0.106
ERROR:homeassistant.components.light:Error while setting up platform flux_led
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity_component.py", line 98, in _setup_platform
    discovery_info)
  File "/home/pi/.homeassistant/custom_components/light/flux_led.py", line 49, in setup_platform
    light = FluxLight(device)
  File "/home/pi/.homeassistant/custom_components/light/flux_led.py", line 70, in __init__
    self._bulb = flux_led.WifiLedBulb(ipaddr)
  File "/home/pi/.homeassistant/deps/flux_led/__init__.py", line 452, in __init__
    self.socket.connect((self.ipaddr, self.port))
socket.gaierror: [Errno -2] Name or service not known
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=light, service=turn_on>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=light, service=turn_off>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=light, service=toggle>
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=light>

Step 2:

INFO:homeassistant.loader:Loaded light.flux_led from custom_components.light.flux_led
INFO:homeassistant.util.package:Attempting install of https://github.com/Danielhiversen/flux_led/archive/master.zip#flux_led==0.2
INFO:custom_components.light.flux_led:192.168.0.106
INFO:custom_components.light.flux_led:192.168.0.106
ERROR:homeassistant.components.light:Error while setting up platform flux_led
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity_component.py", line 98, in _setup_platform
    discovery_info)
  File "/home/pi/.homeassistant/custom_components/light/flux_led.py", line 38, in setup_platform
    add_devices_callback(lights)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity_component.py", line 155, in add_entities
    if self.component.add_entity(entity, self):
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity_component.py", line 125, in add_entity
    entity.update_ha_state()
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity.py", line 165, in update_ha_state
    state = STATE_UNKNOWN if self.state is None else str(self.state)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity.py", line 237, in state
    return STATE_ON if self.is_on else STATE_OFF
  File "/home/pi/.homeassistant/custom_components/light/flux_led.py", line 82, in is_on
    self.update_lights()
AttributeError: 'FluxLight' object has no attribute 'update_lights'
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=turn_on, domain=light>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=turn_off, domain=light>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=toggle, domain=light>
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=light>

BTW - These lights are down at ~$28 today on Amazon: https://smile.amazon.com/gp/product/B00SIDVZSW
They do claim to work in US and Europe, fitting both sizes E26 and E27 standards and covering the range of voltage from 85v to 220v.

Ok, I will have a look at it tomorrow.
Unfortunately, they are not shipping to Norway. Have not found anyone that ships to Norway

These folks ship internationally:


But don’t order, Daniel… yours is in the mail :wink:
1 Like

I think we are getting close to have something.
It would be great if you could do step 1 and 2 again.

Step 1 Success!!!

INFO:homeassistant.loader:Loaded light.flux_led from custom_components.light.flux_led
INFO:homeassistant.util.package:Attempting install of https://github.com/Danielhiversen/flux_led/archive/master.zip#flux_led==0.2
192.168.0.106,ACCF239FDC4E,HF-LPB100-ZJ200 b'HF-A11ASSISTHREAD'
['192.168.0.106', 'ACCF239FDC4E', 'HF-LPB100-ZJ200']
('192.168.0.106', 48899)
192.168.0.129,ACCF239FD35E,HF-LPB100-ZJ200 b'HF-A11ASSISTHREAD'
['192.168.0.129', 'ACCF239FD35E', 'HF-LPB100-ZJ200']
('192.168.0.129', 48899)
INFO:pyvera.subscribe:Poll returned
[{'model': 'HF-LPB100-ZJ200', 'ipaddr': '192.168.0.106', 'id': 'ACCF239FDC4E'}, {'model': 'HF-LPB100-ZJ200', 'ipaddr': '192.168.0.129', 'id': 'ACCF239FD35E'}]
INFO:custom_components.light.flux_led:192.168.0.106
INFO:custom_components.light.flux_led:192.168.0.129
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=None, entity_id=light.accf239fdc4e, new_state=<state light.accf239fdc4e=off; friendly_name=ACCF239FDC4E @ 2016-07-15T08:52:33.917085-04:00>>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=None, entity_id=light.accf239fd35e, new_state=<state light.accf239fd35e=off; friendly_name=ACCF239FD35E @ 2016-07-15T08:52:34.032343-04:00>>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=None, entity_id=group.all_lights, new_state=<state group.all_lights=unknown; order=1, friendly_name=all lights, entity_id=[], hidden=True, auto=True @ 2016-07-15T08:52:34.038200-04:00>>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=<state group.all_lights=unknown; order=1, friendly_name=all lights, entity_id=[], hidden=True, auto=True @ 2016-07-15T08:52:34.038200-04:00>, entity_id=group.all_lights, new_state=None>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=None, entity_id=group.all_lights, new_state=<state group.all_lights=off; order=1, friendly_name=all lights, entity_id=('light.accf239fd35e', 'light.accf239fdc4e'), hidden=True, auto=True @ 2016-07-15T08:52:34.243372-04:00>>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=light, service=turn_on>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=light, service=turn_off>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=light, service=toggle>
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=light>

Note: Not all lights were discovered. I have 4 total lights on the network.

First attempt to turn on a light did nothing:

INFO:homeassistant.core:Bus:Handling <Event call_service[L]: domain=homeassistant, service_call_id=1979810288-3, service_data=entity_id=light.accf239fd35e, service=turn_on>
INFO:homeassistant.core:Bus:Handling <Event call_service[L]: domain=light, service_call_id=1979810288-4, service_data=entity_id=['light.accf239fd35e'], service=turn_on>
INFO:homeassistant.core:Bus:Handling <Event service_executed[L]: service_call_id=1979810288-4>
INFO:homeassistant.core:Bus:Handling <Event service_executed[L]: service_call_id=1979810288-3>

But second attempt was a success!

INFO:homeassistant.core:Bus:Handling <Event call_service[L]: domain=homeassistant, service_call_id=1979810288-5, service_data=entity_id=light.accf239fd35e, service=turn_on>
INFO:homeassistant.core:Bus:Handling <Event call_service[L]: domain=light, service_call_id=1979810288-6, service_data=entity_id=['light.accf239fd35e'], service=turn_on>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=<state light.accf239fd35e=off; friendly_name=ACCF239FD35E @ 2016-07-15T08:52:34.032343-04:00>, entity_id=light.accf239fd35e, new_state=<state light.accf239fd35e=on; friendly_name=ACCF239FD35E @ 2016-07-15T08:56:52.227895-04:00>>
INFO:homeassistant.core:Bus:Handling <Event service_executed[L]: service_call_id=1979810288-6>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=<state group.all_lights=off; order=1, friendly_name=all lights, entity_id=('light.linear_wd500z1_wall_dimmer_switch_level_8', 'light.ge_45602_lamp_dimmer_module_level_16', 'light.accf239fd35e', 'light.ge_12724_3way_dimmer_switch_level_11', 'light.linear_wd500z1_wall_dimmer_switch_level_9', 'light.accf239fdc4e', 'light.ge_12724_3way_dimmer_switch_level_10', 'light.linear_unknown_type4754_id3038_level_21'), hidden=True, auto=True @ 2016-07-15T08:52:47.444046-04:00>, entity_id=group.all_lights, new_state=<state group.all_lights=on; order=1, friendly_name=all lights, entity_id=('light.linear_wd500z1_wall_dimmer_switch_level_8', 'light.ge_45602_lamp_dimmer_module_level_16', 'light.accf239fd35e', 'light.ge_12724_3way_dimmer_switch_level_11', 'light.linear_wd500z1_wall_dimmer_switch_level_9', 'light.accf239fdc4e', 'light.ge_12724_3way_dimmer_switch_level_10', 'light.linear_unknown_type4754_id3038_level_21'), hidden=True, auto=True @ 2016-07-15T08:56:52.286938-04:00>>
INFO:homeassistant.core:Bus:Handling <Event service_executed[L]: service_call_id=1979810288-5>

Note: Looks like if I turn on/off the light from the MagicLight app, Home Assistant doesn’t notice the state change.

Step 2:

INFO:homeassistant.loader:Loaded light.flux_led from custom_components.light.flux_led
INFO:homeassistant.util.package:Attempting install of https://github.com/Danielhiversen/flux_led/archive/master.zip#flux_led==0.2
INFO:custom_components.light.flux_led:192.168.0.106
INFO:custom_components.light.flux_led:192.168.0.106
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=<state light.lamppost1=off; friendly_name=lamppost1 @ 2016-07-15T09:11:37.155378-04:00>, entity_id=light.lamppost1, old_state=None>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=<state group.all_lights=unknown; hidden=True, auto=True, friendly_name=all lights, order=1, entity_id=[] @ 2016-07-15T09:11:37.158417-04:00>, entity_id=group.all_lights, old_state=None>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=None, entity_id=group.all_lights, old_state=<state group.all_lights=unknown; hidden=True, auto=True, friendly_name=all lights, order=1, entity_id=[] @ 2016-07-15T09:11:37.158417-04:00>>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=<state group.all_lights=off; hidden=True, auto=True, friendly_name=all lights, order=1, entity_id=('light.lamppost1',) @ 2016-07-15T09:11:37.165293-04:00>, entity_id=group.all_lights, old_state=None>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=light, service=turn_on>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=light, service=turn_off>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=light, service=toggle>
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=light>

Note: No discovery of other devices found.

Turn Switch On:

INFO:homeassistant.core:Bus:Handling <Event call_service[L]: domain=homeassistant, service=turn_on, service_data=entity_id=light.lamppost1, service_call_id=1979204048-3>
INFO:homeassistant.core:Bus:Handling <Event call_service[L]: domain=light, service=turn_on, service_data=entity_id=['light.lamppost1'], service_call_id=1979204048-4>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=<state light.lamppost1=on; friendly_name=lamppost1 @ 2016-07-15T09:15:58.859440-04:00>, entity_id=light.lamppost1, old_state=<state light.lamppost1=off; friendly_name=lamppost1 @ 2016-07-15T09:11:37.155378-04:00>>
INFO:homeassistant.core:Bus:Handling <Event service_executed[L]: service_call_id=1979204048-4>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: new_state=<state group.all_lights=on; hidden=True, auto=True, friendly_name=all lights, order=1, entity_id=('light.linear_unknown_type4754_id3038_level_21', 'light.ge_12724_3way_dimmer_switch_level_10', 'light.ge_12724_3way_dimmer_switch_level_11', 'light.lamppost1', 'light.linear_wd500z1_wall_dimmer_switch_level_9', 'light.linear_wd500z1_wall_dimmer_switch_level_8', 'light.ge_45602_lamp_dimmer_module_level_16') @ 2016-07-15T09:15:58.872807-04:00>, entity_id=group.all_lights, old_state=<state group.all_lights=off; hidden=True, auto=True, friendly_name=all lights, order=1, entity_id=('light.linear_unknown_type4754_id3038_level_21', 'light.ge_12724_3way_dimmer_switch_level_10', 'light.ge_12724_3way_dimmer_switch_level_11', 'light.lamppost1', 'light.linear_wd500z1_wall_dimmer_switch_level_9', 'light.linear_wd500z1_wall_dimmer_switch_level_8', 'light.ge_45602_lamp_dimmer_module_level_16') @ 2016-07-15T09:12:03.188801-04:00>>
INFO:homeassistant.core:Bus:Handling <Event service_executed[L]: service_call_id=1979204048-3>

Note: Again, changing the state of the light didn’t update the status of the light in Home Assistant.

This is awesome, Daniel! Thanks!

I got one of these bulbs on Amazon Prime day as well and I’ll test the custom component as well.

I changed the format of the configuration a bit:

light 3:                                                                                                                                                                                                            
   platform: flux_led                                                                                                                                                                                               
   automatic_add: True                                                                                                                                                                                              
   devices:                                                                                                                                                                                                         
     192.168.1.5:                                                                                                                                                                                                   
       name: test                                                                                                                                                                                                   
     192.168.1.3:                                                                                                                                                                                                   
       name: test2                                                                                                                                                                                                  
                  

Then it should be possible to manually add devices or automatically add them.
Do you like the way of configuration it?

Hmm, should work, but might be a delay before HA is updated. The bulb is not pushing any information back to HA, so the status will not update before HA ask for an updated status.

@tchellomello
Great, please post any bugs or suggestions for improvements.
At the moment only on/off is supported

Hello guys,

@Danielhiversen the flux_led.py worked as expected and I got was able to turn on/off the Flux Wifi light.
It would be awesome to change brightness, color and use all the features but I’m pretty sure it is on the roadmap.

However I did have an unexpected problem with my hue lights. First, I was using the discovery: component to manage my Hue lights however after enabling the “lights” component it stopped working.

I think the discovery was still working because my Wemo switches continued working as expected, but only the Hue stopped. To troubleshoot it, I enabled it via configuration file as follow:

(home_assistant) ↪ cat lights.yaml 
# vim:sw=2:ts=2:et:
- platform: hue
  host: 192.168.169.18
  allow_unreachable: true
  #filename: hue_token.conf

#https://community.home-assistant.io/t/magiclight-flux-wifi-color-led-light-component/2271/6
- platform: flux_led
  devices:
    flux-garage-bulb.tatu.home:
      name: garage

As we know, when the filename is not present, it will save the phue.conf file with the token. Using the filename or just leaving the default phue.conf ends-up with the same error:

318 16-07-16 01:13:30 phue: Attempting to connect to the bridge...
319 16-07-16 01:13:30 phue: Error opening config file, will attempt bridge registration
320 16-07-16 01:13:30 phue: Writing configuration file to /home/mdemello/.homeassistant/phue.conf
321 16-07-16 01:13:30 phue: Reconnecting to the bridge
322 16-07-16 01:13:30 phue: Attempting to connect to the bridge...
323 16-07-16 01:13:30 phue: Using ip: 192.168.169.18
324 16-07-16 01:13:30 phue: Using username from config: EYFcHnX<SNIP>W3d1
325 16-07-16 01:13:30 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=configurator.philips_hue, new_state=<state configurator.philips_hue=configured @ 20    16-07-16T01:13:30.218129-04:00>, old_state=<state configurator.philips_hue=configure; fields=[], submit_caption=I have pressed the button, configure_id=140311570860184-1    , friendly_name=Philips Hue, description=Press the button on the bridge to register Philips Hue with Home Assistant., description_image=/static/images/config_philips_hue.jpg, errors=Failed to register, please try again. @ 2016-07-16T01:11:38.446752-04:00>>
326 16-07-16 01:13:30 homeassistant.core: BusHandler:Exception doing job
327 Traceback (most recent call last):
328   File "/home/mdemello/devel/home-assistant/homeassistant/core.py", line 835, in job_handler
329     func(arg)
330   File "/home/mdemello/devel/home-assistant/homeassistant/core.py", line 688, in _execute_service
331     service(call)
332   File "/home/mdemello/devel/home-assistant/homeassistant/core.py", line 547, in __call__
333     self.func(call)
334   File "/home/mdemello/devel/home-assistant/homeassistant/components/configurator.py", line 183, in handle_service_call
335     callback(call.data.get(ATTR_FIELDS, {}))
336   File "/home/mdemello/devel/home-assistant/homeassistant/components/light/hue.py", line 169, in hue_configuration_callback
337     allow_unreachable)
338   File "/home/mdemello/devel/home-assistant/homeassistant/components/light/hue.py", line 150, in setup_bridge
339     update_lights()
340   File "/home/mdemello/devel/home-assistant/homeassistant/util/__init__.py", line 289, in wrapper
341     result = method(*args, **kwargs)
342   File "/home/mdemello/devel/home-assistant/homeassistant/util/__init__.py", line 289, in wrapper
343     result = method(*args, **kwargs)
344   File "/home/mdemello/devel/home-assistant/homeassistant/components/light/hue.py", line 147, in update_lights
345     add_devices_callback(new_lights)
346   File "/home/mdemello/devel/home-assistant/homeassistant/helpers/entity_component.py", line 155, in add_entities
347     if self.component.add_entity(entity, self):
348   File "/home/mdemello/devel/home-assistant/homeassistant/helpers/entity_component.py", line 108, in add_entity
349     if entity is None or entity in self.entities.values():
350   File "/home/mdemello/devel/home-assistant/homeassistant/helpers/entity.py", line 223, in __eq__
351     other.unique_id == self.unique_id)
352   File "/home/mdemello/.homeassistant/custom_components/light/flux_led.py", line 91, in unique_id
353     self.__class__, self.info.get('uniqueid', self._name))
354 AttributeError: 'FluxLight' object has no attribute 'info'

Looking at the flux_led.py library, it seems it is returning the ID as expected, however the method unique_id() needs to be fixed

INFO:custom_components.light.flux_led:flux-garage-bulb.tatu.home
INFO:custom_components.light.flux_led:flux-garage-bulb.tatu.home
192.168.169.165,ACCF23920E4A,HF-LPB100-ZJ200 b'HF-A11ASSISTHREAD'
['192.168.169.165', 'ACCF23920E4A', 'HF-LPB100-ZJ200']
('192.168.169.165', 48899)

Then, I modified the method as showed below:

(home_assistant) ↪ diff -ruN flux_led.py.orig  flux_led.py
--- flux_led.py.orig	2016-07-16 02:20:24.568925634 -0400
+++ flux_led.py	2016-07-16 02:21:05.141146861 -0400
@@ -86,9 +86,8 @@
 
     @property
     def unique_id(self):
-        """Return the ID of this Hue light."""
-        return "{}.{}".format(
-            self.__class__, self.info.get('uniqueid', self._name))
+        """Return the ID of this light."""
+        return self._name
 
     @property
     def name(self):

After doing it, Hue and flue_led worked as expected.

I have not found the git location for the HA backport for flux_led.py but you can update the dropbox link for future users.

Let’s add more functionalities to this library since those bulbs are cheaper and work quite fine too (not the same quality, but it’s cheap solution).

Thank you for porting it to HASS.

Best Regards,
mmello

1 Like