Skip to content

"Bulb closed the connection" for yeelight screen bar light

Hi Stavros,

Thanks for your effort on this great python library for Yeelight bulbs.

I bought two Yeelight Screen Bar light for days and encounter issues when use python-yeelight to control it. The device model is YLTD001, maybe you have not fully test library on the new device yet.

code:

from yeelight import Bulb
screen_light = Bulb('10.1.234.107')
screen_light.toggle()

After ~5 secs, the device toggled but got this exception:

Traceback (most recent call last):
  File "python-yeelight/test.py", line 33, in <module>
    screen_light.toggle()
  File "<decorator-gen-9>", line 2, in toggle
  File "python-yeelight/yeelight/main.py", line 133, in _command
    result = self.send_command(method, params).get("result", [])
  File "python-yeelight/yeelight/main.py", line 553, in send_command
    raise BulbException(response["error"])
yeelight.main.BulbException: Bulb closed the connection.

After investgation, if I make an ~20ms sleep between main.py:L253:connect() and send_comment(), the issue disappeared.

So it is a firmware bug most likely I think.

I have reported this bug to Yeelight staff on theirs forum and will make update here once they fix it. If anyone who encounter the same problem, hope this thread can save your time.

Thanks,
Yulan

===
code to reproduce this issue

package main

import (
	"bufio"
	"fmt"
	"log"
	"net"
)

func main() {
	conn, err := net.Dial("tcp", "10.1.234.107:55443")
	if err != nil {
		log.Fatalln(err)
	}
	//time.Sleep(time.Millisecond * 5)  // uncommment this line to reproduce the connection issue
	_, _ = fmt.Fprint(conn, "{\"id\": 0, \"method\": \"toggle\", \"params\": [\"smooth\", 300]}\r\n")
	response, _ := bufio.NewReader(conn).ReadString('\n')
	log.Println("response = " + response)
}
Edited by Yulan Wei
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information