Another connection issue thread with lots of research and will to help and test!

@liufei can you please check that I’m part of testers?
my Mi id: 1595692303

is it possible to do ceiling19 too ? This is the big 960mm 49YL light

Hi…The yeelight colour bulbs are not automatically reconnecting to the wifi after the router gets reset… the bulbs have to be switched off and on again for them to be online.

My mi account ID - 5354206260 and the model of my lights are - yeelink.light.color3
I am using the Singapore server. Please suggest.

Hi could you add me to the whitelist?

Mi id: 6191275032

First feedback after 24h using the new firmware. The issues definitely have dramatically decreased, from like every 5 minutes to pretty much every 3-3.5h! So still not totally random, which makes it very suspicious… Looking just at my two bedside lamps, these are the logs HA sees over 24hours of using the new beta build (I installed it around 9am yesterday, so exactly now 24h ago):

2020-12-03 12:00:40 ERROR (SyncWorker_16) [homeassistant.components.yeelight] Unable to update device 192.168.178.35, [Bedroom] Bedside Lamp Kristina: A socket error occurred when sending the command.
2020-12-03 12:01:10 ERROR (SyncWorker_38) [homeassistant.components.yeelight] Unable to update device 192.168.178.34, [Bedroom] Bedside Lamp Andy: A socket error occurred when sending the command.

2020-12-03 15:21:10 ERROR (SyncWorker_17) [homeassistant.components.yeelight] Unable to update device 192.168.178.35, [Bedroom] Bedside Lamp Kristina: A socket error occurred when sending the command.
2020-12-03 15:21:40 ERROR (SyncWorker_35) [homeassistant.components.yeelight] Unable to update device 192.168.178.34, [Bedroom] Bedside Lamp Andy: A socket error occurred when sending the command.

2020-12-03 18:41:41 ERROR (SyncWorker_47) [homeassistant.components.yeelight] Unable to update device 192.168.178.35, [Bedroom] Bedside Lamp Kristina: A socket error occurred when sending the command.

2020-12-03 18:46:11 ERROR (SyncWorker_5) [homeassistant.components.yeelight] Unable to update device 192.168.178.34, [Bedroom] Bedside Lamp Andy: A socket error occurred when sending the command.

2020-12-03 22:02:43 ERROR (SyncWorker_28) [homeassistant.components.yeelight] Unable to update device 192.168.178.35, [Bedroom] Bedside Lamp Kristina: A socket error occurred when sending the command.

2020-12-03 22:06:43 ERROR (SyncWorker_18) [homeassistant.components.yeelight] Unable to update device 192.168.178.34, [Bedroom] Bedside Lamp Andy: A socket error occurred when sending the command.

2020-12-04 01:05:49 ERROR (SyncWorker_7) [homeassistant.components.yeelight] Unable to update device 192.168.178.35, [Bedroom] Bedside Lamp Kristina: Bulb closed the connection.
2020-12-04 01:05:49 ERROR (SyncWorker_33) [homeassistant.components.yeelight] Unable to update device 192.168.178.34, [Bedroom] Bedside Lamp Andy: Bulb closed the connection.

2020-12-04 01:52:44 ERROR (SyncWorker_25) [homeassistant.components.yeelight] Unable to update device 192.168.178.34, [Bedroom] Bedside Lamp Andy: A socket error occurred when sending the command.
2020-12-04 01:52:44 ERROR (SyncWorker_21) [homeassistant.components.yeelight] Unable to update device 192.168.178.35, [Bedroom] Bedside Lamp Kristina: A socket error occurred when sending the command.

2020-12-04 04:26:14 ERROR (SyncWorker_45) [homeassistant.components.yeelight] Unable to update device 192.168.178.34, [Bedroom] Bedside Lamp Andy: A socket error occurred when sending the command.
2020-12-04 04:26:44 ERROR (SyncWorker_13) [homeassistant.components.yeelight] Unable to update device 192.168.178.35, [Bedroom] Bedside Lamp Kristina: A socket error occurred when sending the command.

2020-12-04 07:47:15 ERROR (SyncWorker_47) [homeassistant.components.yeelight] Unable to update device 192.168.178.35, [Bedroom] Bedside Lamp Kristina: A socket error occurred when sending the command.
2020-12-04 07:47:15 ERROR (SyncWorker_17) [homeassistant.components.yeelight] Unable to update device 192.168.178.34, [Bedroom] Bedside Lamp Andy: A socket error occurred when sending the command.

