core: Yeelight Color bulbs FW 2.0.6_0051 become "unavailable" in HA

Home Assistant release with the issue:

arch x86_64 dev false docker false hassio false os_name Linux python_version 3.6.7 timezone Europe/Lisbon version 0.97.2 virtualenv true

Last working Home Assistant release (if known): 0.97.2

Operating environment (Hass.io/Docker/Windows/etc.):

Component/platform:

yeelight

Description of problem: After upgrading the firmware of my two Yeelight Color bulbs to version 2.0.6_0051, HA is showing a notification about 2 new Homekit devices. I have ignored the notification and didn’t setup the integration, but now these bulbs are “unavailable” in HA, although they can be accessed and controlled from Mi Home and Yeelight applications.

Upon restart, sometimes (not always!) HA shows the bulbs during a few minutes, but then they become “unavailable”. Power cycling the bulbs always bring them back in HA, but after some time (sometimes minutes, sometimes a few hours) they become “unavailable” again. Seems that something changed in this new firmware that is causing problems in HA’s Yeelight component. I have other Yeelight lamps (different model) that are working fine.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

yeelight:
  devices:
    192.168.110.111:
      name: Bedroom 3 Right Lamp
      model: color2
    192.168.110.125:
      name: Bedroom 3 Left Lamp
      model: color2

Traceback (if applicable):

2019-08-22 13:43:40 ERROR (SyncWorker_6) [homeassistant.components.yeelight] Unable to update device 192.168.110.125, Bedroom 3 Left Lamp: Bulb closed the connection.
2019-08-22 14:00:15 ERROR (SyncWorker_3) [homeassistant.components.yeelight] Unable to update device 192.168.110.125, Bedroom 3 Left Lamp: Bulb closed the connection.
2019-08-22 14:28:20 ERROR (SyncWorker_2) [homeassistant.components.yeelight] Unable to turn the bulb off: 192.168.110.111, Bedroom 3 Right Lamp: Bulb closed the connection.

