sblantipodi / firefly_luciferin

Very fast Java screen capture PC software designed for the Glow Worm Luciferin firmware, the combination of these software create the perfect Bias Lighting and Ambient Light system for PC.
GNU General Public License v3.0
331 stars 30 forks source link

Publish realtime RGB colors over MQTT #9

Closed mikosoft83 closed 4 years ago

mikosoft83 commented 4 years ago

Since you already have MQTT support would it be possible to add realtime RGB data to MQTT so that the PC and the ESP don't need to be connected over serial? I have a HTPC with a projector on the other side of the room where my screen sits so that would greatly benefit my setup.

sblantipodi commented 4 years ago

@mikosoft83 thank you for opening this issue and for the kind feedback. I can't tell you when I will implement this feature but I will do it in the next near future for sure. Thanks.

sblantipodi commented 4 years ago

@mikosoft83 just released a new version with full MQTT support. closing the issue, hope you'll enjoy it :)

mikosoft83 commented 4 years ago

@sblantipodi Already downloaded and testing the MQTT stream, I plan to integrate it to home assistant to control a bunch of RGB LED stuff. Thanks a lot for such a quick update!

sblantipodi commented 4 years ago

@mikosoft83 no problem, thank you for your suggestion. future release will let you control multiple led strip with separate channels on separate ESP devices, it will be useful for big home cinema.
if you want to share a video of your setup once finished, it will be appreciated. thanks!

sblantipodi commented 4 years ago

PS: If you want to integrate Luciferin with Home Assistant there is a ready to use package for the purpose, if you don't want to create your own.
https://github.com/sblantipodi/firefly_luciferin/wiki/Home-Automation-configs

mikosoft83 commented 4 years ago

@sblantipodi Thanks for the tip, I've seen that. What I want to do though is to actually convert the RGB stream to be usable in Shelly RGBW. I already have some LED lights, I just want to convert them to smart so they can be controlled via HA and work similarly to Ambilight for Hue.

sblantipodi commented 4 years ago

Hi @mikosoft83, it should be very easy to implement now that MQTT pipeline is ready but I don't think that the Shelly RGBW is powerfull enough to sustain an MQTT stream like this.
It's not a problem of horse power but a problem of how they manage the MQTT input.

If you read the Shelly documentation they "waste" an entire MQTT message for just brightness and a single color state. It's ok for their implementation but not really good for an "ambilight" purpose.

Suppose that you have 100 LEDs, with the current Luciferin implementation, Firefly Luciferin sends 1 message to the Glow Worm Luciferin firmware containing the information of 100 LEDs, in 1 seconds, Luciferin sends 30 message.

With the shelly implementation, if you have 100 LEDs, Luciferin should send 100 message for just 1 frame just to light up all the LEDs.
A good framerate is 30FPS, you can understand that this implementation will require (100 LEDs x 30FPS) 3000 MQTT messages for just 1 second.

but there is another problem...
Shelly does not let you turn on red 1 led and green another led. If you turn on green the strip, all the strip will be green, so how can you create an ambilight effect with that thing?

An ESP8266 costs 3 dollars, you could try it :)

mikosoft83 commented 4 years ago

@sblantipodi Actually, I want to use Shelly RGBW, which accepts payloads like this:

shellies/shellyrgbw2-<deviceid>/color/0/set accepts a JSON payload described below:
{
    "mode": "color",    /* "color" */
    "red": 0,           /* red brightness, 0..255 */
    "green": 0,         /* green brightness, 0..255 */
    "blue": 255,        /* blue brightness, 0..255 */
    "gain": 100,        /* gain for all channels, 0..100 */
    "white": 0,         /* white brightness, 0..255 */
    "effect": 0,        /* applies an effect when set */
    "turn": "on"        /* "on", "off" or "toggle" */
}

I have four DYI lamps that have (non addressable) RGB strips in them. Two of them are around my projector screen so I would hook up each lamp to one Shelly and use one pixel value from Firefly for each. So that means converting your stream message to two Shelly messages. Not that bad :)

Shellies also have the added value that they offer direct HA support so wife approval factor rises up :D

But if you think I could do this with ESP I could take a shot, but I have never worked with one so it'll be a steeper learning curve.

sblantipodi commented 4 years ago

@mikosoft83 firefly have a ready to use package that can be easily integrated in home assistant. There is a wiki here on how to do it.
https://github.com/sblantipodi/firefly_luciferin/wiki/Home-Automation-configs

I don't think that Luciferin is the best software to be used with Shelly devices. Luciferin is made to work with addressable led strip. If you have 100 LEDs, it capture the colours of 100 zones and send 100 different colours to the led strip.

There are thousands of guides on how to connect a led strip (ws2812B is recommended) to an ESP8266 D1 mini, learning curve it's really not that hard.

If you need help installing Luciferin on the ESP and connecting the led strip, don't hesitate to open an issue, I will try to help you out.