The lamps have not been touched / used most of the day. Only usage times were at ~1:30am and again ~8am. Nor has power been cut at any time. Also Wi-Fi was available the whole time and they’re still very close to an access point (it’s literally behind the wall).
Again: The only command that HA sends at that time is “get_properties”!
And again: They still have internet blocked!

It would be very interesting to see, if you @tomb92 can still reproduce the “get_prop” issue using Telnet. I haven’t applied your suggested changes to the Yeelight HA component / Yeelight python lib yet, because I wanted to see if the fix itself solves all occurrences of this issue :slight_smile:

I will now also monitor the Pendant lamp (ceiling10) and my three ceiling lamps (2x ceiling15, 1x ceiling20). That’s a bit harder to actually track, as people tend to hit the wall switch which then gives false reports. I will note down every time a wall switch has been hit, so I can post clean results. I hope to have them by tomorrow!

Thanks again so far @liufei and Yeelight team!!

Hello,

Hello

There is one issue I’ve read about here on the forum. I applied the solution from this post to the Python library.

Basically this one is not an error. It’s just letting you know that the connection has been closed which is absolutely fine. I debugged this one. But Homeassisant doesn’t like Errors.

2020-12-04 01:05:49 ERROR (SyncWorker_7) [homeassistant.components.yeelight] Unable to update device 192.168.178.35, [Bedroom] Bedside Lamp Kristina: Bulb closed the connection.

So what I implemeneted was this:

def send_command(self, method, params=None):
    """
    Send a command to the bulb.

    :param str method:  The name of the method to send.
    :param list params: The list of parameters for the method.

    :raises BulbException: When the bulb indicates an error condition.
    :returns: The response from the bulb.
    """
    command = {"id": self._cmd_id, "method": method, "params": params}

    _LOGGER.debug("%s > %s", self, command)

    try:
        self._socket.send((json.dumps(command) + "\r\n").encode("utf8"))
        **time.sleep(0.05)**
        **self._socket.close();**
    except socket.error as ex:
        # Some error occurred, remove this socket in hopes that we can later
        # create a new one.
        self.__socket.close()
        self.__socket = None
        raise_from(BulbException("A socket error occurred when sending the command."), ex)

As you can see I implemented a little wait after a command is sent and then close it, which also increases reaction times dramatically. (it can be any command, get_prop, set_ etc.)

        **time.sleep(0.05)**
        **self._socket.close();**

Same here without timeout.

    while response is None:
        try:
            data = self._socket.recv(16 * 1024)
            **self._socket.close()**
        except socket.error:
            # An error occured, let's close and abort...
            self.__socket.close()
            self.__socket = None
            response = {"error": "Bulb closed the connection."}
            break

So for those error you are getting I can confirm that it is a problem on the library. But it is really a non-problem. The library is just not specifically made to work with Homeassistant.
So if I implement my own Python solution there are no issues with it.

best regards,
Thomas Barbut

True that the library could use some work in regards to error handling etc for home assistant :stuck_out_tongue:
But it’s also a problem with Yeelights stops responding to get_prop after a while (randomly) Though home assistant depends on availability with get_prop

Any progress for fixing the bug with get_prop for lamp model color4 ?

Thanks

Thanks again for pointing this out. However, only one out of eight “connection issues” are the “bulb closed the connection” error you’re mentioning and fixing with that patch. I was still lazy and didn’t check and apply your fix. I’m still thinking of somehow applying that fix to the HA plugin, but didn’t have time yet to think about it…

1 个赞

@ezcGman

That fix breaks more stuff than it fixes. Trust me.

    try:
        self._socket.send((json.dumps(command) + "\r\n").encode("utf8"))
        **time.sleep(0.05)**
        **self._socket.close();**

/\ Closing the socket and then the below happens later in the same method

data = self._socket.recv(16 * 1024)
            **self._socket.close()**

Trying to read from the socket which was just closed previously.

@liufei
Can I please be whitelisted for the beta firmware for color2?

UID: 6360133601
Server: Asia and Oceana (Singapore)

Thanks!

hi, @Dwaipayan, we will look into this issue. no fix yet.
@Skirmish, color2 irrelevant with the issues discussed in this thread. Please describe the issues with yout bulbs. Thanks.

@tancheesoo I have whitelisted your MI ID and you should be able to see 2.0.6_0031 very soon. There’s will be another version with fix of issue discussed in this thread. But I believe 0031 will perform much better than 0030.

