mariusmotea / diyHue

Philips Hue emulator that is able to control multiple types of lights
Other
627 stars 107 forks source link

Hue Disco or similar Apps with Yeelight #444

Closed qontrixz closed 5 years ago

qontrixz commented 5 years ago

Hello there.

There is a problem with apps like Hue Disco and yeelights:

If i start e.g. hue disco for my yeelights it all works fine, but just for a moment. And after researching a bit i discovered this in the official yeelight documentation:

NOTE: Currently WiFi smart device support up to 4 simultaneous TCP connections, any further connect attempt will be rejected. For each connection, there is a command message quota, that is 60 commands per minute. There is also a total quota for all the LAN commands: 144 commands per minute 4 × 60 × 60%.

The yeelights have a special music mode, also discribed in the documentation:

Method: set_music Usage: This method is used to start or stop music mode on a device. Under music mode, no property will be reported and no message quota is checked. Parameters: 1 ~ 3. "action" the action of set_music command. The valid value can be: 0: turn off music mode. 1: turn on music mode. "host" the IP address of the music server. "port" the TCP port music application is listening on. Request Example: {"id":1,"method":"set_music","params":[1, “192.168.0.2", 54321]} {"id":1,"method":"set_music","params":[0]} Response Example: {"id":1, "result":["ok"]} NOTE: When control device wants to start music mode, it needs start a TCP server firstly and then call “set_music” command to let the device know the IP and Port of the TCP listen socket. After received the command, LED device will try to connect the specified peer address. If the TCP connection can be established successfully, then control device could send all supported commands through this channel without limit to simulate any music effect. The control device can stop music mode by explicitly send a stop command or just by closing the socket.

But i am a total noob in python and json and have no idea how get a workaround. :(

A simple manual toggle in die diyhue webapp would be enough for me

mariusmotea commented 5 years ago

I can lower the number of requests / second to avoid yeelight to hang, but the implementation of music mode in yeelight is very unfrendly it ask to create new tcp sockets for every bulb witch is not that easy. I can also try to buid pcb for conversion of the yeelight to esp8266 that don't have this limitation.

qontrixz commented 5 years ago

My noob workaround was to start musicmode via the original yeelight app, and then open hue disco simultaously in the background and open yeelight again.

Then it worked like a charm for 14 bulbs. The only downside was, that huedisco and yeelight commands mixed up, and the result was not like on original hue disco only... And if hue disco told the bulb "0 brightness (off)" music mode stopped for that specific bulb, and i hab to press play in the yeelight app again

qontrixz commented 5 years ago

inl just found this python library. does this help?https://yeelight.readthedocs.io/en/stable/yeelight.html#yeelight.Bulb.start_music

mariusmotea commented 5 years ago

Don't help, because is easy to enable music mode, is hard to use it.

ghost commented 5 years ago

Closing as won't fix