2019-08-22 14:28:25 ERROR (SyncWorker_2) [homeassistant.components.yeelight] Unable to update device 192.168.110.111, Bedroom 3 Right Lamp: Bulb closed the connection.
2019-08-22 14:28:28 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140258754912552] 'NoneType' object has no attribute 'close'
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/yeelight/main.py", line 410, in send_command
    data = self._socket.recv(16 * 1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/websocket_api/commands.py", line 128, in handle_call_service
    connection.context(msg),
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 1235, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 1260, in _execute_service
    await handler.func(service_call)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 210, in handle_service
    self._platforms.values(), func, call, service_name, required_features
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 334, in entity_service_call
    future.result()  # pop exception if have
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 356, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/yeelight/light.py", line 598, in turn_off
    self.device.turn_off(duration=duration, light_type=self.light_type)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/yeelight/__init__.py", line 269, in turn_off
    self.bulb.turn_off(duration=duration, light_type=light_type)
  File "<decorator-gen-8>", line 2, in turn_off
  File "/srv/homeassistant/lib/python3.6/site-packages/yeelight/main.py", line 114, in _command
    result = self.send_command(method, params).get("result", [])
  File "/srv/homeassistant/lib/python3.6/site-packages/yeelight/main.py", line 413, in send_command
    self.__socket.close()
AttributeError: 'NoneType' object has no attribute 'close'
2019-08-22 14:28:30 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/yeelight/main.py", line 410, in send_command
    data = self._socket.recv(16 * 1024)
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/yeelight/__init__.py", line 151, in update
    device.update()
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/yeelight/__init__.py", line 300, in update
    self._update_properties()
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/yeelight/__init__.py", line 281, in _update_properties
    self.bulb.get_properties(UPDATE_REQUEST_PROPERTIES)
  File "/srv/homeassistant/lib/python3.6/site-packages/yeelight/main.py", line 359, in get_properties
    response = self.send_command("get_prop", requested_properties)
  File "/srv/homeassistant/lib/python3.6/site-packages/yeelight/main.py", line 413, in send_command
    self.__socket.close()
AttributeError: 'NoneType' object has no attribute 'close'

2019-08-22 14:29:06 ERROR (SyncWorker_7) [homeassistant.components.yeelight] Unable to update device 192.168.110.125, Bedroom 3 Left Lamp: Bulb closed the connection.

Additional information: Port 55443 is open:

Starting Nmap 7.60 ( https://nmap.org ) at 2019-08-24 14:49 WEST
Nmap scan report for 192.168.110.125
Host is up (-0.083s latency).

PORT      STATE SERVICE
55443/tcp open  unknown
MAC Address: 7C:49:EB:B3:xx:xx (Unknown)

Using yeecli to control the bulbs (turn on/turn off) apparently fail with the errors shown below. However, despite the errors, commands are executed correctly and the bulb is turned on and then off.

pmcouto@pmcesph1:~$ yee --ip=192.168.110.125 turn on
Turning the bulb on...
Traceback (most recent call last):
  File "/home/pmcouto/.local/bin/yee", line 11, in <module>
    sys.exit(cli())
  File "/home/pmcouto/.local/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/pmcouto/.local/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/pmcouto/.local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/pmcouto/.local/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/pmcouto/.local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/pmcouto/.local/lib/python2.7/site-packages/yeecli/cli.py", line 160, in turn
    bulb.turn_on()
  File "<decorator-gen-7>", line 2, in turn_on
  File "/home/pmcouto/.local/lib/python2.7/site-packages/yeelight/main.py", line 114, in _command
    result = self.send_command(method, params).get("result", [])
  File "/home/pmcouto/.local/lib/python2.7/site-packages/yeelight/main.py", line 441, in send_command
    raise BulbException(response["error"])
yeelight.main.BulbException: Bulb closed the connection.

--------------------------------------------------------------------------------------------------

pmcouto@pmcesph1:~$ yee --ip=192.168.110.125 turn off
Turning the bulb off...
Traceback (most recent call last):
  File "/home/pmcouto/.local/bin/yee", line 11, in <module>
    sys.exit(cli())
  File "/home/pmcouto/.local/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/pmcouto/.local/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/pmcouto/.local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/pmcouto/.local/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/pmcouto/.local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/pmcouto/.local/lib/python2.7/site-packages/yeecli/cli.py", line 162, in turn
    bulb.turn_off()
  File "<decorator-gen-8>", line 2, in turn_off
  File "/home/pmcouto/.local/lib/python2.7/site-packages/yeelight/main.py", line 114, in _command
    result = self.send_command(method, params).get("result", [])
  File "/home/pmcouto/.local/lib/python2.7/site-packages/yeelight/main.py", line 441, in send_command
    raise BulbException(response["error"])
yeelight.main.BulbException: Bulb closed the connection.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 54 (14 by maintainers)

Most upvoted comments

I’m from Yeelight and we are investigating the issue, sorry for the late response.

I have the same issue using the Yeelight 1S YLDP13YL on 2.0.6_0030. As a temporary workaround, I’m using the HomeKit Controller integration to add the bulbs to HA. The bulbs have been working flawlessly using this, however you do lose some features such having only the colour wheel, and not whites to pick from.

I’m not famliliar with HA and from all the comments I believe HA uses python-yeelight internally to communicate with Yeelight bulb, so I installed python-yeelight and tested with the latest firmware. However, I didn’t see any issue, or at least turn on, turn off and toggle works well.

I also installed the latest HA in my VirtualBox but struggling with the debugging method, any help would be appreciated.

image

>>> from yeelight import Bulb
>>> bulb = Bulb("192.168.1.12")
>>> bulb.toggle()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<decorator-gen-9>", line 2, in toggle
  File "/usr/local/lib/python3.7/dist-packages/yeelight/main.py", line 126, in _command
    result = self.send_command(method, params).get("result", [])
  File "/usr/local/lib/python3.7/dist-packages/yeelight/main.py", line 545, in send_command
    raise BulbException(response["error"])
yeelight.main.BulbException: Bulb closed the connection.
>>> bulb.toggle()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<decorator-gen-9>", line 2, in toggle
  File "/usr/local/lib/python3.7/dist-packages/yeelight/main.py", line 126, in _command
    result = self.send_command(method, params).get("result", [])
  File "/usr/local/lib/python3.7/dist-packages/yeelight/main.py", line 545, in send_command
    raise BulbException(response["error"])
yeelight.main.BulbException: Bulb closed the connection.
>>> bulb = Bulb("192.168.1.13")
>>> bulb.toggle()
'ok'
>>> bulb.toggle()
'ok'

Hi. I am using same exact commands and this is what I get. The bulb that closes the connection (192.168.1.12) is brand new firmware for Yeelight 1S that just came out yesterday 2.06_0030. USA region. The toggle works and turns on/off the bulb, but HA shows it as unavailable because not getting an ‘ok’ response? Exactly like OP’s problem back in August of last year… D:

Issuing identical commands to second bulb (192.168.1.13) works like a charm and responds to commands. This firmware is original factory firmware: 1.3.2_0018

Any chance of an update from Yeelight, @vvpossible? Please? I look over at Yeelight forums and many people are experiencing these connection issues over a year later.

@rytilahti I’ve been debugging with weiwei today and I’m testing a new firmware overnight. Looks promising so far.

The last update from weiwei is that it is a problem in Home Assistant and has been reported with no response yet from the hass community:

quote from weiwei’s post: Currently there are two issues here:

HA has trouble discovering bulbs with new firmware. HA occasionally shows disconnect/unavailable for bulbs. Regarding the first issue, it should be caused by HA’s discovery mechanism since new firmware didn’t change anything related to discovery and we believe HA didn’t handle devices that support Homekit as well as LAN control properly. This issue has been reported to HA community and so far no response yet. https://github.com/home-assistant/home-assistant/issues/26574

There hasn’t been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Yeelight 1s color. After update Firmware 2.0.6_0030 I can use homekit controller with lag, also lag present with yeelight app. for turn on/off lamp. Integration with yeelight plugin in HA worked 5-20 minutes after add lamp in system, and after is unavailable status. But, with factory firmware worked fine.

Reposting my comments from yeelight forum

Using the python yeelight library ( https://yeelight.readthedocs.io/en/latest/ ) I have no issues discovering the devices and no issues in connecting the bulbs running new firmware using telnet and sending commands. This shows the discovery function of the bulb works and bulbs are responding to commands using telnet. It seems hass is unable to handle the bulbs with multiple discovery protocols as Weiwei’s post suggested.

The output of discovery and telnet below.(192.168.0.55 is old version 1 color bulb, rest are all v2 color bulbs with the latest firmware)

output of discovery and telnet
Python 2.7.16 (default, Jul  9 2019, 16:43:02) 
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from yeelight import discover_bulbs
>>> bulbs = discover_bulbs()
>>> for i in bulbs:
...      print(i["ip"], i["port"])
... 
(u'192.168.0.55', 55443)
(u'192.168.0.218', 55443)
(u'192.168.0.56', 55443)
(u'192.168.0.244', 55443)
(u'192.168.0.57', 55443)
(u'192.168.0.58', 55443)
(u'192.168.0.212', 55443)
(u'192.168.0.215', 55443)
>>> 
user@server~$ telnet 192.168.0.55 55443
Trying 192.168.0.55...
Connected to 192.168.0.55.
Escape character is '^]'.
{"id":1,"method":"get_prop","params":["power", "name", "bright"]}
{"id":1, "result":["on","","1"]}
^]q

telnet> q
Connection closed.
user@server~$ telnet 192.168.0.218 55443
Trying 192.168.0.218...
Connected to 192.168.0.218.
Escape character is '^]'.
{"id":1,"method":"get_prop","params":["power", "name", "bright"]}
{"id":1,"result":["off","","100"]}
^Q]
{"id":0, "error":{"code":-1, "message":"invalid command"}}
^]q

telnet> q
Connection closed.
user@server~$ telnet 192.168.0.56 55443
Trying 192.168.0.56...
Connected to 192.168.0.56.
Escape character is '^]'.
{"id":1,"method":"get_prop","params":["power", "name", "bright"]}
{"id":1,"result":["off","","100"]}
^]q

telnet> q
Connection closed.
user@server~$ telnet 192.168.0.244 55443
Trying 192.168.0.244...
Connected to 192.168.0.244.
Escape character is '^]'.
{"id":1,"method":"get_prop","params":["power", "name", "bright"]}
{"id":1,"result":["off","","100"]}
^]q
</details>
telnet> q
Connection closed.
user@server~$ telnet 192.168.0.215 55443
Trying 192.168.0.215...
Connected to 192.168.0.215.
Escape character is '^]'.
{"id":1,"method":"get_prop","params":["power", "name", "bright"]}
{"id":1,"result":["off","","21"]}
^]q

telnet> q
Connection closed.```