====

About beta version of color4.
There’s a new 2.0.6_0031 queued to be released, which include some enhancement in network connectivity. Should be online within a week. Please wait and see if this helps with the issues you are seeing.
The beta version (likely 0032) including the new patch has to wait until 0031 is released.

done

Hi, please list which products are you using.

Hello Liufeu,

I have already received the 2.0.6_0031 update 2 weeks ago (27-11-2020). After some monitoring I can say that the bulbs are still going unavailable on Home Assistant. Though they are a little more responsive on the Yeelight app.

I’m looking forward for the beta version with the fix.
Again thank you all for the great research and support.

@liufei

So I’ve updated one of my models to the beta firmwares

ceiling20 2.0.6__0026
color4 2.0.6__0031
bslamp2 2.06__0040

It seems to have gotten worse for bslamp2. Responses all get timeouts (You can still send commands but you won’t ever get a response) Home assistant does get_props response to set bulb’s availability and initial status. Will update later on ceiling20 and color4

My models on older firmwares works fine.
ceiling20 2.06_0020
bslamp2 2.06_0030
I don’t have a another color4 to test

The easiest way to test it in your lab is to use

It uses the same library used in home assistant.

pip install yeecli or pip3 install yeecli

And then for example:

yee --ip=192.168.0.34 status
yee --ip=192.168.0.34 turn off
yee --ip=192.168.0.34 turn on

You will be able to turn bulbs on/off but you will get timeout on response.

Ceiling3, Ceiling4

Hey @liufei,

here now also my reports from the two YLXD42YL (ceiling15), the YLXD50YL (ceiling20) and the YLDL01YL (ceiling10), also again over 24h from 9am-9am.
They all look the same now like the two bedside lamps I already reported. So a few socket errors still every 3.5-4h:

One of the YLXD42YL / ceiling15:

2020-12-04 07:59:45 ERROR (SyncWorker_43) [homeassistant.components.yeelight] Unable to update device 192.168.178.27, [Office] Ceiling Light: A socket error occurred when sending the command.
2020-12-04 11:20:15 ERROR (SyncWorker_14) [homeassistant.components.yeelight] Unable to update device 192.168.178.27, [Office] Ceiling Light: A socket error occurred when sending the command.
2020-12-04 14:40:46 ERROR (SyncWorker_32) [homeassistant.components.yeelight] Unable to update device 192.168.178.27, [Office] Ceiling Light: A socket error occurred when sending the command.
2020-12-04 18:01:16 ERROR (SyncWorker_38) [homeassistant.components.yeelight] Unable to update device 192.168.178.27, [Office] Ceiling Light: A socket error occurred when sending the command.
2020-12-04 21:22:17 ERROR (SyncWorker_12) [homeassistant.components.yeelight] Unable to update device 192.168.178.27, [Office] Ceiling Light: A socket error occurred when sending the command.
2020-12-04 23:45:18 ERROR (SyncWorker_30) [homeassistant.components.yeelight] Unable to update device 192.168.178.27, [Office] Ceiling Light: Bulb closed the connection.
2020-12-05 03:05:48 ERROR (SyncWorker_43) [homeassistant.components.yeelight] Unable to update device 192.168.178.27, [Office] Ceiling Light: A socket error occurred when sending the command.
2020-12-05 06:26:19 ERROR (SyncWorker_20) [homeassistant.components.yeelight] Unable to update device 192.168.178.27, [Office] Ceiling Light: A socket error occurred when sending the command.

Please note, that the one “Bulb closed the connection.” was me hitting the light switch.

YLXD50YL / ceiling20:

