Xiaomi Yeelight E27 bulb component

Bulbs are all connected - i can control them via the Yeelight app!

I am using this script ( https://raw.githubusercontent.com/home-assistant/home-assistant/dev/homeassistant/components/light/yeelight.py) and it is working ok with my white and colored Yeelight bulbs, but I have a problem related to brightness dimming/brightening when I am using emulated_hue with Google Home.

If I say"Ok Google, set the brightness to xx%", everything is ok, but if i say “Ok Google, dim the lights”, the brightness goes all the time at 1% and if I say “Ok Google, brighten the lights”. it goes all the time at 2%.

What could be the problem?

Were they connected at that moment too? When the app is open, it’s not possible for home assistant to access the bulbs.

@Ciquattro the music mode required a fix to work on multiple bulbs, I hope I can get it in for 0.38 which will also include the module. The only use for the mode is that the commands are more instant as the connection is hold by the component, so if you don’t really require that (and, e.g., want to control lights with other apps) you should let it stay disabled.

@mihaifireball this doesn’t sound like a problem in the yeelight component but elsewhere…

if i use yeelight.py from @mxtra this feature works, but it lacks of other features like dynamically detects the status of online bulbs.

@teprrr thanks for your explanation… now it’s clear :-)… atm I’m on 0.38 dev0… can I test it? or need to be merged?

