Xiaomi Yeelight E27 bulb component

It has a minor bug. Sometimes it shows the light is on, while in reality is off.

For the rest is working

Yeah, just noticed that now it doesn’t read the status of the light. If I turn the light off/on on the Yeelight APP it doesn’t update the status :frowning:

What are the values you put for a warm whit light?

Is there anyway to add support for the Xiaomi Philips Eyecare light?

where is the folder of custom_components? i can’t find it in my home assistant folder?

Just create it on the homeassistant root folder

not working,

What not work @kornfool? Because i have 6 yeelight bulbs and all works with the custom component

@mxtra Thank you for yeelight-ha !!

Here are some bugs I found:

  1. Customizations don’t seem to work with yeelight platform when imported from yeelight.py (ex. I can’t change the friendly_name or set a custom icon)
  2. I can’t set the default brightness
  3. HA GUI doesn’t change state if light bulb changes state (by hand or via yeelight app)

Would it be possible to address this issues?
Also, is there a plan to merge this into HA?

i create custom components folder but don’t seem it working.

The state of the bulb it’s bad :frowning: can’t use or rely on it atm because of it… hope it gets fixed soon

Hello,

i have https://www.aliexpress.com/item/Original-For-Xiaomi-Yeelight-E27-Led-Adjustable-Brightness-Wifi-Remote-Control-Smart-LED-Bulb-8W-600/32708909107.html?ws_ab_test=searchweb0_0,searchweb201602_5_10065_10068_10000009_10084_10083_10080_10082_10081_10060_10062_10056_10055_10054_10033_10059_10099_10078_10079_10000012_10103_10073_10102_10000015_10096_10052_10053_10050_10107_10106_10051,searchweb201603_3,afswitch_5_afChannel,single_sort_0_default&btsid=eea0b4c4-6103-40c7-91e7-8b7dd43be1a3

this still can work? i try to add the line to the my HA but this is not working.

i be happy to help,

via telnet the lamp is off on via command
{“id”:1,“method”:“set_power”,“params”:[“off”, “smooth”, 2000]}
work fine,

but with HA i cannot get it to work, i try all step user add here, non of this work for me.

any one can tell me what i need to do exactly?

Big Thanks!

Yanir

The following presumes that you are running Linux (and probably works on MacOS) and that you have installed home assistant to run as “hass” user:

sudo su -s /bin/bash hass
mkdir -p /home/hass/.homeassistant/custom_components/light
cd /home/hass/.homeassistant/custom_components/light
wget https://raw.githubusercontent.com/mxtra/yeelight-ha/master/yeelight.py

Then in HA configuration.yaml:

lights:
    - platform: yeelight
      devices:
        10.0.0.51:
          name: Living Room Light
          transition: 600

NOTE: Substitute 10.0.0.51 with the ip address of your yeelight light bulb
IMPORTANT: You need to enable developer support on the light bulb using the yeelight app.

Restart HA and test

Will this override the existing yeelight component that is currently in HA?

I have a small problem with the yeelight platform.
Since the yeelight platform has no transition property I am using a small automation + template trick to decrease the brightness every 5 minutes.
The problems is that the log gets full of errors. The automation still works but the log file gets huge. Am I doing something wrong?

- alias: Living dim lights
  hide_entity: False
  trigger:
      - platform: time
        minutes: '/5'
        seconds: 00
  condition:
    - condition: and
      conditions:
      - condition: time
        after: '22:00:00'
        before: '22:59:00'
  action:
    - service: homeassistant.turn_on
      entity_id: group.xiaomi_living
      data_template:
        brightness: '{{ 255 - now().minutes }}'

Additional info:
A small sample from the log:

17-01-10 20:40:00 homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 386, in _update_entity_states
    yield from update_coro
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 216, 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 "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/light/yeelight.py", line 115, in update
    self._bulb.refresh_property()
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/__init__.py", line 72, in refresh_property
    self.api_call.operate_on_bulb("get_prop", prop_list)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightAPICall.py", line 63, in operate_on_bulb
    self.response = YeelightResponse(data.decode(), self.command)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightMessage.py", line 116, in __init__
    self.decode_response(raw_response)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightMessage.py", line 131, in decode_response
    self.check_id()
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightMessage.py", line 148, in check_id
    self.command.get_command_id()))
Exception: Error decoding response : the response id 18848 doesn't match the command id 52107
17-01-10 20:52:00 homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1049, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/light/__init__.py", line 241, in async_handle_light_service
    yield from light.async_turn_on(**params)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 353, in async_turn_on
    None, ft.partial(self.turn_on, **kwargs))
  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 "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/light/yeelight.py", line 106, in turn_on
    self._bulb.set_brightness(bright)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/__init__.py", line 191, in set_brightness
    self.api_call.operate_on_bulb("set_bright", params)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightAPICall.py", line 63, in operate_on_bulb
    self.response = YeelightResponse(data.decode(), self.command)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightMessage.py", line 116, in __init__
    self.decode_response(raw_response)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightMessage.py", line 131, in decode_response
    self.check_id()
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightMessage.py", line 148, in check_id
    self.command.get_command_id()))
