Yeelight lag time for state

Hi.
I use 4 groups of 2 yeelignt bulbs.
When I change the state of a group, the bulbs change state, but the indicator comes back a few seconds later, then changes again several seconds later.
So you have to wait 10 sec minimum between 2 change of state for it to work.

With the application Yeelight, the change is immediate, everything works perfectly, so the problem does not come from the wifi.

I tried with the parameters:
scan_interval:
use_music_mode:
I disabled the different trackers (bt, ping), but without success.

Would someone have a solution?
Thanks you

Just tested this 0.67.1. Turned on all my yeelights via the group toggle. They came on and stayed on. Then turned them off, they turned off and stayed off.

My config is plain and simple, no music mode or anything. I do have all the bulbs blocked from communicated with the home servers in china so no app access.
https://github.com/SilvrrGIT/HomeAssistant/blob/master/lights.yaml

What version of HA are you on and how do you have your yaml configured?

Do you have the app open/running at the same time you are doing testing in HA? This is known to cause issues.

One of my group is :

  • platform: yeelight
    devices:
    10.0.4.190:
    name: “Salon 1”
    use_music_mode: False #(defaults to False)
    save_on_change: False #(defaults to True)
    10.0.4.191:
    name: “Salon 2”
    use_music_mode: False #(defaults to False)
    save_on_change: False #(defaults to True)

I’m on 0.66.1, i will try to update now.
the app is only open for testing, blocking access to china don’t change anything.

Have you tried save_on_change: true?

I will.
I’m now on 0.68.1

Same problem on 0.68.1, save on change true or false…
Sometime only one of the two bulbs change state.
Sometime, the 2 states don’t change.
Sometime it work immediatly…

I don’t understand…

Any errors in your log?

2018-05-02 19:18:51 ERROR (Thread-22) [homeassistant.components.light.yeelight] Error when calling <function YeelightLight.set_default at 0x686dc3d8>: Bulb closed the connection.
2018-05-02 19:18:51 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall light.turn_on: entity_id=[‘light.salon_1’], color_temp=304, transition=30.0>
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/yeelight/main.py”, line 299, 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 “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py”, line 1002, in _event_to_service_call
await service_handler.func(service_call)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/light/init.py”, line 360, in async_handle_light_service
await light.async_turn_on(**params)
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/light/yeelight.py”, line 455, in turn_on
self._bulb.turn_on(duration=duration)
File “”, line 2, in turn_on
File “/srv/homeassistant/lib/python3.5/site-packages/yeelight/main.py”, line 58, in _command
result = self.send_command(method, params).get(“result”, [])
File “/srv/homeassistant/lib/python3.5/site-packages/yeelight/main.py”, line 302, in send_command
self.__socket.close()
AttributeError: ‘NoneType’ object has no attribute ‘close’
2018-05-02 19:18:51 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall light.turn_on: transition=50.0, brightness_pct=100.0, entity_id=[‘light.salon_1’, ‘light.salon_2’]>
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/yeelight/main.py”, line 299, 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 “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py”, line 1002, in _event_to_service_call
await service_handler.func(service_call)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/light/init.py”, line 360, in async_handle_light_service
await light.async_turn_on(**params)
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/light/yeelight.py”, line 455, in turn_on
self._bulb.turn_on(duration=duration)
File “”, line 2, in turn_on
File “/srv/homeassistant/lib/python3.5/site-packages/yeelight/main.py”, line 58, in _command
result = self.send_command(method, params).get(“result”, [])
File “/srv/homeassistant/lib/python3.5/site-packages/yeelight/main.py”, line 302, in send_command
self.__socket.close()
AttributeError: ‘NoneType’ object has no attribute ‘close’
2018-05-02 19:18:51 DEBUG (Thread-7) [yeelight.main] Bulb<10.0.4.191:55443, type=BulbType.Color> > {‘params’: [‘on’, ‘smooth’, 50000, 0], ‘method’: ‘set_power’, ‘id’: 177}
2018-05-02 19:18:52 DEBUG (Thread-7) [yeelight.main] Bulb<10.0.4.191:55443, type=BulbType.Color> < {‘id’: 177, ‘result’: [‘ok’]}
2018-05-02 19:18:52 DEBUG (Thread-7) [yeelight.main] Bulb<10.0.4.191:55443, type=BulbType.Color> > {‘params’: [100, ‘smooth’, 50000], ‘method’: ‘set_bright’, ‘id’: 178}
2018-05-02 19:18:52 DEBUG (Thread-7) [yeelight.main] Bulb<10.0.4.191:55443, type=BulbType.Color> < {‘id’: 178, ‘result’: [‘ok’]}
2018-05-02 19:18:52 DEBUG (Thread-7) [yeelight.main] Bulb<10.0.4.191:55443, type=BulbType.Color> > {‘params’: [], ‘method’: ‘set_default’, ‘id’: 179}
2018-05-02 19:18:52 DEBUG (Thread-7) [yeelight.main] Bulb<10.0.4.191:55443, type=BulbType.Color> < {‘id’: 179, ‘result’: [‘ok’]}
2018-05-02 19:18:52 DEBUG (Thread-17) [yeelight.main] Bulb<10.0.4.190:55443, type=BulbType.Color> > {‘params’: [‘power’, ‘bright’, ‘ct’, ‘rgb’, ‘hue’, ‘sat’, ‘color_mode’, ‘flowing’, ‘delayoff’, ‘music_on’, ‘name’], ‘method’: ‘get_prop’, ‘id’: 193}
2018-05-02 19:18:52 ERROR (Thread-2) [homeassistant.components.light.yeelight] Unable to turn the bulb off: Bulb closed the connection.
2018-05-02 19:18:52 DEBUG (Thread-13) [yeelight.main] Bulb<10.0.4.191:55443, type=BulbType.Color> > {‘params’: [‘off’, ‘smooth’, 350], ‘method’: ‘set_power’, ‘id’: 180}
2018-05-02 19:18:52 DEBUG (Thread-13) [yeelight.main] Bulb<10.0.4.191:55443, type=BulbType.Color> < {‘id’: 180, ‘result’: [‘ok’]}
2018-05-02 19:18:57 ERROR (MainThread) [homeassistant.helpers.entity] Update for light.salon_1 fails
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/yeelight/main.py”, line 299, 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 “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py”, line 204, in async_update_ha_state
yield from self.async_device_update()
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py”, line 327, in async_device_update
yield from self.hass.async_add_job(self.update)
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/light/yeelight.py”, line 305, in update
self._bulb.get_properties()
File “/srv/homeassistant/lib/python3.5/site-packages/yeelight/main.py”, line 256, in get_properties
response = self.send_command(“get_prop”, requested_properties)
File “/srv/homeassistant/lib/python3.5/site-packages/yeelight/main.py”, line 302, in send_command
self.__socket.close()
AttributeError: ‘NoneType’ object has no attribute ‘close’
2018-05-02 19:18:57 DEBUG (Thread-6) [yeelight.main] Bulb<10.0.4.191:55443, type=BulbType.Color> > {‘params’: [‘power’, ‘bright’, ‘ct’, ‘rgb’, ‘hue’, ‘sat’, ‘color_mode’, ‘flowing’, ‘delayoff’, ‘music_on’, ‘name’], ‘method’: ‘get_prop’, ‘id’: 181}
2018-05-02 19:18:57 DEBUG (Thread-6) [yeelight.main] Bulb<10.0.4.191:55443, type=BulbType.Color> < {‘params’: {‘power’: ‘off’}, ‘method’: ‘props’}
2018-05-02 19:18:57 DEBUG (Thread-6) [yeelight.main] Bulb<10.0.4.191:55443, type=BulbType.Color> < {‘id’: 181, ‘result’: [‘off’, ‘100’, ‘3289’, ‘16711680’, ‘359’, ‘100’, ‘2’, ‘0’, ‘0’, ‘0’, ‘’]}