New component is working like a charm. Way faster and transitions are finally here.
The only problem i experience is saving the default state (as far as i cant tell from the logs… But frnakly speaking i couldn’t save a default state from Mi Home app as well (gave of an error in chinese). Wonder if this can be solved somehow

17-02-13 07:12:08 ERROR (Thread-7) [homeassistant.components.light.yeelight] Error when calling <function YeelightLight.set_default at 0x719ec5d0>: {'code': -5000, 'message': 'general error'}
17-02-13 07:12:32 ERROR (Thread-11) [homeassistant.components.light.yeelight] Error when calling <function YeelightLight.set_default at 0x719ec5d0>: {'code': -5000, 'message': 'general error'}
17-02-13 07:13:24 ERROR (Thread-8) [homeassistant.components.light.yeelight] Error when calling <function YeelightLight.set_default at 0x719ec5d0>: {'code': -5000, 'message': 'general error'}
17-02-13 07:14:29 ERROR (Thread-5) [homeassistant.components.light.yeelight] Error when calling <function YeelightLight.set_default at 0x719ec5d0>: {'code': -5000, 'message': 'general error'}
17-02-13 07:49:45 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal read error on socket transport

Is there any possible way to set static ip to the bulb if my router doesnt have an option in its website ? Or to implement auto discovery?

1 Like

This bulb http://www.gearbest.com/smart-lighting/pp_361555.html works with this component? It works with voltage 220V. Anyone test it with 230V?

Yes this bulb works. I use it at 230v in The Netherlands :wink:

1 Like

Hi there, I’m having some problem with my Yeelight. I’m using the normal component, no custom, but strangely the Yeelight disappear from everywhere! I can use it from MiHome application and Homebridge see that light as always. I installed another bulb (the third one) and Homeassistant misitcally found it without write the ip address in the condfiguration file. Thanks strage, can you please help me to understand how to debug for give you a change for investigate.

PS: I tryed to remove this light, the two that have disappeared, from group and from room… but nothing changed, I can ping and use it but in HA they are not visible. With my previous configuration, they were in a room that say unknown

please help me :slight_smile:

you have to enable the Developer Mode for all your bulbs in the Yeelight app.

Still have the following error with this action. Any ideas?

  action:
    service: light.toggle
    entity_id: light.bed_bra_l
    data_template:
      color_temp: "294"
      brightness: 100     


17-02-27 21:39:09 ERROR (MainThread) [homeassistant.core] Invalid service data for light.toggle: extra keys not allowed @ data['brightness']. Got '100'
extra keys not allowed @ data['color_temp']. Got '294'
17-02-27 21:39:11 ERROR (MainThread) [homeassistant.core] Invalid service data for light.toggle: extra keys not allowed @ data['brightness']. Got '100'
extra keys not allowed @ data['color_temp']. Got '294'
17-02-27 21:40:04 ERROR (Thread-7) [homeassistant.components.light.yeelight] Error when calling <function YeelightLight.set_default at 0x6e6e29c0>: {'code': -5000, 'message': 'general error'}

Obliviously yes. They magically disappear from all HA but still available in homebridge-yeelight

My log

Thanks!

Hi, just wanted to say that I feel like controlling my white Yeelights is more unstable after I updated to the official Yeelight component. Earlier with the custom component (discussed in this topic) switching and dimming etc worked quicker and more reliably than now. Now I frequently get “unavailable” status in HA panel and sometimes some bulbs don’t switch on/off or dont follow chosen scene. Even when “unavailable” status is shown I can still control lights using Yeelight or Home apps, without delays. Below is some logs related to this.

[details=logs]17-03-02 17:37:51 ERROR (Thread-10) [homeassistant.components.light.yeelight] Failed to connect to bulb 10.0.1.20, OH3: A socket error occurred when sending the command.
17-03-02 17:38:14 ERROR (Thread-8) [homeassistant.components.light.yeelight] Failed to connect to bulb 10.0.1.20, yeelight_white_f0b429a8ce02: A socket error occurred when sending the command.
17-03-02 17:39:16 WARNING (MainThread) [homeassistant.core] Unable to find service sensor/turn_on
17-03-02 17:39:21 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/home/homeassistant/.homeassistant/deps/yeelight/main.py”, line 271, in send_command
self._socket.send((json.dumps(command) + “\r\n”).encode(“utf8”))
OSError: [Errno 9] Bad file descriptor

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 “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/core.py”, line 1001, in _event_to_service_call
yield from service_handler.func(service_call)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/light/init.py”, line 249, in async_handle_light_service
yield from light.async_turn_on(**params)
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/lib/python3.4/site-packages/homeassistant/components/light/yeelight.py”, line 295, in turn_on
self._bulb.turn_on(duration=duration)
File “”, line 2, in turn_on
File “/home/homeassistant/.homeassistant/deps/yeelight/main.py”, line 50, in _command
result = self.send_command(method, params).get(“result”, [])
File “/home/homeassistant/.homeassistant/deps/yeelight/main.py”, line 275, in send_command
self.__socket.close()
AttributeError: ‘NoneType’ object has no attribute ‘close’
17-03-02 17:39:21 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/home/homeassistant/.homeassistant/deps/yeelight/main.py”, line 271, in send_command
self._socket.send((json.dumps(command) + “\r\n”).encode(“utf8”))
OSError: [Errno 9] Bad file descriptor

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 “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/core.py”, line 1001, in _event_to_service_call
yield from service_handler.func(service_call)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/light/init.py”, line 249, in async_handle_light_service
yield from light.async_turn_on(**params)
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/lib/python3.4/site-packages/homeassistant/components/light/yeelight.py”, line 295, in turn_on
self._bulb.turn_on(duration=duration)
File “”, line 2, in turn_on
File “/home/homeassistant/.homeassistant/deps/yeelight/main.py”, line 50, in _command
result = self.send_command(method, params).get(“result”, [])
File “/home/homeassistant/.homeassistant/deps/yeelight/main.py”, line 275, in send_command
self.__socket.close()
AttributeError: ‘NoneType’ object has no attribute ‘close’
17-03-02 17:39:21 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/home/homeassistant/.homeassistant/deps/yeelight/main.py”, line 271, in send_command
self._socket.send((json.dumps(command) + “\r\n”).encode(“utf8”))
OSError: [Errno 9] Bad file descriptor

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 “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/core.py”, line 1001, in _event_to_service_call
yield from service_handler.func(service_call)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/light/init.py”, line 249, in async_handle_light_service
yield from light.async_turn_on(**params)
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/lib/python3.4/site-packages/homeassistant/components/light/yeelight.py”, line 295, in turn_on
self._bulb.turn_on(duration=duration)
File “”, line 2, in turn_on
File “/home/homeassistant/.homeassistant/deps/yeelight/main.py”, line 50, in _command
result = self.send_command(method, params).get(“result”, [])
File “/home/homeassistant/.homeassistant/deps/yeelight/main.py”, line 275, in send_command
self.__socket.close()
AttributeError: ‘NoneType’ object has no attribute ‘close’
17-03-02 17:39:21 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/home/homeassistant/.homeassistant/deps/yeelight/main.py”, line 271, in send_command
self._socket.send((json.dumps(command) + “\r\n”).encode(“utf8”))
File “/home/homeassistant/.homeassistant/deps/yeelight/main.py”, line 171, in _socket
self.__socket.connect((self._ip, self._port))
socket.timeout: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/tasks.py”, line 233, in _step
result = coro.throw(exc)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/core.py”, line 1001, in _event_to_service_call
yield from service_handler.func(service_call)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/light/init.py”, line 249, in async_handle_light_service
yield from light.async_turn_on(**params)
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/lib/python3.4/site-packages/homeassistant/components/light/yeelight.py”, line 295, in turn_on
self._bulb.turn_on(duration=duration)
File “”, line 2, in turn_on
File “/home/homeassistant/.homeassistant/deps/yeelight/main.py”, line 50, in _command
result = self.send_command(method, params).get(“result”, [])
File “/home/homeassistant/.homeassistant/deps/yeelight/main.py”, line 277, in send_command
raise_from(BulbException(‘A socket error occurred when sending the command.’), ex)
File “/home/homeassistant/.homeassistant/deps/future/utils/init.py”, line 398, in raise_from
exec(execstr, myglobals, mylocals)
File “”, line 1, in
yeelight.main.BulbException: A socket error occurred when sending the command.
17-03-02 17:40:11 ERROR (Thread-11) [homeassistant.components.light.yeelight] Unable to update bulb status: Bulb closed the connection.
17-03-02 17:41:17 ERROR (Thread-7) [homeassistant.components.light.yeelight] Unable to update bulb status: Bulb closed the connection.
17-03-02 17:42:15 ERROR (Thread-5) [homeassistant.components.light.yeelight] Unable to update bulb status: Bulb closed the connection.
[/details]

I have the same problems since updating to 0.39.2

17-03-02 19:34:12 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/home/pi/.homeassistant/deps/yeelight/main.py”, line 271, in send_command
self._socket.send((json.dumps(command) + “\r\n”).encode(“utf8”))
File “/home/pi/.homeassistant/deps/yeelight/main.py”, line 171, in _socket
self.__socket.connect((self._ip, self._port))
OSError: [Errno 113] No route to host

The above exception was the direct cause of the following exception:

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/core.py”, line 1001, in _event_to_service_call
yield from service_handler.func(service_call)
File “/usr/local/lib/python3.4/dist-packages/homeassistant/components/light/init.py”, line 249, in async_handle_light_service
yield from light.async_turn_on(**params)
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/yeelight.py”, line 295, in turn_on
self._bulb.turn_on(duration=duration)
File “”, line 2, in turn_on
File “/home/pi/.homeassistant/deps/yeelight/main.py”, line 50, in _command
result = self.send_command(method, params).get(“result”, [])
File “/home/pi/.homeassistant/deps/yeelight/main.py”, line 277, in send_command
raise_from(BulbException(‘A socket error occurred when sending the command.’), ex)
File “/home/pi/.homeassistant/deps/future/utils/init.py”, line 398, in raise_from
exec(execstr, myglobals, mylocals)
File “”, line 1, in
yeelight.main.BulbException: A socket error occurred when sending the command.
17-03-02 19:34:27 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/home/pi/.homeassistant/deps/yeelight/main.py”, line 271, in send_command
self._socket.send((json.dumps(command) + “\r\n”).encode(“utf8”))
File “/home/pi/.homeassistant/deps/yeelight/main.py”, line 171, in _socket
self.__socket.connect((self._ip, self._port))
OSError: [Errno 113] No route to host

The above exception was the direct cause of the following exception:

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/core.py”, line 1001, in _event_to_service_call
yield from service_handler.func(service_call)
File “/usr/local/lib/python3.4/dist-packages/homeassistant/components/light/init.py”, line 251, in async_handle_light_service
yield from light.async_turn_off(**params)
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/yeelight.py”, line 313, in turn_off
self._bulb.turn_off()
File “”, line 2, in turn_off
File “/home/pi/.homeassistant/deps/yeelight/main.py”, line 50, in _command
result = self.send_command(method, params).get(“result”, [])
File “/home/pi/.homeassistant/deps/yeelight/main.py”, line 277, in send_command
raise_from(BulbException(‘A socket error occurred when sending the command.’), ex)
File “/home/pi/.homeassistant/deps/future/utils/init.py”, line 398, in raise_from
exec(execstr, myglobals, mylocals)
File “”, line 1, in
yeelight.main.BulbException: A socket error occurred when sending the command.

Solution:

One bulb was powered off via the wall switch… After repowering it, all the scenes are working again and the errors are gone…

Maybe someone who is able to understand the code is able to write a workaround to ensure that a single powered off bulb is not affecting the rest of the group when triggering scenes and group switches.

Thanks in advance

Thorben

@brthrsam There should be no such great difference but if you go and enable music mode, the connection will be kept alive and the commands will be handled faster as long as the bulb stays connected. The bulb gets marked as unavailable when homeassistant has not been able to get state from it when it tries to do an update.

edit: it may be so that the bulbs can be accessed only from one application at the same time, therefore if you are using the app (which uses the music mode per default), it may not answer to homeassistant. Just a guess though.