Exception: Error decoding response : the response id 12786 doesn't match the command id 32749
17-01-10 20:56:00 homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 386, in _update_entity_states
    yield from update_coro
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 216, 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 "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/light/yeelight.py", line 115, in update
    self._bulb.refresh_property()
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/__init__.py", line 72, in refresh_property
    self.api_call.operate_on_bulb("get_prop", prop_list)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightAPICall.py", line 63, in operate_on_bulb
    self.response = YeelightResponse(data.decode(), self.command)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightMessage.py", line 116, in __init__
    self.decode_response(raw_response)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightMessage.py", line 127, in decode_response
    data = json.loads(raw_response)
  File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.4/json/decoder.py", line 346, in decode
    raise ValueError(errmsg("Extra data", s, end, len(s)))
ValueError: Extra data: line 2 column 1 - line 3 column 1 (char 88 - 131)
17-01-10 20:56:00 homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1049, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/light/__init__.py", line 241, in async_handle_light_service
    yield from light.async_turn_on(**params)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 353, in async_turn_on
    None, ft.partial(self.turn_on, **kwargs))
  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 "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/light/yeelight.py", line 106, in turn_on
    self._bulb.set_brightness(bright)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/__init__.py", line 191, in set_brightness
    self.api_call.operate_on_bulb("set_bright", params)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightAPICall.py", line 63, in operate_on_bulb
    self.response = YeelightResponse(data.decode(), self.command)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightMessage.py", line 116, in __init__
    self.decode_response(raw_response)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightMessage.py", line 127, in decode_response
    data = json.loads(raw_response)
  File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.4/json/decoder.py", line 346, in decode
    raise ValueError(errmsg("Extra data", s, end, len(s)))
ValueError: Extra data: line 2 column 1 - line 3 column 1 (char 30 - 73)
17-01-10 21:00:00 homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 386, in _update_entity_states
    yield from update_coro
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 216, 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 "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/light/yeelight.py", line 115, in update
    self._bulb.refresh_property()
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/__init__.py", line 75, in refresh_property
    self.property[prop_list[i]] = self.api_call.get_response()[i]
IndexError: list index out of range
17-01-10 21:04:00 homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1049, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/light/__init__.py", line 241, in async_handle_light_service
    yield from light.async_turn_on(**params)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 353, in async_turn_on
    None, ft.partial(self.turn_on, **kwargs))
  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 "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/light/yeelight.py", line 106, in turn_on
    self._bulb.set_brightness(bright)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/__init__.py", line 191, in set_brightness
    self.api_call.operate_on_bulb("set_bright", params)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightAPICall.py", line 63, in operate_on_bulb
    self.response = YeelightResponse(data.decode(), self.command)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightMessage.py", line 116, in __init__
    self.decode_response(raw_response)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightMessage.py", line 127, in decode_response
    data = json.loads(raw_response)
  File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.4/json/decoder.py", line 346, in decode
    raise ValueError(errmsg("Extra data", s, end, len(s)))
ValueError: Extra data: line 2 column 1 - line 3 column 1 (char 31 - 74)
17-01-10 21:08:00 homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1049, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/light/__init__.py", line 241, in async_handle_light_service
    yield from light.async_turn_on(**params)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 353, in async_turn_on
    None, ft.partial(self.turn_on, **kwargs))
  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 "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/light/yeelight.py", line 106, in turn_on
    self._bulb.set_brightness(bright)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/__init__.py", line 191, in set_brightness
    self.api_call.operate_on_bulb("set_bright", params)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightAPICall.py", line 63, in operate_on_bulb
    self.response = YeelightResponse(data.decode(), self.command)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightMessage.py", line 116, in __init__
    self.decode_response(raw_response)
  File "/home/homeassistant/.homeassistant/deps/pyyeelight/yeelightMessage.py", line 127, in decode_response
    data = json.loads(raw_response)
  File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.4/json/decoder.py", line 346, in decode
    raise ValueError(errmsg("Extra data", s, end, len(s)))
ValueError: Extra data: line 2 column 1 - line 3 column 1 (char 31 - 74)

Transition works for me with the https://github.com/mxtra/yeelight-ha

This seems a bit old. Does it work properly with all light bulbs (including the color ones)? The transition applies only to the color/temp or to the brightness?

what seems old @covrig

how to, where?

I have a white yeelight and works perfectly.

I just added an RGB, and it does not work in HASS

  - platform: yeelight
    automatic_add: False
    devices:
      192.168.1.203:
        name: Hallway left
      192.168.1.204:
        name: Living table lamp