DIY Lights, different light types on one ESP

Hello, is it possible to use different types of lights(RGB, Dimmable, onoff) on one ESP8266 (i know it depends on diyHue)and if possible, how should the “detect” string must look like that diyHue can connect/find the lights?
What is the maximum number of “lights:” on one device?

I ask because now i use Arduino ESPAlexa-Library where each ESP-Device(ESP8266, ESP32) emulates a Hue-bridge with all combination of devices possible, for example my “couch-device” has 6 “lights” (onoff, RGB, dimmable, onoff, onoff, onoff), cabinet-device (2x RGB, 2x dimmable), distribution cabinet-device has 13 lights (3x dimmable, 10x on/off), … and if possible i want to switch over to a solution with openHAB/diyHue on a RasPi.

Thx in advance

If you are using the sketches in the DIYHue/Lights repository you don’t have to do any manual setup. DIYHue will search your network for lights when you search for lights in Hue Essentials.
You cannot control more than one light type from one ESP with the sketches that are pre-built in the Lights repository.
If you have a current solution that emulates a Hue bridge you shouldn’t need to use DIYHue. You should be able to add your existing device as a Hue bridge in Openhab, if it truly does emulate a Hue Bridge as DIYHue does. Can you locate your current devices in the Hue Essentials app and does it show up as a Hue bridge?

Hue Essentials is not really happy, the app displays 4 bridges of 11(=espalexa-devices) and when i will connect one,the app runs into an error, “bridge is not reachable”.

The Alexa Echos find (with “Alexa, search for new devices” command) all 30 lights/switches in the 11 ESP-devices and show them in the alexa app without an addional skill or hardware.
But the Alexa App has simple unflexible UI for smart home compared to Hue Essentials App or openHAB, so i search for another solution.

And so i look if diyHue can find in one physical MC different numbers of different light types or in other words, can the string send to the bridge after a “/detect” contain more than one type of light with its devicecount?

I think your solution is rather complicated.
Here is the diyhue approach.
RaspPi or any other device with diyhue Emulator running (Docker or Host install) will search for ESP8266 devices in your network. showing only one single Bridge with all Lights in it.

according to the sketch uploaded you will end up with multiple “Lights” within one esp8266.
e.g. 1x esp8266 + 20 ws2812 Leds = 4 individual lights with 5 Leds each → on the same Strip (configurable via web ui)

so far we dont incorporate mixed types on one single esp8266. i am sure this could be accomplished but since the devices are cheap it sometimes is just easier to setup another esp.

I suggest having a look over the docs:

1 Like

I was thinking the same thing. When you start getting into timing though, two long runs on a single board might be tough. I’m sure an ESP32 could do it but I agree, one type per one board. Why make it more difficult if you don’t have to.

I know diyHue is very close to Philips’ light concept, but if I use microcontrollers, I think can become more flexible and smarter.
Another example:
I have a home cinema screen in the living room, for years with two 433kHz radio switches with an infrared radio converter, canvas up/down and white background light on/off. This was controllable with a Logitech Harmony remote control (home theater).
Now this has been converted with an ESP32 (ESP8266 would also work), with ESP Alexa and IR library) with the following functions behind the screen:
• ESP32 with a small 5v power supply
• Infrared receiver
• RGB LED strip for background light (can be operated via Alexa)
• White LED strip for background light (can be operated via Alexa and infrared (Logitech Harmony))
• Canvas up and down (can be operated via Alexa and infrared (Logitech Harmony))
• 12V 8a power supply for LED strips
• Extra relay for switching the 12V power supply for the LED strips (first LED strip on switches on the power supply, the last off switches off), power supply only energized when required.
If I split these functions over two or three ESP8266s, the effort will explode.

I looked at the source code of the diyHue Generic Lights and found that large parts of the code are the same across different devices, so I had the idea to bring the entire Hue handling into a library analogous to ESPalexa-library. Here the principle/structure of the code from Canvas example (560 lines of code in the original), when you have a library this contains all the hue stuff and you only must handle all the I/O:

#include <WiFi.h> // or #include <ESP8266WiFi.h>
#include <Espalexa.h> 	// contains all the hue stuff
#include <IRremote.h>
Espalexa espalexa;
// ports/PWM, IR codes defines here
void canvas_Callback(uint8_t brightness)
  //porthandling stuff  canvas up down, called also when right IR code detected

void canvaslight_Callback(uint8_t brightness)			
 //PWM handling canvas white light, also 12v supply, called also when right IR code detected
void canvasRGBlight_Callback(uint8_t brightness, uint32_t rgb)	// LED-Strip RGB
 // PWM handling canvas RGB light, switching 12v supply here

void setup()
    // here init stuff, wifi connection, serial, init Ports PWM
    espalexa.addDevice("canvas", canvas_Callback, EspalexaDeviceType::onoff); //non-dimmable device
    espalexa.addDevice("canvaslight", canvaslight_Callback, EspalexaDeviceType::dimmable); //Dimmable device
    espalexa.addDevice("canvaslighttwo", canvasRGBlight_Callback, EspalexaDeviceType::color); //color device
    irrecv.enableIRIn(TRUE); // start IR-receiver   

void loop()
    // here is the IR code part
    delay(1);		// Only for ESP8266

I hope my train of thought has become a little clearer. If I also want to write or rewrite code for my own devices myself and not just take over finished code, every flexibility helps me to realize my own ideas.

And this was the reason I ask for the possibility diyHue can handle different light types in one device.

1 Like

DiYHue can but there is no sketch that supports that feature. If you wanted to develop one, you could. There’s nothing stopping you. DIYHue treats each light individually so there’s nothing that’s says light 1 and light 2 on a device have to have the same properties. But I wouldn’t want to deal with how complex a sketch that would have to be. Not when I could just buy a $5 board instead. But you’re more than welcome to write one.

Ok, I saw the detect string in the generic device sketches and had no idea how to describe different types of light. Before that, in the diyhue documentation, I skipped over the example of how to do it :grinning:. I think I’m getting on now. Thank you.