Do you have a mobile phone with MiHome/Yeelight apps installed?

Yes I have, why?

Try to disinstall them! I noticed that my yeelights went to unavailable status if I had those app installed! (Even if I didn’t use them).
I suppose that the apps open a socket with the bulb and if HA arrives, it find the socket busy.
Give it a try!

Thanks you but the problem is the same… of I need to wait more time?

Sorry, I had similar problem when the apps were working.
To be honest I had errors like this:
ERROR (Thread-10) [homeassistant.components.light.yeelight] Unable to update bulb status: Bulb closed the connection

try to telnet to the bulb: telnet <ip_of_bulb> 55443 just to be sure that everything it’s ok!

Hi.
I’have desinstall Yeelight app Yesterday and reboot all, no changement.
I can telnet my bulb, but what to do after that?
I’m thinking about make a second instance of home assistant with only yeelight and see, what do you think?

Thanks you all.

Which server are you using?

My Yeelights are auto-detected in HA and I don’t see this issue. There is a delay if I use the Yeelight app to control - maybe a few seconds for HA to catch up. Or if I switch off at light switch they become unavailable and switch back on and I have them set to come on… in a few seconds they are back on WiFi and showing the correct state. Pretty trouble free. I use the Singapore server and both HA and Google Assistant support them natively without having to configure them (other than customise to set a friendly name)

I’m on a raspberry pi 3b, mi WiFi router is a Synology, so I think it’s good, and it’s perfect with yeelight app. Maybe a bug between 2 components?

With another Raspberry, and stock config, it’s working. I need to make more test…

yes there is no incompatibility/bug between components

It looks better without declaring the bulbs, just using the discovery, but it’s not perfect, and no way to force a state to power on (disable the last state) and if the bulb is offline at startup , forced to restart for it to appear …

I have not found that. If the Bulb is off at startup it just says unavailable on mine until I power it on. In the App you can force it to not remember the last state and if you do that it will power on when you switch it on.