2020-12-04 09:40:15 ERROR (SyncWorker_7) [homeassistant.components.yeelight] Unable to update device 192.168.178.24, [Living Room] Ceiling Light: A socket error occurred when sending the command.
2020-12-04 13:00:45 ERROR (SyncWorker_3) [homeassistant.components.yeelight] Unable to update device 192.168.178.24, [Living Room] Ceiling Light: A socket error occurred when sending the command.
2020-12-04 16:21:16 ERROR (SyncWorker_29) [homeassistant.components.yeelight] Unable to update device 192.168.178.24, [Living Room] Ceiling Light: A socket error occurred when sending the command.
2020-12-04 18:58:16 ERROR (SyncWorker_0) [homeassistant.components.yeelight] Unable to update device 192.168.178.24, [Living Room] Ceiling Light: Bulb closed the connection.
2020-12-04 19:41:47 ERROR (SyncWorker_7) [homeassistant.components.yeelight] Unable to update device 192.168.178.24, [Living Room] Ceiling Light: A socket error occurred when sending the command.
2020-12-04 23:02:17 ERROR (SyncWorker_49) [homeassistant.components.yeelight] Unable to update device 192.168.178.24, [Living Room] Ceiling Light: A socket error occurred when sending the command.
2020-12-05 02:22:48 ERROR (SyncWorker_18) [homeassistant.components.yeelight] Unable to update device 192.168.178.24, [Living Room] Ceiling Light: A socket error occurred when sending the command.
2020-12-05 05:43:18 ERROR (SyncWorker_17) [homeassistant.components.yeelight] Unable to update device 192.168.178.24, [Living Room] Ceiling Light: A socket error occurred when sending the command.
2020-12-05 09:03:49 ERROR (SyncWorker_45) [homeassistant.components.yeelight] Unable to update device 192.168.178.24, [Living Room] Ceiling Light: A socket error occurred when sending the command.

YLDL01YL / ceiling10:

2020-12-04 07:47:15 ERROR (SyncWorker_26) [homeassistant.components.yeelight] Unable to update device 192.168.178.60, [Dining  Room] Pendant Light: A socket error occurred when sending the command.
2020-12-04 11:07:45 ERROR (SyncWorker_42) [homeassistant.components.yeelight] Unable to update device 192.168.178.60, [Dining  Room] Pendant Light: A socket error occurred when sending the command.
2020-12-04 11:32:20 ERROR (SyncWorker_25) [homeassistant.components.yeelight] Unable to update device 192.168.178.60, [Dining  Room] Pendant Light: Bulb closed the connection.
2020-12-04 11:35:50 ERROR (SyncWorker_40) [homeassistant.components.yeelight] Unable to update device 192.168.178.60, [Dining  Room] Pendant Light: Bulb closed the connection.
2020-12-04 12:03:15 ERROR (SyncWorker_48) [homeassistant.components.yeelight] Unable to update device 192.168.178.60, [Dining  Room] Pendant Light: A socket error occurred when sending the command.
2020-12-04 12:35:45 ERROR (SyncWorker_23) [homeassistant.components.yeelight] Unable to update device 192.168.178.60, [Dining  Room] Pendant Light: Bulb closed the connection.
2020-12-04 15:56:46 ERROR (SyncWorker_12) [homeassistant.components.yeelight] Unable to update device 192.168.178.60, [Dining  Room] Pendant Light: A socket error occurred when sending the command.
2020-12-04 18:42:51 ERROR (SyncWorker_24) [homeassistant.components.yeelight] Unable to update device 192.168.178.60, [Dining  Room] Pendant Light: Bulb closed the connection.
2020-12-04 22:04:47 ERROR (SyncWorker_23) [homeassistant.components.yeelight] Unable to update device 192.168.178.60, [Dining  Room] Pendant Light: A socket error occurred when sending the command.
2020-12-05 01:25:18 ERROR (SyncWorker_49) [homeassistant.components.yeelight] Unable to update device 192.168.178.60, [Dining  Room] Pendant Light: A socket error occurred when sending the command.
2020-12-05 04:45:48 ERROR (SyncWorker_34) [homeassistant.components.yeelight] Unable to update device 192.168.178.60, [Dining  Room] Pendant Light: A socket error occurred when sending the command.
2020-12-05 08:06:19 ERROR (SyncWorker_20) [homeassistant.components.yeelight] Unable to update device 192.168.178.60, [Dining  Room] Pendant Light: A socket error occurred when sending the command.

So I’m still curious about these errors every 3.5-4h, which still smell a bit. I’m now doing a test again with allowing internet again with the beta and see if these also happen every-3.5.4h.

Hope this is somehow helpful!

Also: Is the fix for the issue of the color2 bulbs getting completely unresponsive also on the way?

Greetings,

Andy!

@liufei
I did some more testing as well. All models with the new beta firmware stops responding to even telnet requests. You can use telnet to turn it off/on but you won’t get any response.

So this is not a home assistant issue.

Easily to test just by doing a few requests ,with telnet

Not trying! Actually doing it. Check documentation socket() and documentation on Yeelight. You will see the library does not work as per documentation in this case