Xiaomi Yeelight E27 bulb component

Also check that tabs are not used. All indentation should be done with spaces. Sometimes with copy/paste or depending on the editor you use, tabs will be inserted.

yes exactly, I learned it the hard way in the past … the best is to backspace and then press space, to avoid problems

i dont know what i’m do wrong… so hard to use HA.

i check , there is not any spaces after.
how many spaces i need to make before the titile?

Big Thanks for try to help me.

is it (correct)
platform: yeelight
or (wrong)
platform:yeelight

Make it like this:

light:
  - platform: yeelight
    automatic_add: False
    devices:
      192.168.1.203:
        name: Hallway left

Ok!! Now that work but i get on HA

Invalid config
The following components and platforms could not be set up:

light.yeelight

Please check your config

i make it like this.

https://hastebin.com/dicaquwihi.css

And this is the log
https://hastebin.com/amihusivib.sql

Big Thanks for help me!

put the - is missing

and also
platform: yeelight you put 2 spaces, and not 1.

Not sure if it is that, but remember to follow well indentation and spaces

Big Thankd, but still not working i get same
The following components and platforms could not be set up:

i give up.

Thanks anyway,

See here: https://hastebin.com/abegumofox.css

You needed a space between platform and yeelight.

Also you had to many spaces before devices. That threw the rest of the spacing off also.

Yes, it works!
I got my RGB bulb today, so I plugged it in, enrolled it to the iPhone yeelight app, upgraded the firmware, enabled developer mode, configured a static dhcp leas for the it on my router (OpenWRT), rebooted and got the new ip.
Then just added the new ip address under “devices:” under “platform: yeelight” and off course I added a “name: something” under the new ip. IMPORTANT: watch the yaml indentations!
Rebooted HA and it worked!

I get temperature, brightness and color control under HA.

A few notes:

  • The temperature control on the yeelight color bulb is not very natural, plus the more you go into the lower kelvins the less lumens I get and the more two-color shade I can recognize.
  • I don’t have any other smart lights so I don’t know how HA should behave, but transition doesn’t seem to do anything, and I cant set default brightness or temperature while defining the yeelight in lights: section.

May I suggest trying to get more interactive help on the https://gitter.im/home-assistant/home-assistant chat

No way!!! after 3 week i’m work on it, that work!!

how you did it?!?!? i try all options that i can think so!

Big Big Thanks! that work… I do not believe, almost despaired.

for next time, how can i know how many space need to be?
there is i can read about it?

i love you men big Thanks!

no one help there i try… no one like newbie user.

silvrr resolve me issue, i dont know how but work!

I also have problems.

I put the yeelight component, and add under custom_component/light/yeelight.py

My white yeelight lamp was working correctly. Then I added two RGB which were discovered, put in front end, but not working from front end (everything ok from the MiHome app).

So now I tried to remove the custom_compoinent, (from my understanding the White should not work, but the RGB it should). But none work now

this is the log

17-01-12 20:49:20 homeassistant.components.light.yeelight: Failed to connect to bulb 192.168.1.203, Hallway left
17-01-12 20:49:20 homeassistant.components.light.yeelight: Failed to connect to bulb 192.168.1.204, Living table lamp
17-01-12 20:49:20 homeassistant.components.light.yeelight: Failed to connect to bulb 192.168.1.206, TV Room top lamp
17-01-12 20:49:20 homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 335, in _async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 204, in async_add_entity
    yield from entity.async_update_ha_state()
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 220, in async_update_ha_state
    state = self.state
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 338, in state
    return STATE_ON if self.is_on else STATE_OFF
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/light/yeelight.py", line 77, in is_on
    return self._state == self._bulb.POWER_ON
AttributeError: 'NoneType' object has no attribute 'POWER_ON'
17-01-12 20:49:20 homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 335, in _async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 204, in async_add_entity
    yield from entity.async_update_ha_state()
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 220, in async_update_ha_state
    state = self.state
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 338, in state
    return STATE_ON if self.is_on else STATE_OFF
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/light/yeelight.py", line 77, in is_on
    return self._state == self._bulb.POWER_ON
AttributeError: 'NoneType' object has no attribute 'POWER_ON'
17-01-12 20:49:20 homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 335, in _async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 204, in async_add_entity
    yield from entity.async_update_ha_state()
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 220, in async_update_ha_state
    state = self.state
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 338, in state
    return STATE_ON if self.is_on else STATE_OFF
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/light/yeelight.py", line 77, in is_on
    return self._state == self._bulb.POWER_ON
At

From my experience it is always two spaces. Generally, I follow the example given on the component page, and any indentation I put two spaces.

To read up a bit more on YAML:

I am confused.

I put the yeelight.py (of mxtra) under custom_components/light/

and what about yeelight.py of jjensn

???

did you use the custom_components?

You can’t use both.
Python will load any custom component/script that you put in custom_components under the appropriate category. If you put there something with the same name as the built in component that comes with home assistent, python will load that instead of the built in module. Hence, you cannot have/load two yeelight platforms.

At the moment, I would say that maxtra’s code works best, so just use that.

Ok clear.

I put yeelight.py of mxtra back in custom_components/light/
and nothing else, correct? cancelling the directory that was inside …

I did this and now.

The white lamp disappeared … none to be found in the log (and not in front end)
The RGB lamps are present in the log (with error)
17-01-12 21:40:00 custom_components.light.yeelight: Failed to connect to bulb 192.168.1.204, Living table lamp

and this

Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
    result = next(coro)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 335, in _async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 204, in async_add_entity
    yield from entity.async_update_ha_state()
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 220, in async_update_ha_state
    state = self.state
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 338, in state
    return STATE_ON if self.is_on else STATE_OFF
  File "/home/hass/.homeassistant/custom_components/light/yeelight.py", line 100, in is_on
    return self.bulb.isOn()
AttributeError: 'YeelightBulb' object has no attribute 'isOn'
1

Yes, only maxtra’s yeelight.py file.
Try to stop HA, remove the pyache dir, then start HA. Just in case something wired happened to the code.

Check if the IP addresses of the devices changed. I would recommend setting a DHCP Static lease for your smart devices. This way they never change.
Then check that you didn’t mix up the ip and name in the devices list/section. Keep in mind that all sceens, automations, everything really, is done by the name of the device. This happened to me once :slight_smile: I switched device places, changed the ip’s in the conf but didn’t change the names (no need to, because names describe places). Then when the automations kicked in, all hell broke loose :slight_smile: Basically the two devices had different set of features, so one of the devices was complaining and broke HA.

this I did.

Shall I keep this?
automatic_add: False