MQTT, LED, NodeMCU Issue

So I am stuck on this one. I have some led lights that I am trying to get to work. I have two strips that are connected to a NodeMCU (one on pin 5 and one on pin 6) I want to be able to control them separately. I am trying to control them using MQTT. I used BRUH Automation’s code for the most part and it works if I don’t seperate them out to two pins. I have since added a second set of topics and modified my code to include a second pin. I have tried lots of things and now have gone back to removing most of the code to see if I could find the problem. What I came across is that if I include the following code in my arduino then I can no longer turn the leds on or off for either pin:

client.subscribe(setcolorsub2);

I comment this out it seems to work.

Here is the rest of my code if that helps. I am just stuck and probably missing something simple.

#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include "FastLED.h"

/************ WIFI and MQTT INFORMATION (CHANGE THESE FOR YOUR SETUP) ******************/
#define wifi_ssid "Omit" //enter your WIFI SSID
#define wifi_password "Omit" //enter your WIFI Password

#define mqtt_server "Omit" // Enter your MQTT server adderss or IP. I use my DuckDNS adddress (yourname.duckdns.org) in this field
#define mqtt_user "Omit" //enter your MQTT username
#define mqtt_password "Omit" //enter your password

/************ FastLED Defintions ******************/

#define DATA_PIN    6 //on the NodeMCU 1.0, FastLED will default to the D5 pin after throwing an error during compiling. Leave as is. 
#define LED_TYPE    WS2811 //change to match your LED type
#define COLOR_ORDER BRG //change to match your LED configuration
#define NUM_LEDS    51 //change to match your setup

#define DATA_PIN2    5 //on the NodeMCU 1.0, FastLED will default to the D5 pin after throwing an error during compiling. Leave as is. 
//#define LED_TYPE    WS2811 //change to match your LED type
//#define COLOR_ORDER BRG //change to match your LED configuration
#define NUM_LEDS2    52 //change to match your setup

/****************************** MQTT TOPICS (change these topics as you wish)  ***************************************/

#define colorstatuspub "home/livingroom/tvleds/colorstatus"
#define setcolorsub "home/livingroom/tvleds/setcolor"
#define setpowersub "home/livingroom/tvleds/setpower"
#define seteffectsub "home/livingroom/tvleds/seteffect"
#define setbrightness "home/livingroom/tvleds/setbrightness"

#define setcolorpub "home/livingroom/tvleds/setcolorpub"
#define setpowerpub "home/livingroom/tvleds/setpowerpub"
#define seteffectpub "home/livingroom/tvleds/seteffectpub"
#define setbrightnesspub "home/livingroom/tvleds/setbrightnesspub"
#define setanimationspeed "home/livingroom/tvleds/setanimationspeed"

#define colorstatuspub2 "home/livingroom/cabinetleds/colorstatus"
#define setcolorsub2 "home/livingroom/cabinetleds/setcolor"
#define setpowersub2 "home/livingroom/cabinetleds/setpower"
#define seteffectsub2 "home/livingroom/cabinetleds/seteffect"
#define setbrightness2 "home/livingroom/cabinetleds/setbrightness"
//
#define setcolorpub2 "home/livingroom/cabinetleds/setcolorpub"
#define setpowerpub2 "home/livingroom/cabinetleds/setpowerpub"
#define seteffectpub2 "home/livingroom/cabinetleds/seteffectpub"
#define setbrightnesspub2 "home/livingroom/cabinetleds/setbrightnesspub"
#define setanimationspeed2 "home/livingroom/cabinetleds/setanimationspeed"

/*************************** EFFECT CONTROL VARIABLES AND INITIALIZATIONS ************************************/

#if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)
#warning "Requires FastLED 3.1 or later; check github for latest code."
#endif

String setColor ="0,0,150";
String setPower;
String setEffect = "Solid";
String setBrightness = "150";
int brightness = 150;
String setAnimationSpeed;
int animationspeed = 240;
String setColorTemp;
int Rcolor = 0;
int Gcolor = 0;
int Bcolor = 0;
CRGB leds[NUM_LEDS];

String setColor2 ="0,0,150";
String setPower2;
String setEffect2 = "Solid";
String setBrightness2 = "150";
int brightness2 = 150;
String setAnimationSpeed2;
int animationspeed2 = 240;
String setColorTemp2;
int Rcolor2 = 0;
int Gcolor2 = 0;
int Bcolor2 = 0;
CRGB leds2[NUM_LEDS2];

char message_buff[100];

WiFiClient espClient;
PubSubClient client(espClient);

void setup() {
  Serial.begin(115200);

  FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
//  FastLED.addLeds<LED_TYPE, 5, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.addLeds<LED_TYPE, DATA_PIN2, COLOR_ORDER>(leds2, NUM_LEDS2).setCorrection(TypicalLEDStrip);
  FastLED.setMaxPowerInVoltsAndMilliamps(12, 10000); //experimental for power management. Feel free to try in your own setup.
  FastLED.setBrightness(brightness);
  FastLED.setBrightness(brightness2);

  fill_solid(leds, NUM_LEDS, CRGB(255, 0, 0)); //Startup LED Lights
  fill_solid(leds2, NUM_LEDS2, CRGB(255, 0, 0)); //Startup LED Lights
  FastLED.show();
  
  setup_wifi();

  client.setServer(mqtt_server, 1883); //CHANGE PORT HERE IF NEEDED
  client.setCallback(callback);
}

void setup_wifi() {

  delay(10);
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(wifi_ssid);

  WiFi.begin(wifi_ssid, wifi_password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void callback(char* topic, byte* payload, unsigned int length) {
  int i = 0;

  if (String(topic) == setpowersub) {
    for (i = 0; i < length; i++) {
      message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
    setPower = String(message_buff);
    Serial.println("Set Power: " + setPower);
    if (setPower == "OFF") {
      client.publish(setpowerpub, "OFF");
    }

    if (setPower == "ON") {
      client.publish(setpowerpub, "ON");
    }
  }

  if (String(topic) == setpowersub2) {
    for (i = 0; i < length; i++) {
      message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
    setPower2 = String(message_buff);
    Serial.println("Set Power: " + setPower2);
    if (setPower2 == "OFF") {
      client.publish(setpowerpub2, "OFF");
    }

    if (setPower2 == "ON") {
      client.publish(setpowerpub2, "ON");
    }
  }


  if (String(topic) == seteffectsub) {
    for (i = 0; i < length; i++) {
      message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
    setEffect = String(message_buff);
    Serial.println("Set Effect: " + setEffect);
    setPower = "ON";
    client.publish(setpowerpub, "ON");
  }

  if (String(topic) == seteffectsub2) {
    for (i = 0; i < length; i++) {
      message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
    setEffect2 = String(message_buff);
    Serial.println("Set Effect: " + setEffect2);
    setPower2 = "ON";
    client.publish(setpowerpub2, "ON");
  }

  if (String(topic) == setbrightness) {
    for (i = 0; i < length; i++) {
      message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
    setBrightness = String(message_buff);
    Serial.println("Set Brightness: " + setBrightness);
    brightness = setBrightness.toInt();
    setPower = "ON";
    client.publish(setpowerpub, "ON");
  }

  if (String(topic) == setbrightness2) {
    for (i = 0; i < length; i++) {
      message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
    setBrightness2 = String(message_buff);
    Serial.println("Set Brightness: " + setBrightness2);
    brightness2 = setBrightness2.toInt();
    setPower2 = "ON";
    client.publish(setpowerpub2, "ON");
  }

  if (String(topic) == setcolorsub) {
    for (i = 0; i < length; i++) {
      message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
    client.publish(setcolorpub, message_buff);
    setColor = String(message_buff);
    Serial.println("Set Color: " + setColor);
    setPower = "ON";
    client.publish(setpowerpub, "ON");
  }

  if (String(topic) == setcolorsub2) {
    for (i = 0; i < length; i++) {
      message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
    client.publish(setcolorpub2, message_buff);
    setColor2 = String(message_buff);
    Serial.println("Set Color: " + setColor2);
    setPower2 = "ON";
    client.publish(setpowerpub2, "ON");
  }


//  if (String(topic) == setanimationspeed) {
//    for (i = 0; i < length; i++) {
//      message_buff[i] = payload[i];
//    }
//    message_buff[i] = '\0';
//    setAnimationSpeed = String(message_buff);
//    animationspeed = setAnimationSpeed.toInt();
//  }
//
//  if (String(topic) == setanimationspeed2) {
//    for (i = 0; i < length; i++) {
//      message_buff[i] = payload[i];
//    }
//    message_buff[i] = '\0';
//    setAnimationSpeed2 = String(message_buff);
//    animationspeed2 = setAnimationSpeed2.toInt();
//  }
}

void loop() {

  if (!client.connected()) {
    reconnect();
  }
  client.loop();


  int Rcolor = setColor.substring(0, setColor.indexOf(',')).toInt();
  int Gcolor = setColor.substring(setColor.indexOf(',') + 1, setColor.lastIndexOf(',')).toInt();
  int Bcolor = setColor.substring(setColor.lastIndexOf(',') + 1).toInt();

  int Rcolor2 = setColor2.substring(0, setColor2.indexOf(',')).toInt();
  int Gcolor2 = setColor2.substring(setColor2.indexOf(',') + 1, setColor2.lastIndexOf(',')).toInt();
  int Bcolor2 = setColor2.substring(setColor2.lastIndexOf(',') + 1).toInt();

  if (setPower == "OFF") {
    setEffect = "Solid";
    for ( int i = 0; i < NUM_LEDS; i++) {
      leds[i].fadeToBlackBy( 8 );   //FADE OFF LEDS
    }
  }

  if (setPower2 == "OFF") {
    setEffect2 = "Solid";
    for ( int i = 0; i < NUM_LEDS2; i++) {
      leds2[i].fadeToBlackBy( 8 );   //FADE OFF LEDS
    }
  }

  if (setEffect == "Solid" & setPower == "ON" ) {          //Fill entire strand with solid color
    fill_solid(leds, NUM_LEDS, CRGB(Rcolor, Gcolor, Bcolor));
  }

//  if (setEffect2 == "Solid" & setPower2 == "ON" ) {          //Fill entire strand with solid color
//    fill_solid(leds2, NUM_LEDS2, CRGB(Rcolor2, Gcolor2, Bcolor2));
//  }

  FastLED.setBrightness(brightness);  //EXECUTE EFFECT COLOR
  FastLED.setBrightness(brightness2);  //EXECUTE EFFECT COLOR
  FastLED.show();

  if (animationspeed > 0 && animationspeed < 150) {  //Sets animation speed based on receieved value
    FastLED.delay(1000 / animationspeed);
  }

//  if (animationspeed2 > 0 && animationspeed2 < 150) {  //Sets animation speed based on receieved value
//    FastLED.delay(1000 / animationspeed2);
//  }

}

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
  if (client.connect("LivingRoomTVLEDs1", mqtt_user, mqtt_password)) {
      Serial.println("connected");

      FastLED.clear (); //Turns off startup LEDs after connection is made
      FastLED.show();

      client.subscribe(setcolorsub);
      client.subscribe(setbrightness);
      //client.subscribe(setcolortemp);
      client.subscribe(setpowersub);
      client.subscribe(seteffectsub);
//      client.subscribe(setanimationspeed);

      client.subscribe(setcolorsub2);
      client.subscribe(setbrightness2);
//      //client.subscribe(setcolortemp2);
      client.subscribe(setpowersub2);
      client.subscribe(seteffectsub2);
//      client.subscribe(setanimationspeed2);
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}

Just throwing this out, have you tried writing to a different pin other than 6? I see there’s a comment in the code about ‘Defaulting to pin 5’, but since I don’t have a nodemcu (or anything ATM) I can’t play with the code.

on the NodeMCU 1.0, FastLED will default to the D5 pin after throwing an error during compiling. Leave as is.

So I think I got it figured out. I saw that note about the pin but I initially had it set up on pin 5 and 6 and it was working with one MQTT command. So the solution has to do with the subscribe portion. I guess I am subscribing to too many topics at once. To fix this add the client.loop(); between the subscribe topics like so:

      client.subscribe(setcolorsub);
      client.loop();
      client.subscribe(setbrightness);
      client.loop();
//      client.subscribe(setcolortemp);
//      client.loop();
      client.subscribe(setpowersub);
      client.loop();
      client.subscribe(seteffectsub);
      client.loop();
      client.subscribe(setanimationspeed);
      client.loop();

Sorry for my language.I leave in spain and i was instaling fastled of Bruth and i have a error with he code.and i was searching for internet about that after hours i found your problem.
my code is

*/

#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include “FastLED.h”
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

/************ WIFI and MQTT Information (CHANGE THESE FOR YOUR SETUP) *************/
const char
ssid = “name of my wifi”; //type your WIFI information inside the quotes
const char
password = “my password”;
const char
mqtt_server = “192.168.1.20”;
const char
mqtt_username = “username”;
const char
mqtt_password = “password”;
const int mqtt_port = 1883;

/**************************** FOR OTA **************************************************/
#define SENSORNAME “porch” //change this to whatever you want to call your device
#define OTApassword “yourOTApassword” //the password you will need to enter to upload remotely via the ArduinoIDE
int OTAport = 8266;

/************* MQTT TOPICS (change these topics as you wish) ************************/
const char
light_state_topic = “bruh/porch”;
const char
light_set_topic = “bruh/porch/set”;

const char* on_cmd = “ON”;
const char* off_cmd = “OFF”;
const char* effect = “solid”;
String effectString = “solid”;
String oldeffectString = “solid”;

/*FOR JSON/
const int BUFFER_SIZE = JSON_OBJECT_SIZE(10);
#define MQTT_MAX_PACKET_SIZE 512

/*********************************** FastLED Defintions ********************************/
#define NUM_LEDS 188
#define DATA_PIN 5
//#define CLOCK_PIN 5
#define CHIPSET WS2811
#define COLOR_ORDER BRG

byte realRed = 0;
byte realGreen = 0;
byte realBlue = 0;

byte red = 255;
byte green = 255;
byte blue = 255;
byte brightness = 255;

/******************************** GLOBALS for fade/flash *******************************/
bool stateOn = false;
bool startFade = false;
bool onbeforeflash = false;
unsigned long lastLoop = 0;
int transitionTime = 0;
int effectSpeed = 0;
bool inFade = false;
int loopCount = 0;
int stepR, stepG, stepB;
int redVal, grnVal, bluVal;

bool flash = false;
bool startFlash = false;
int flashLength = 0;
unsigned long flashStartTime = 0;
byte flashRed = red;
byte flashGreen = green;
byte flashBlue = blue;
byte flashBrightness = brightness;

/********************************** GLOBALS for EFFECTS ******************************/
//RAINBOW
uint8_t thishue = 0; // Starting hue value.
uint8_t deltahue = 10;

//CANDYCANE
CRGBPalette16 currentPalettestriped; //for Candy Cane
CRGBPalette16 gPal; //for fire

//NOISE
static uint16_t dist; // A random number for our noise generator.
uint16_t scale = 30; // Wouldn’t recommend changing this on the fly, or the animation will be really blocky.
uint8_t maxChanges = 48; // Value for blending between palettes.
CRGBPalette16 targetPalette(OceanColors_p);
CRGBPalette16 currentPalette(CRGB::Black);

//TWINKLE
#define DENSITY 80
int twinklecounter = 0;

//RIPPLE
uint8_t colour; // Ripple colour is randomized.
int center = 0; // Center of the current ripple.
int step = -1; // -1 is the initializing step.
uint8_t myfade = 255; // Starting brightness.
#define maxsteps 16 // Case statement wouldn’t allow a variable.
uint8_t bgcol = 0; // Background colour rotates.
int thisdelay = 20; // Standard delay value.

//DOTS
uint8_t count = 0; // Count up to 255 and then reverts to 0
uint8_t fadeval = 224; // Trail behind the LED’s. Lower => faster fade.
uint8_t bpm = 30;

//LIGHTNING
uint8_t frequency = 50; // controls the interval between strikes
uint8_t flashes = 8; //the upper limit of flashes per strike
unsigned int dimmer = 1;
uint8_t ledstart; // Starting location of a flash
uint8_t ledlen;
int lightningcounter = 0;

//FUNKBOX
int idex = 0; //-LED INDEX (0 to NUM_LEDS-1
int TOP_INDEX = int(NUM_LEDS / 2);
int thissat = 255; //-FX LOOPS DELAY VAR
uint8_t thishuepolice = 0;
int antipodal_index(int i) {
int iN = i + TOP_INDEX;
if (i >= TOP_INDEX) {
iN = ( i + TOP_INDEX ) % NUM_LEDS;
}
return iN;
}

//FIRE
#define COOLING 55
#define SPARKING 120
bool gReverseDirection = false;

//BPM
uint8_t gHue = 0;

WiFiClient espClient;
PubSubClient client(espClient);
struct CRGB leds[NUM_LEDS];

/********************************** START SETUP*****************************************/
void setup() {
Serial.begin(115200);
FastLED.addLeds<CHIPSET, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);

setupStripedPalette( CRGB::Red, CRGB::Red, CRGB::White, CRGB::White); //for CANDY CANE
gPal = HeatColors_p; //for FIRE

setup_wifi();
client.setServer(mqtt_server, mqtt_port);
client.setCallback(callback);

//OTA SETUP
ArduinoOTA.setPort(OTAport);
// Hostname defaults to esp8266-[ChipID]
ArduinoOTA.setHostname(SENSORNAME);

// No authentication by default
ArduinoOTA.setPassword((const char *)OTApassword);

ArduinoOTA.onStart( {
Serial.println(“Starting”);
});
ArduinoOTA.onEnd( {
Serial.println("\nEnd");
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf(“Progress: %u%%\r”, (progress / (total / 100)));
});
ArduinoOTA.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println(“Auth Failed”);
else if (error == OTA_BEGIN_ERROR) Serial.println(“Begin Failed”);
else if (error == OTA_CONNECT_ERROR) Serial.println(“Connect Failed”);
else if (error == OTA_RECEIVE_ERROR) Serial.println(“Receive Failed”);
else if (error == OTA_END_ERROR) Serial.println(“End Failed”);
});
ArduinoOTA.begin();

Serial.println(“Ready”);
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());

}

/********************************** START SETUP WIFI*****************************************/
void setup_wifi() {

delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}

Serial.println("");
Serial.println(“WiFi connected”);
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}

/*
SAMPLE PAYLOAD:
{
“brightness”: 120,
“color”: {
“r”: 255,
“g”: 100,
“b”: 100
},
“flash”: 2,
“transition”: 5,
“state”: “ON”
}
*/

and i uploading with arduino i have two erorrs:
1. In file included from C:\Users\TheOne\Downloads\Compressed\ESP-MQTT-JSON-Digital-LEDs-master_2\ESP-MQTT-JSON-Digital-LEDs-master\ESP_MQTT_Digital_LEDs\ESP_MQTT_Digital_LEDs.ino:26:0:

C:\Users\TheOne\Desktop\arduino-1.8.3\portable\sketchbook\libraries\FastLED/FastLED.h:17:21: note: #pragma message: FastLED version 3.001.003

pragma message “FastLED version 3.001.003”

2. In file included from C:\Users\TheOne\Desktop\arduino-1.8.3\portable\sketchbook\libraries\FastLED/FastLED.h:65:0,

             from C:\Users\TheOne\Downloads\Compressed\ESP-MQTT-JSON-Digital-LEDs-master_2\ESP-MQTT-JSON-Digital-LEDs-master\ESP_MQTT_Digital_LEDs\ESP_MQTT_Digital_LEDs.ino:26:

C:\Users\TheOne\Desktop\arduino-1.8.3\portable\sketchbook\libraries\FastLED/fastspi.h:110:23: note: #pragma message: No hardware SPI pins defined. All SPI access will default to bitbanged output

pragma message “No hardware SPI pins defined. All SPI access will default to bitbanged output”

and i upload with that erorr and my NodeMcu Amica (NodeMcu DevKit, ESP8266 12E, 4 MB, WIFI, CP2102) is blocked with led blue (right corner) and if i put Serial Monitor i see a lot of caracters whitout myredwifi and mqtt.

Can you help me plz?can you send me a code for that? for a simple led strip 2m…120leds (WS2811 5050 SMD RGB Tira 30/48/60 leds/m).

I would be glad to help but I am not really sure what the issue is. it looks like the SPI pin is defined. But it is really hard to read your code as it is not in the preformatted text,

My code is all shown above. I made the update which is shown in the second post but other than that it hasn’t changed.

First i thankyou a lot to answerd so quickly.

  1. I have NodeMcu Amica, driver cp2102. That is posible to be a problem for the code¿¿¿¿¿
  2. You code have:#include <ESP8266WiFi.h>
    #include <PubSubClient.h>
    #include “FastLED.h”
    and code of bruth have : #include <ArduinoJson.h>
    #include <ESP8266WiFi.h>
    #include <PubSubClient.h>
    #include “FastLED.h”
    #include <ESP8266mDNS.h>
    #include <WiFiUdp.h>
    #include <ArduinoOTA.h>
  3. Your mqtt is : /************ WIFI and MQTT INFORMATION (CHANGE THESE FOR YOUR SETUP) ******************/
    #define wifi_ssid “Omit” //enter your WIFI SSID
    #define wifi_password “Omit” //enter your WIFI Password

#define mqtt_server “Omit” // Enter your MQTT server adderss or IP. I use my DuckDNS adddress (yourname.duckdns.org) in this field
#define mqtt_user “Omit” //enter your MQTT username
#define mqtt_password “Omit” //enter your password

and mqtt of Bruth had ¨ constant char ¨ and not ¨define¨¨ like you¨:

           const char* ssid = "....."; //type your WIFI information inside the quotes

const char* password = “…”;
const char* mqtt_server = “192.168.1.20”;
const char* mqtt_username = “…”;
const char* mqtt_password = “…”;
const int mqtt_port = 1883;
.
4. you have define MQTT TOPICS but in code of Bruth dont have MQTT TOPICS

for all that i think that the code of Bruth is wrong.(in his video ¨¨The BEST Digital LED Strip Light Tutorial - DIY, WIFI-Controllable via ESP, MQTT, and Home Assistant¨¨ the code is different which he had on page web)
and for that i ask you if you can send me your code for try with him to install in nodemcu.
in this forum you say that ¨Here is the rest of my code¨ but i ask you if you can send me all of code .

Thanks again for you attention. sorry for my language. plz help me . in my country ¨ SPAIN ¨ homeassistant is a new thing and we dont have forum for that.

Ok here is what I have. I started with Bruh Automations code but have added stuff since so hopefully that doesn’t mess you up. I have redacted my personal info. This code controls two separate strings of lights so I don’t know if that is what you want or not but this will do that. Also I have code in here to control the lights on the holidays or special days. I have to make 2 posts because it is too long for 1 post

/*
  .______   .______    __    __   __    __          ___      __    __  .___________.  ______   .___  ___.      ___   .___________. __    ______   .__   __.
  |   _  \  |   _  \  |  |  |  | |  |  |  |        /   \    |  |  |  | |           | /  __  \  |   \/   |     /   \  |           ||  |  /  __  \  |  \ |  |
  |  |_)  | |  |_)  | |  |  |  | |  |__|  |       /  ^  \   |  |  |  | `---|  |----`|  |  |  | |  \  /  |    /  ^  \ `---|  |----`|  | |  |  |  | |   \|  |
  |   _  <  |      /  |  |  |  | |   __   |      /  /_\  \  |  |  |  |     |  |     |  |  |  | |  |\/|  |   /  /_\  \    |  |     |  | |  |  |  | |  . `  |
  |  |_)  | |  |\  \-.|  `--'  | |  |  |  |     /  _____  \ |  `--'  |     |  |     |  `--'  | |  |  |  |  /  _____  \   |  |     |  | |  `--'  | |  |\   |
  |______/  | _| `.__| \______/  |__|  |__|    /__/     \__\ \______/      |__|      \______/  |__|  |__| /__/     \__\  |__|     |__|  \______/  |__| \__|
This is the code I use for my MQTT LED Strip controlled from Home Assistant. It's a work in progress, but works great! Huge shout out to all the people I copied ideas from as a scoured around the internet. If you recoginze your code here and want credit, let me know and I'll get that added. Cheers! 
*/


#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include "FastLED.h"


/************ WIFI and MQTT INFORMATION (CHANGE THESE FOR YOUR SETUP) ******************/
#define wifi_ssid "REDACTED" //enter your WIFI SSID
#define wifi_password "REDACTED" //enter your WIFI Password

#define mqtt_server "XXX.XXX.XXX.XXX" // Enter your MQTT server adderss or IP. I use my DuckDNS adddress (yourname.duckdns.org) in this field
#define mqtt_user "REDACTED" //enter your MQTT username
#define mqtt_password "REDACTED" //enter your password

/************ FastLED Defintions ******************/

#define DATA_PIN    6 //on the NodeMCU 1.0, FastLED will default to the D5 pin after throwing an error during compiling. Leave as is. 
#define LED_TYPE    WS2811 //change to match your LED type
#define COLOR_ORDER BRG //change to match your LED configuration
#define NUM_LEDS    51 //change to match your setup

#define DATA_PIN2    5 //on the NodeMCU 1.0, FastLED will default to the D5 pin after throwing an error during compiling. Leave as is. 
//#define LED_TYPE    WS2811 //change to match your LED type
//#define COLOR_ORDER BRG //change to match your LED configuration
#define NUM_LEDS2    52 //change to match your setup


//No Changes Required After This Point

/****************************** MQTT TOPICS (change these topics as you wish)  ***************************************/

#define colorstatuspub "home/livingroom/tvleds/colorstatus"
#define setcolorsub "home/livingroom/tvleds/setcolor"
#define setpowersub "home/livingroom/tvleds/setpower"
#define seteffectsub "home/livingroom/tvleds/seteffect"
#define setbrightness "home/livingroom/tvleds/setbrightness"

#define setcolorpub "home/livingroom/tvleds/setcolorpub"
#define setpowerpub "home/livingroom/tvleds/setpowerpub"
#define seteffectpub "home/livingroom/tvleds/seteffectpub"
#define setbrightnesspub "home/livingroom/tvleds/setbrightnesspub"
#define setanimationspeed "home/livingroom/tvleds/setanimationspeed"

#define colorstatuspub2 "home/livingroom/cabinetleds/colorstatus"
#define setcolorsub2 "home/livingroom/cabinetleds/setcolor"
#define setpowersub2 "home/livingroom/cabinetleds/setpower"
#define seteffectsub2 "home/livingroom/cabinetleds/seteffect"
#define setbrightness2 "home/livingroom/cabinetleds/setbrightness"

#define setcolorpub2 "home/livingroom/cabinetleds/setcolorpub"
#define setpowerpub2 "home/livingroom/cabinetleds/setpowerpub"
#define seteffectpub2 "home/livingroom/cabinetleds/seteffectpub"
#define setbrightnesspub2 "home/livingroom/cabinetleds/setbrightnesspub"
#define setanimationspeed2 "home/livingroom/cabinetleds/setanimationspeed"

/*************************** EFFECT CONTROL VARIABLES AND INITIALIZATIONS ************************************/

#if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)
#warning "Requires FastLED 3.1 or later; check github for latest code."
#endif

String setColor ="0,0,150";
String setPower;
String setEffect = "Solid";
String setBrightness = "150";
int brightness = 150;
String setAnimationSpeed;
int animationspeed = 240;
String setColorTemp;
int Rcolor = 0;
int Gcolor = 0;
int Bcolor = 0;
CRGB leds[NUM_LEDS];

String setColor2 ="0,0,150";
String setPower2;
String setEffect2 = "Solid";
String setBrightness2 = "150";
int brightness2 = 150;
String setAnimationSpeed2;
int animationspeed2 = 240;
String setColorTemp2;
int Rcolor2 = 0;
int Gcolor2 = 0;
int Bcolor2 = 0;
CRGB leds2[NUM_LEDS2];

/****************FOR CANDY CANE***************/
CRGBPalette16 currentPalettestriped; //for Candy Cane
CRGBPalette16 gPal; //for fire

/****************FOR NOISE***************/
static uint16_t dist;         // A random number for our noise generator.
uint16_t scale = 30;          // Wouldn't recommend changing this on the fly, or the animation will be really blocky.
uint8_t maxChanges = 48;      // Value for blending between palettes.
CRGBPalette16 targetPalette(OceanColors_p);
CRGBPalette16 currentPalette(CRGB::Black);

/*****************For TWINKER********/
#define DENSITY     80
int twinklecounter = 0;
int twinklecounter2 = 0;

/*********FOR RIPPLE***********/
uint8_t colour;                                               // Ripple colour is randomized.
int center = 0;                                               // Center of the current ripple.
int step = -1;                                                // -1 is the initializing step.
uint8_t myfade = 255;                                         // Starting brightness.
#define maxsteps 16                                           // Case statement wouldn't allow a variable.
uint8_t bgcol = 0;                                            // Background colour rotates.
int thisdelay = 20;                                           // Standard delay value.

/**************FOR RAINBOW***********/
uint8_t thishue = 0;                                          // Starting hue value.
uint8_t deltahue = 10;
uint8_t thishue2 = 0;

/**************FOR DOTS**************/
uint8_t   count =   0;                                        // Count up to 255 and then reverts to 0
uint8_t fadeval = 224;                                        // Trail behind the LED's. Lower => faster fade.
uint8_t bpm = 30;

/**************FOR LIGHTNING**************/
uint8_t frequency = 50;                                       // controls the interval between strikes
uint8_t flashes = 8;                                          //the upper limit of flashes per strike
unsigned int dimmer = 1;
uint8_t ledstart;                                             // Starting location of a flash
uint8_t ledlen;
int lightningcounter = 0;

uint8_t frequency2 = 50;                                       // controls the interval between strikes
uint8_t ledstart2;                                             // Starting location of a flash
uint8_t ledlen2;
int lightningcounter2 = 0;

/********FOR FUNKBOX EFFECTS**********/
int idex = 0;                //-LED INDEX (0 to NUM_LEDS-1
int TOP_INDEX = int(NUM_LEDS / 2);
int thissat = 255;           //-FX LOOPS DELAY VAR
uint8_t thishuepolice = 0;     
int antipodal_index(int i) {
  int iN = i + TOP_INDEX;
  if (i >= TOP_INDEX) {
    iN = ( i + TOP_INDEX ) % NUM_LEDS;
  }
  return iN;
}

int idex2 = 0;
int TOP_INDEX2 = int(NUM_LEDS2 / 2);
int thissat2 = 255;           //-FX LOOPS DELAY VAR
uint8_t thishuepolice2 = 0;     
int antipodal_index2(int i) {
  int iN = i + TOP_INDEX2;
  if (i >= TOP_INDEX2) {
    iN = ( i + TOP_INDEX2 ) % NUM_LEDS2;
  }
  return iN;
}

/********FIRE**********/
#define COOLING  55
#define SPARKING 120
bool gReverseDirection = false;

/********BPM**********/
uint8_t gHue = 0;
char message_buff[100];


WiFiClient espClient;
PubSubClient client(espClient);

void setup() {
  Serial.begin(115200);

  FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalSMD5050 );
  //FastLED.addLeds<LED_TYPE, 5, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.addLeds<LED_TYPE, DATA_PIN2, COLOR_ORDER>(leds2, NUM_LEDS2).setCorrection( TypicalSMD5050 );
  FastLED.setMaxPowerInVoltsAndMilliamps(12, 10000); //experimental for power management. Feel free to try in your own setup.
  FastLED.setBrightness(brightness);
  FastLED.setBrightness(brightness2);

  setupStripedPalette( CRGB::Red, CRGB::Red, CRGB::White, CRGB::White); //for CANDY CANE

    gPal = HeatColors_p; //for FIRE

  fill_solid(leds, NUM_LEDS, CRGB(255, 0, 0)); //Startup LED Lights
  fill_solid(leds2, NUM_LEDS2, CRGB(255, 0, 0)); //Startup LED Lights
  FastLED.show();

  setup_wifi();

  client.setServer(mqtt_server, 1883); //CHANGE PORT HERE IF NEEDED
  client.setCallback(callback);
}


void setup_wifi() {

  delay(10);
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(wifi_ssid);

  WiFi.begin(wifi_ssid, wifi_password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void callback(char* topic, byte* payload, unsigned int length) {
  int i = 0;

  if (String(topic) == setpowersub) {
    for (i = 0; i < length; i++) {
      message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
    setPower = String(message_buff);
    Serial.println("Set Power: " + setPower);
    if (setPower == "OFF") {
      client.publish(setpowerpub, "OFF");
    }

    if (setPower == "ON") {
      client.publish(setpowerpub, "ON");
    }
  }

  if (String(topic) == setpowersub2) {
    for (i = 0; i < length; i++) {
      message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
    setPower2 = String(message_buff);
    Serial.println("Set Power: " + setPower2);
    if (setPower2 == "OFF") {
      client.publish(setpowerpub2, "OFF");
    }

    if (setPower2 == "ON") {
      client.publish(setpowerpub2, "ON");
    }
  }


  if (String(topic) == seteffectsub) {
    for (i = 0; i < length; i++) {
      message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
    setEffect = String(message_buff);
    Serial.println("Set Effect: " + setEffect);
    setPower = "ON";
    client.publish(setpowerpub, "ON");
    if (setEffect == "Twinkle") {
      twinklecounter = 0;
    }
    if (setEffect == "Lightning") {
      twinklecounter = 0;
    }
  }

  if (String(topic) == seteffectsub2) {
    for (i = 0; i < length; i++) {
      message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
    setEffect2 = String(message_buff);
    Serial.println("Set Effect: " + setEffect2);
    setPower2 = "ON";
    client.publish(setpowerpub2, "ON");
    if (setEffect2 == "Twinkle") {
      twinklecounter2 = 0;
    }
    if (setEffect2 == "Lightning") {
      twinklecounter2 = 0;
    }
  }

  if (String(topic) == setbrightness) {
    for (i = 0; i < length; i++) {
      message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
    setBrightness = String(message_buff);
    Serial.println("Set Brightness: " + setBrightness);
    brightness = setBrightness.toInt();
    setPower = "ON";
    client.publish(setpowerpub, "ON");
  }

  if (String(topic) == setbrightness2) {
    for (i = 0; i < length; i++) {
      message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
    setBrightness2 = String(message_buff);
    Serial.println("Set Brightness: " + setBrightness2);
    brightness2 = setBrightness2.toInt();
    setPower2 = "ON";
    client.publish(setpowerpub2, "ON");
  }


//  if (String(topic) == setcolortemp) {    //colortemp setup for future update
//    for (i = 0; i < length; i++) {
//      message_buff[i] = payload[i];
//    }
//    message_buff[i] = '\0';
//    setColorTemp = String(message_buff);
//    Serial.println("Set Color Temperature: " + setColorTemp);
//    setPower = "ON";
//    client.publish(setpowerpub, "ON");
//  }

  if (String(topic) == setcolorsub) {
    for (i = 0; i < length; i++) {
      message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
    client.publish(setcolorpub, message_buff);
    setColor = String(message_buff);
    Serial.println("Set Color: " + setColor);
    setPower = "ON";
    client.publish(setpowerpub, "ON");
  }

  if (String(topic) == setcolorsub2) {
    for (i = 0; i < length; i++) {
      message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
    client.publish(setcolorpub2, message_buff);
    setColor2 = String(message_buff);
    Serial.println("Set Color: " + setColor2);
    setPower2 = "ON";
    client.publish(setpowerpub2, "ON");
  }


  if (String(topic) == setanimationspeed) {
    for (i = 0; i < length; i++) {
      message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
    setAnimationSpeed = String(message_buff);
    animationspeed = setAnimationSpeed.toInt();
  }

  if (String(topic) == setanimationspeed2) {
    for (i = 0; i < length; i++) {
      message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
    setAnimationSpeed2 = String(message_buff);
    animationspeed2 = setAnimationSpeed2.toInt();
  }
}



void loop() {

  if (!client.connected()) {
    reconnect();
  }
  client.loop();


  int Rcolor = setColor.substring(0, setColor.indexOf(',')).toInt();
  int Gcolor = setColor.substring(setColor.indexOf(',') + 1, setColor.lastIndexOf(',')).toInt();
  int Bcolor = setColor.substring(setColor.lastIndexOf(',') + 1).toInt();

  int Rcolor2 = setColor2.substring(0, setColor2.indexOf(',')).toInt();
  int Gcolor2 = setColor2.substring(setColor2.indexOf(',') + 1, setColor2.lastIndexOf(',')).toInt();
  int Bcolor2 = setColor2.substring(setColor2.lastIndexOf(',') + 1).toInt();

  if (setPower == "OFF") {
    setEffect = "Solid";
    for ( int i = 0; i < NUM_LEDS; i++) {
      leds[i].fadeToBlackBy( 8 );   //FADE OFF LEDS
    }
  }

  if (setPower2 == "OFF") {
    setEffect2 = "Solid";
    for ( int i = 0; i < NUM_LEDS2; i++) {
      leds2[i].fadeToBlackBy( 8 );   //FADE OFF LEDS
    }
  }

  if (setEffect == "Sinelon") {
    fadeToBlackBy( leds, NUM_LEDS, 20);
    int pos = beatsin16(13, 0, NUM_LEDS);
    leds[pos] += CRGB(Rcolor, Gcolor, Bcolor);
  }

  if (setEffect2 == "Sinelon") {
    fadeToBlackBy( leds2, NUM_LEDS2, 20);
    int pos = beatsin16(13, 0, NUM_LEDS2);
    leds2[pos] += CRGB(Rcolor2, Gcolor2, Bcolor2);
  }

  if (setEffect == "Juggle" ) {                           // eight colored dots, weaving in and out of sync with each other
    fadeToBlackBy( leds, NUM_LEDS, 20);
    byte dothue = 0;
    for ( int i = 0; i < 8; i++) {
      leds[beatsin16(i + 7, 0, NUM_LEDS)] |= CRGB(Rcolor, Gcolor, Bcolor);
      dothue += 32;
    }
  }

  if (setEffect2 == "Juggle" ) {                           // eight colored dots, weaving in and out of sync with each other
    fadeToBlackBy( leds2, NUM_LEDS2, 20);
    byte dothue = 0;
    for ( int i = 0; i < 8; i++) {
      leds2[beatsin16(i + 7, 0, NUM_LEDS2)] |= CRGB(Rcolor2, Gcolor2, Bcolor2);
      dothue += 32;
    }
  }

  if (setEffect == "Confetti" ) {                       // random colored speckles that blink in and fade smoothly
    fadeToBlackBy( leds, NUM_LEDS, 10);
    int pos = random16(NUM_LEDS);
    leds[pos] += CRGB(Rcolor + random8(64), Gcolor, Bcolor);
  }

  if (setEffect2 == "Confetti" ) {                       // random colored speckles that blink in and fade smoothly
    fadeToBlackBy( leds2, NUM_LEDS2, 10);
    int pos = random16(NUM_LEDS2);
    leds2[pos] += CRGB(Rcolor2 + random8(64), Gcolor2, Bcolor2);
  }


  if (setEffect == "Rainbow") {
    // FastLED's built-in rainbow generator
    static uint8_t starthue = 0;    thishue++;
    fill_rainbow(leds, NUM_LEDS, thishue, deltahue);
  }

  if (setEffect2 == "Rainbow") {
    // FastLED's built-in rainbow generator
    static uint8_t starthue2 = 0;    thishue2++;
    fill_rainbow(leds2, NUM_LEDS2, thishue2, deltahue);
  }


  if (setEffect == "Rainbow with Glitter") {               // FastLED's built-in rainbow generator with Glitter
    static uint8_t starthue = 0;
    thishue++;
    fill_rainbow(leds, NUM_LEDS, thishue, deltahue);
    addGlitter(80);
  }

  if (setEffect2 == "Rainbow with Glitter") {               // FastLED's built-in rainbow generator with Glitter
    static uint8_t starthue2 = 0;
    thishue2++;
    fill_rainbow(leds2, NUM_LEDS2, thishue2, deltahue);
    addGlitter2(80);
  }


  if (setEffect == "Glitter") {
    fadeToBlackBy( leds, NUM_LEDS, 20);
    addGlitterColor(80, Rcolor, Gcolor, Bcolor);
  }

  if (setEffect2 == "Glitter") {
    fadeToBlackBy( leds2, NUM_LEDS2, 20);
    addGlitterColor2(80, Rcolor2, Gcolor2, Bcolor2);
  }


  if (setEffect == "BPM") {                                  // colored stripes pulsing at a defined Beats-Per-Minute (BPM)
  uint8_t BeatsPerMinute = 62;
  CRGBPalette16 palette = PartyColors_p;
  uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
  for( int i = 0; i < NUM_LEDS; i++) { //9948
    leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));
  }
}

  if (setEffect2 == "BPM") {                                  // colored stripes pulsing at a defined Beats-Per-Minute (BPM)
  uint8_t BeatsPerMinute2 = 62;
  CRGBPalette16 palette = PartyColors_p;
  uint8_t beat2 = beatsin8( BeatsPerMinute2, 64, 255);
    for( int i = 0; i < NUM_LEDS2; i++) { //9948
      leds2[i] = ColorFromPalette(palette, gHue+(i*2), beat2-gHue+(i*10));
    }
}

  if (setEffect == "Solid" & setPower == "ON" ) {          //Fill entire strand with solid color
    fill_solid(leds, NUM_LEDS, CRGB(Rcolor, Gcolor, Bcolor));
  }

  if (setEffect2 == "Solid" & setPower2 == "ON" ) {          //Fill entire strand with solid color
    fill_solid(leds2, NUM_LEDS2, CRGB(Rcolor2, Gcolor2, Bcolor2));
  }
  if (setEffect == "Twinkle") {
    twinklecounter = twinklecounter + 1;
    if (twinklecounter < 2) {                               //Resets strip if previous animation was running
      FastLED.clear();
      FastLED.show();
    }
    const CRGB lightcolor(8, 7, 1);
    for ( int i = 0; i < NUM_LEDS; i++) {
      if ( !leds[i]) continue; // skip black pixels
      if ( leds[i].r & 1) { // is red odd?
        leds[i] -= lightcolor; // darken if red is odd
      } else {
        leds[i] += lightcolor; // brighten if red is even
      }
    }
    if ( random8() < DENSITY) {
      int j = random16(NUM_LEDS);
      if ( !leds[j] ) leds[j] = lightcolor;
    }
  }

  if (setEffect2 == "Twinkle") {
    twinklecounter2 = twinklecounter2 + 1;
    if (twinklecounter2 < 2) {                               //Resets strip if previous animation was running
      FastLED.clear();
      FastLED.show();
    }
    const CRGB lightcolor2(8, 7, 1);
    for ( int i = 0; i < NUM_LEDS2; i++) {
      if ( !leds2[i]) continue; // skip black pixels
      if ( leds2[i].r & 1) { // is red odd?
        leds2[i] -= lightcolor2; // darken if red is odd
      } else {
        leds2[i] += lightcolor2; // brighten if red is even
      }
    }
    if ( random8() < DENSITY) {
      int j = random16(NUM_LEDS2);
      if ( !leds2[j] ) leds2[j] = lightcolor2;
    }
  }

  if (setEffect == "Dots") {
    uint8_t inner = beatsin8(bpm, NUM_LEDS / 4, NUM_LEDS / 4 * 3);
    uint8_t outer = beatsin8(bpm, 0, NUM_LEDS - 1);
    uint8_t middle = beatsin8(bpm, NUM_LEDS / 3, NUM_LEDS / 3 * 2);
    leds[middle] = CRGB::Purple;
    leds[inner] = CRGB::Blue;
    leds[outer] = CRGB::Aqua;
    nscale8(leds, NUM_LEDS, fadeval);
  }

  if (setEffect2 == "Dots") {
    uint8_t inner2 = beatsin8(bpm, NUM_LEDS2 / 4, NUM_LEDS2 / 4 * 3);
    uint8_t outer2 = beatsin8(bpm, 0, NUM_LEDS2 - 1);
    uint8_t middle2 = beatsin8(bpm, NUM_LEDS2 / 3, NUM_LEDS2 / 3 * 2);
    leds2[middle2] = CRGB::Purple;
    leds2[inner2] = CRGB::Blue;
    leds2[outer2] = CRGB::Aqua;
    nscale8(leds2, NUM_LEDS2, fadeval);
  }

  if (setEffect == "Lightning") {
    twinklecounter = twinklecounter + 1;                     //Resets strip if previous animation was running
    Serial.println(twinklecounter);
    if (twinklecounter < 2) {
      FastLED.clear();
      FastLED.show();
    }
    ledstart = random8(NUM_LEDS);           // Determine starting location of flash
    ledlen = random8(NUM_LEDS - ledstart);  // Determine length of flash (not to go beyond NUM_LEDS-1)
    for (int flashCounter = 0; flashCounter < random8(3, flashes); flashCounter++) {
      if (flashCounter == 0) dimmer = 5;    // the brightness of the leader is scaled down by a factor of 5
      else dimmer = random8(1, 3);          // return strokes are brighter than the leader
      fill_solid(leds + ledstart, ledlen, CHSV(255, 0, 255 / dimmer));
      FastLED.show();                       // Show a section of LED's
      delay(random8(4, 10));                // each flash only lasts 4-10 milliseconds
      fill_solid(leds + ledstart, ledlen, CHSV(255, 0, 0)); // Clear the section of LED's
      FastLED.show();
      if (flashCounter == 0) delay (150);   // longer delay until next flash after the leader
      delay(50 + random8(100));             // shorter delay between strokes
    }
    delay(random8(frequency) * 100);        // delay between strikes
  }

  if (setEffect2 == "Lightning") {
    twinklecounter2 = twinklecounter2 + 1;                     //Resets strip if previous animation was running
    Serial.println(twinklecounter2);
    if (twinklecounter2 < 2) {
      FastLED.clear();
      FastLED.show();
    }
    ledstart2 = random8(NUM_LEDS2);           // Determine starting location of flash
    ledlen2 = random8(NUM_LEDS2 - ledstart2);  // Determine length of flash (not to go beyond NUM_LEDS-1)
    for (int flashCounter = 0; flashCounter < random8(3, flashes); flashCounter++) {
      if (flashCounter == 0) dimmer = 5;    // the brightness of the leader is scaled down by a factor of 5
      else dimmer = random8(1, 3);          // return strokes are brighter than the leader
      fill_solid(leds2 + ledstart2, ledlen2, CHSV(255, 0, 255 / dimmer));
      FastLED.show();                       // Show a section of LED's
      delay(random8(4, 10));                // each flash only lasts 4-10 milliseconds
      fill_solid(leds2 + ledstart2, ledlen2, CHSV(255, 0, 0)); // Clear the section of LED's
      FastLED.show();
      if (flashCounter == 0) delay (150);   // longer delay until next flash after the leader
      delay(50 + random8(100));             // shorter delay between strokes
    }
    delay(random8(frequency2) * 100);        // delay between strikes
  }



  if (setEffect == "Police One") {                    //POLICE LIGHTS (TWO COLOR SINGLE LED)
    idex++;
    if (idex >= NUM_LEDS) {
      idex = 0;
    }
    int idexR = idex;
    int idexB = antipodal_index(idexR);
    int thathue = (thishuepolice + 160) % 255;
    for (int i = 0; i < NUM_LEDS; i++ ) {
      if (i == idexR) {
        leds[i] = CHSV(thishuepolice, thissat, 255);
      }
      else if (i == idexB) {
        leds[i] = CHSV(thathue, thissat, 255);
      }
      else {
        leds[i] = CHSV(0, 0, 0);
      }
    }

  }

  if (setEffect2 == "Police One") {                    //POLICE LIGHTS (TWO COLOR SINGLE LED)
    idex2++;
    if (idex2 >= NUM_LEDS2) {
      idex2 = 0;
    }
    int idexR2 = idex2;
    int idexB2 = antipodal_index2(idexR2);
    int thathue2 = (thishuepolice2 + 160) % 255;
    for (int i = 0; i < NUM_LEDS2; i++ ) {
      if (i == idexR2) {
        leds2[i] = CHSV(thishuepolice2, thissat2, 255);
      }
      else if (i == idexB2) {
        leds2[i] = CHSV(thathue2, thissat2, 255);
      }
      else {
        leds2[i] = CHSV(0, 0, 0);
      }
    }

  }

  if (setEffect == "Police All") {                 //POLICE LIGHTS (TWO COLOR SOLID)
    idex++;
    if (idex >= NUM_LEDS) {
      idex = 0;
    }
    int idexR = idex;
    int idexB = antipodal_index(idexR);
    int thathue = (thishuepolice + 160) % 255;
    leds[idexR] = CHSV(thishuepolice, thissat, 255);
    leds[idexB] = CHSV(thathue, thissat, 255);
  }

  if (setEffect2 == "Police All") {                 //POLICE LIGHTS (TWO COLOR SOLID)
    idex2++;
    if (idex2 >= NUM_LEDS2) {
      idex2 = 0;
    }
    int idexR2 = idex2;
    int idexB2 = antipodal_index2(idexR2);
    int thathue2 = (thishuepolice2 + 160) % 255;
    leds2[idexR2] = CHSV(thishuepolice2, thissat2, 255);
    leds2[idexB2] = CHSV(thathue2, thissat2, 255);
  }


  if (setEffect == "Candy Cane") {
    static uint8_t startIndex = 0;
    startIndex = startIndex + 1; /* higher = faster motion */

    fill_palette( leds, NUM_LEDS,
                  startIndex, 16, /* higher = narrower stripes */
                  currentPalettestriped, 255, LINEARBLEND);
  }

  if (setEffect2 == "Candy Cane") {
    static uint8_t startIndex2 = 0;
    startIndex2 = startIndex2 + 1; /* higher = faster motion */

    fill_palette( leds2, NUM_LEDS2,
                  startIndex2, 16, /* higher = narrower stripes */
                  currentPalettestriped, 255, LINEARBLEND);
  }


  if (setEffect == "Cyclon Rainbow") {                    //Single Dot Down
  static uint8_t hue = 0;
  Serial.print("x");
  // First slide the led in one direction
  for(int i = 0; i < NUM_LEDS; i++) {
    // Set the i'th led to red 
    leds[i] = CHSV(hue++, 255, 255);
    // Show the leds
    FastLED.show(); 
    // now that we've shown the leds, reset the i'th led to black
    // leds[i] = CRGB::Black;
    fadeall();
    // Wait a little bit before we loop around and do it again
    delay(10);
  }
  for(int i = (NUM_LEDS)-1; i >= 0; i--) {
    // Set the i'th led to red 
    leds[i] = CHSV(hue++, 255, 255);
    // Show the leds
    FastLED.show();
    // now that we've shown the leds, reset the i'th led to black
    // leds[i] = CRGB::Black;
    fadeall();
    // Wait a little bit before we loop around and do it again
    delay(10);
  }
}

  if (setEffect2 == "Cyclon Rainbow") {                    //Single Dot Down
  static uint8_t hue2 = 0;
  Serial.print("x");
  // First slide the led in one direction
    for(int i = 0; i < NUM_LEDS2; i++) {
      // Set the i'th led to red 
      leds2[i] = CHSV(hue2++, 255, 255);
      // Show the leds
      FastLED.show(); 
      // now that we've shown the leds, reset the i'th led to black
      // leds[i] = CRGB::Black;
      fadeall();
      // Wait a little bit before we loop around and do it again
      delay(10);
    }
    for(int i = (NUM_LEDS2)-1; i >= 0; i--) {
      // Set the i'th led to red 
      leds2[i] = CHSV(hue2++, 255, 255);
      // Show the leds
      FastLED.show();
      // now that we've shown the leds, reset the i'th led to black
      // leds[i] = CRGB::Black;
      fadeall();
      // Wait a little bit before we loop around and do it again
      delay(10);
    }
  }

  if (setEffect == "Fire") { 
      Fire2012WithPalette();
  }

  if (setEffect2 == "Fire") { 
      Fire2012WithPalette2();
  }
     random16_add_entropy( random8());

  if (setEffect == "Valentines Day") {
    fill_solid(leds, NUM_LEDS, CRGB::DarkRed);   
  }
  
  if (setEffect2 == "Valentines Day") {
    fill_solid(leds2, 7, CRGB::DeepPink);
    fill_solid(leds2+7, 7, CRGB::DarkRed);
    fill_solid(leds2+14, 6, CRGB::DeepPink);
    fill_solid(leds2+20, 6, CRGB::DarkRed);
    fill_solid(leds2+26, 6, CRGB::DarkRed);
    fill_solid(leds2+32, 6, CRGB::DeepPink);
    fill_solid(leds2+38, 7, CRGB::DarkRed);
    fill_solid(leds2+45, 7, CRGB::DeepPink);   
  }

  if (setEffect == "Easter Sunday") {
    fill_solid(leds, NUM_LEDS, CRGB::DarkTurquoise);   
  }
  
  if (setEffect2 == "Easter Sunday") {
    fill_solid(leds2, 7, CRGB::Bisque);
    fill_solid(leds2+7, 7, CRGB::DarkTurquoise);
    fill_solid(leds2+14, 6, CRGB::MediumOrchid);
    fill_solid(leds2+20, 6, CRGB::Yellow);
    fill_solid(leds2+26, 6, CRGB::Yellow);
    fill_solid(leds2+32, 6, CRGB::MediumOrchid);
    fill_solid(leds2+38, 7, CRGB::DarkTurquoise);
    fill_solid(leds2+45, 7, CRGB::Bisque);   
  }

  if (setEffect == "Red, White, Blue") {
    fill_solid(leds, NUM_LEDS, CRGB::White);   
  }
  
  if (setEffect2 == "Red, White, Blue") {
    fill_solid(leds2, 26, CRGB(224, 22, 43));
    fill_solid(leds2+26, 26, CRGB(0, 82, 165));
  }

  if (setEffect == "Halloween") {
    fill_solid(leds, NUM_LEDS, CRGB::OrangeRed);   
  }
  
  if (setEffect2 == "Halloween") {
    fill_solid(leds2, NUM_LEDS2, CRGB::Purple);
  }

  if (setEffect == "Thanksgiving") {
    fill_solid(leds, NUM_LEDS, CRGB::OrangeRed);   
  }
  
  if (setEffect2 == "Thanksgiving") {
    fill_solid(leds2, 13, CRGB::SaddleBrown);
    fill_solid(leds2+13, 13, CRGB::DarkRed);
    fill_solid(leds2+26, 13, CRGB::DarkRed);
    fill_solid(leds2+39, 13, CRGB::SaddleBrown);   
  }

  if (setEffect == "Christmas Day") {
    fill_solid(leds, NUM_LEDS, CRGB(197, 164, 54));   
  }
  
  if (setEffect2 == "Christmas Day") {
    fill_solid(leds2, 13, CRGB(153, 33, 20));
    fill_solid(leds2+13, 13, CRGB(26, 49, 18));
    fill_solid(leds2+26, 13, CRGB(153, 33, 20));
    fill_solid(leds2+39, 13, CRGB(26, 49, 18));   
  }

  if (setEffect == "Star Wars") {
    fill_solid(leds, NUM_LEDS, CRGB(67, 224, 177));   
  }
  
  if (setEffect2 == "Star Wars") {
    fill_solid(leds2, 26, CRGB::DarkRed);
    fill_solid(leds2+26, 26, CRGB(107, 224, 68));
  }

  if (setEffect == "St. Patricks Day") {
    fill_solid(leds, NUM_LEDS, CRGB(0, 154, 73));   
  }
  
  if (setEffect2 == "St. Patricks Day") {
    fill_solid(leds2, NUM_LEDS2, CRGB(0, 154, 73));
  }

  
  
  EVERY_N_MILLISECONDS(10) {
    nblendPaletteTowardPalette(currentPalette, targetPalette, maxChanges);  // FOR NOISE ANIMATION
    { gHue++; }


    if (setEffect == "Noise") {
      setPower = "ON";
      for (int i = 0; i < NUM_LEDS; i++) {                                     // Just ONE loop to fill up the LED array as all of the pixels change.
        uint8_t index = inoise8(i * scale, dist + i * scale) % 255;            // Get a value from the noise function. I'm using both x and y axis.
        leds[i] = ColorFromPalette(currentPalette, index, 255, LINEARBLEND);   // With that value, look up the 8 bit colour palette value and assign it to the current LED.
      }
      dist += beatsin8(10, 1, 4);                                              // Moving along the distance (that random number we started out with). Vary it a bit with a sine wave.
      // In some sketches, I've used millis() instead of an incremented counter. Works a treat.
    }

    if (setEffect2 == "Noise") {
      setPower2 = "ON";
      for (int i = 0; i < NUM_LEDS2; i++) {                                     // Just ONE loop to fill up the LED array as all of the pixels change.
        uint8_t index2 = inoise8(i * scale, dist + i * scale) % 255;            // Get a value from the noise function. I'm using both x and y axis.
        leds2[i] = ColorFromPalette(currentPalette, index2, 255, LINEARBLEND);   // With that value, look up the 8 bit colour palette value and assign it to the current LED.
      }
      dist += beatsin8(10, 1, 4);                                              // Moving along the distance (that random number we started out with). Vary it a bit with a sine wave.
      // In some sketches, I've used millis() instead of an incremented counter. Works a treat.
    }


    if (setEffect == "Ripple") {
      for (int i = 0; i < NUM_LEDS; i++) leds[i] = CHSV(bgcol++, 255, 15);  // Rotate background colour.
      switch (step) {
        case -1:                                                          // Initialize ripple variables.
          center = random(NUM_LEDS);
          colour = random8();
          step = 0;
          break;
        case 0:
          leds[center] = CHSV(colour, 255, 255);                          // Display the first pixel of the ripple.
          step ++;
          break;
        case maxsteps:                                                    // At the end of the ripples.
          step = -1;
          break;
        default:                                                             // Middle of the ripples.
          leds[(center + step + NUM_LEDS) % NUM_LEDS] += CHSV(colour, 255, myfade / step * 2);   // Simple wrap from Marc Miller
          leds[(center - step + NUM_LEDS) % NUM_LEDS] += CHSV(colour, 255, myfade / step * 2);
          step ++;                                                         // Next step.
          break;
      }
    }

    if (setEffect2 == "Ripple") {
      for (int i = 0; i < NUM_LEDS2; i++) leds2[i] = CHSV(bgcol++, 255, 15);  // Rotate background colour.
      switch (step) {
        case -1:                                                          // Initialize ripple variables.
          center = random(NUM_LEDS2);
          colour = random8();
          step = 0;
          break;
        case 0:
          leds2[center] = CHSV(colour, 255, 255);                          // Display the first pixel of the ripple.
          step ++;
          break;
        case maxsteps:                                                    // At the end of the ripples.
          step = -1;
          break;
        default:                                                             // Middle of the ripples.
          leds2[(center + step + NUM_LEDS2) % NUM_LEDS2] += CHSV(colour, 255, myfade / step * 2);   // Simple wrap from Marc Miller
          leds2[(center - step + NUM_LEDS2) % NUM_LEDS2] += CHSV(colour, 255, myfade / step * 2);
          step ++;                                                         // Next step.
          break;
      }
    }

    
  }

  EVERY_N_SECONDS(5) {
    targetPalette = CRGBPalette16(CHSV(random8(), 255, random8(128, 255)), CHSV(random8(), 255, random8(128, 255)), CHSV(random8(), 192, random8(128, 255)), CHSV(random8(), 255, random8(128, 255)));
  }

  FastLED.setBrightness(brightness);  //EXECUTE EFFECT COLOR
  FastLED.setBrightness(brightness2);  //EXECUTE EFFECT COLOR
  FastLED.show();

  if (animationspeed > 0 && animationspeed < 150) {  //Sets animation speed based on receieved value
    FastLED.delay(1000 / animationspeed);
  }

  if (animationspeed2 > 0 && animationspeed2 < 150) {  //Sets animation speed based on receieved value
    FastLED.delay(1000 / animationspeed2);
  }

}



void setupStripedPalette( CRGB A, CRGB AB, CRGB B, CRGB BA)
{
  currentPalettestriped = CRGBPalette16(
                            A, A, A, A, A, A, A, A, B, B, B, B, B, B, B, B
                            //    A, A, A, A, A, A, A, A, B, B, B, B, B, B, B, B
                          );
}


void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } } //for CYCLON

void fadeall2 () { for(int i = 0; i < NUM_LEDS2; i++) { leds2[i].nscale8(250); } } //for CYCLON


void Fire2012WithPalette()
{
// Array of temperature readings at each simulation cell
  static byte heat[NUM_LEDS];

  // Step 1.  Cool down every cell a little
    for( int i = 0; i < NUM_LEDS; i++) {
      heat[i] = qsub8( heat[i],  random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
    }
  
    // Step 2.  Heat from each cell drifts 'up' and diffuses a little
    for( int k= NUM_LEDS - 1; k >= 2; k--) {
      heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
    }
    
    // Step 3.  Randomly ignite new 'sparks' of heat near the bottom
    if( random8() < SPARKING ) {
      int y = random8(7);
      heat[y] = qadd8( heat[y], random8(160,255) );
    }

    // Step 4.  Map from heat cells to LED colors
    for( int j = 0; j < NUM_LEDS; j++) {
      // Scale the heat value from 0-255 down to 0-240
      // for best results with color palettes.
      byte colorindex = scale8( heat[j], 240);
      CRGB color = ColorFromPalette( gPal, colorindex);
      int pixelnumber;
      if( gReverseDirection ) {
        pixelnumber = (NUM_LEDS-1) - j;
      } else {
        pixelnumber = j;
      }
      leds[pixelnumber] = color;
    }
}

void Fire2012WithPalette2()
{
// Array of temperature readings at each simulation cell
  static byte heat[NUM_LEDS2];

  // Step 1.  Cool down every cell a little
    for( int i = 0; i < NUM_LEDS2; i++) {
      heat[i] = qsub8( heat[i],  random8(0, ((COOLING * 10) / NUM_LEDS2) + 2));
    }
  
    // Step 2.  Heat from each cell drifts 'up' and diffuses a little
    for( int k= NUM_LEDS2 - 1; k >= 2; k--) {
      heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
    }
    
    // Step 3.  Randomly ignite new 'sparks' of heat near the bottom
    if( random8() < SPARKING ) {
      int y = random8(7);
      heat[y] = qadd8( heat[y], random8(160,255) );
    }

    // Step 4.  Map from heat cells to LED colors
    for( int j = 0; j < NUM_LEDS2; j++) {
      // Scale the heat value from 0-255 down to 0-240
      // for best results with color palettes.
      byte colorindex = scale8( heat[j], 240);
      CRGB color = ColorFromPalette( gPal, colorindex);
      int pixelnumber;
      if( gReverseDirection ) {
        pixelnumber = (NUM_LEDS2-1) - j;
      } else {
        pixelnumber = j;
      }
      leds2[pixelnumber] = color;
    }
}


void addGlitter( fract8 chanceOfGlitter) 
{
  if( random8() < chanceOfGlitter) {
    leds[ random16(NUM_LEDS) ] += CRGB::White;
  }
}

void addGlitter2( fract8 chanceOfGlitter) 
{
  if( random8() < chanceOfGlitter) {
    leds2[ random16(NUM_LEDS2) ] += CRGB::White;
  }
}

void addGlitterColor( fract8 chanceOfGlitter, int Rcolor, int Gcolor, int Bcolor) 
{
  if( random8() < chanceOfGlitter) {
    leds[ random16(NUM_LEDS) ] += CRGB(Rcolor, Gcolor, Bcolor);
  }
}

void addGlitterColor2( fract8 chanceOfGlitter, int Rcolor2, int Gcolor2, int Bcolor2) 
{
  if( random8() < chanceOfGlitter) {
    leds2[ random16(NUM_LEDS2) ] += CRGB(Rcolor2, Gcolor2, Bcolor2);
  }
}


void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
  if (client.connect("LivingRoomTVLEDs", mqtt_user, mqtt_password)) {
      Serial.println("connected");

      FastLED.clear (); //Turns off startup LEDs after connection is made
      FastLED.show();

      client.subscribe(setcolorsub);
      client.loop();
      client.subscribe(setbrightness);
      client.loop();
//      client.subscribe(setcolortemp);
//      client.loop();
      client.subscribe(setpowersub);
      client.loop();
      client.subscribe(seteffectsub);
      client.loop();
      client.subscribe(setanimationspeed);
      client.loop();

      client.subscribe(setcolorsub2);
      client.loop();
      client.subscribe(setbrightness2);
      client.loop();
//      client.subscribe(setcolortemp2);
//      client.loop();
      client.subscribe(setpowersub2);
      client.loop();
      client.subscribe(seteffectsub2);
      client.loop();
      client.subscribe(setanimationspeed2);
      client.loop();
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}

again i thx a lot. o work a lot but this night i will put this code in my NodeMcu Amica and i told you how is work. But is totaly different for code of bruth. i think that you codee will work.
I have 4m of led w8211 …240led and i have surce pover 12v 30A and i want to put him in my kitchen like only one strip led. i will modifify your code only for one strip.

If i ask you for config. yaml for this strip and automation can you send me this config. ¿¿¿ please.

again i thank you a lot. i dont believe that you help me. thx a lot.
did you have an email a twitter¿¿¿

If i install in my kitchen i will change ¨ livingroom¨ with ¨ cocina(its mean kitchen)¨ , that is correct¿¿¿¿
like this:

#define colorstatuspub2 “home/cocina/cabinetleds/colorstatus”
#define setcolorsub2 “home/cocina/cabinetleds/setcolor”
#define setpowersub2 “home/cocina/cabinetleds/setpower”
#define seteffectsub2 “home/cocina/cabinetleds/seteffect”
#define setbrightness2 “home/cocina/cabinetleds/setbrightness”

#define setcolorpub2 “home/cocina/cabinetleds/setcolorpub”
#define setpowerpub2 “home/cocina/cabinetleds/setpowerpub”
#define seteffectpub2 “home/cocina/cabinetleds/seteffectpub”
#define setbrightnesspub2 “home/cocina/cabinetleds/setbrightnesspub”
#define setanimationspeed2 “home/cocina/cabinetleds/setanimationspeed”

Beware @danielaradu2016 - most Ws2811 chips are 5v not 12v!!

Make sure you check that before hooking up!

grangemd

I dont have pacience and i install it . and he work. i told you that your code is diffenrent . thx a lot.
again thx a lot

i will see for one strip how i change it if not i will let him like you.
thx a lot

its connect my mqtt server and my wifi
thx a lot

phileep

in my strip i see 12v Din GND
i think that is 12V
I have another and you have right because a see 5V DinIn DinOut GND.
thx for told me

Hy Grangemd

i will hope that you can help me with config yaml. i built all electrical circuit and when i conect to switch the led strip take color red for 5 second and after is off.
i think that its ok.
i conect only d5 and all strip led 5m. i change the code with 300led not 52 like you
mqtt topics is same like you code because i will change in customize of HA the name of led.

Hy Grangemd

All night i was intent to build the config.yaml for ledstrip but is imposible
i modificated config.yaml of bruth but dont work it.

Can you help me with your config.yaml for ledstrip animacion??
Thx a lot

Hope this helps. Sorry I am busy on the weekends and don’'t have a lot of time to post.

input_select.yaml file

living_room_led_effect:
  name: Living Room LED Effect
  options:
   - "BPM"
   - "Candy Cane"
   - "Christmas Day"
   - "Confetti"
   - "Cyclon Rainbow"
   - "Dots"
   - "Easter Sunday"
   - "Fire"
   - "Glitter"
   - "Halloween"
   - "Juggle"
   - "Lightning"
   - "Noise"
   - "Police All"
   - "Police One"
   - "Rainbow"
   - "Rainbow with Glitter"
   - "Red, White, Blue"
   - "Ripple"
   - "Sinelon"
   - "Solid"
   - "Star Wars"
   - "St. Patricks Day"
   - "Thanksgiving"
   - "Twinkle"
   - "Valentines Day"
  initial: "Solid"

input_slider.yaml

living_room_animation_speed:
  name: Living Room Cabinet Animation Speed
  initial: 150
  min: 1
  max: 150
  step: 1

automation.yaml

- alias: "Living Room TV Input Effect"
  initial_state: True
  hide_entity: True
  trigger:
    - platform: state
      entity_id: input_select.tv_led_effect
  action:
    - service: mqtt.publish
      data_template:
        topic: "home/livingroom/tvleds/seteffect"
        payload: '{{ trigger.to_state.state | string }}'

- alias: "Living Room TV Animation Speed"
  initial_state: True
  hide_entity: True
  trigger:
    - platform: state
      entity_id: input_slider.tv_animation_speed
  action:
    - service: mqtt.publish
      data_template:
        topic: "home/livingroom/tvleds/setanimationspeed"
        payload: '{{ trigger.to_state.state | int }}'

- alias: "Living Room Cabinet Input Effect"
  initial_state: True
  hide_entity: True
  trigger:
    - platform: state
      entity_id: input_select.living_room_led_effect
  action:
    - service: mqtt.publish
      data_template:
        topic: "home/livingroom/cabinetleds/seteffect"
        payload: '{{ trigger.to_state.state | string }}'

- alias: "Living Room Cabinet Animation Speed"
  initial_state: True
  hide_entity: True
  trigger:
    - platform: state
      entity_id: input_slider.living_room_animation_speed
  action:
    - service: mqtt.publish
      data_template:
        topic: "home/livingroom/cabinetleds/setanimationspeed"
        payload: '{{ trigger.to_state.state | int }}'

Hy Grangemd

i have all day work of this. before you send me that i just build this files what you send me but i have one more and that is mqtt. is like :

  platform: mqtt

name: “Porch LEDs”
command_topic: “home/livingroom/tvleds/setpower”
state_topic: “home/livingroom/tvleds/setpowerpub”
rgb_state_topic: “home/livingroom/tvleds/setcolorpub”
rgb_command_topic: “home/livingroom/tvleds/setcolor”
brightness_state_topic: “home/livingroom/tvleds/setbrightnesspub”
brightness_command_topic: “home/livingroom/tvleds/setbrightness”
#color_temp_state_topic: “home/livingroom/tvleds/setcolortemppub”
#color_temp_command_topic: “home/livingroom/tvleds/setcolortemp”

optimistic: false

and dont want to work.

i buil electrical scheme and i put only d5 with data of stripled.
but dont work

Can you think that i was wrong with electrical circuit. I just change num of led and i put only 240.
can you help me?? plz

the scheme of electrical i just use that.

I changed the pinD5 with pinD6 and I have removed the Logic Level Shifter. But it does not work in any way. With scaner port I can see that the nodemcu is connected but I do not know how I can see if it is connected to my mqtt server.

my automation is like this.

  • alias: “Living Room TV Animation Speed”
    initial_state: True
    hide_entity: True
    trigger:

    • platform: state
      entity_id: input_slider.living_room_animation_speed
      action:
    • service: mqtt.publish
      data_template:
      topic: “home/livingroom/tvleds/setanimationspeed”
      payload: ‘{{ trigger.to_state.state | int }}’
  • alias: “Living Room TV Input Effect”
    initial_state: True
    hide_entity: True
    trigger:

    • platform: state
      entity_id: input_select.living_room_led_effect
      action:
    • service: mqtt.publish
      data_template:
      topic: “home/livingroom/tvleds/seteffect”
      payload: ‘{{ trigger.to_state.state | string }}’

So when the device was turned on and all the LEDs turned red that was what was supposed to happen. They turn off when they are connected to the MQTT server. I don’t know how you are doing the automations. I would start out doing two separate automation files.

First one:

- alias: "Living Room TV Input Effect"
  initial_state: True
  hide_entity: True
  trigger:
    - platform: state
      entity_id: input_select.tv_led_effect
  action:
    - service: mqtt.publish
      data_template:
        topic: "home/livingroom/tvleds/seteffect"
        payload: '{{ trigger.to_state.state | string }}'

second one:

- alias: "Living Room TV Animation Speed"
  initial_state: True
  hide_entity: True
  trigger:
    - platform: state
      entity_id: input_slider.tv_animation_speed
  action:
    - service: mqtt.publish
      data_template:
        topic: "home/livingroom/tvleds/setanimationspeed"
        payload: '{{ trigger.to_state.state | int }}'

The Light.yaml file should look as follows:

- platform: mqtt
  name: "Living Room TV LEDs"
  command_topic: "home/livingroom/tvleds/setpower"
  state_topic: "home/livingroom/tvleds/setpowerpub"
  rgb_state_topic: "home/livingroom/tvleds/setcolorpub"
  rgb_command_topic: "home/livingroom/tvleds/setcolor"
  brightness_state_topic: "home/livingroom/tvleds/setbrightnesspub"
  brightness_command_topic: "home/livingroom/tvleds/setbrightness"
  optimistic: false

I don’t have a wiring diagram off the top of my head but it should be simple and i think that one looks correct.

i change all like you send me.
the led blue of nodemcu is on but my led strip dont work.
can i put again Logic Level Shifter ??
i have to cut the stripled if i change de code for 240leds?? o i leave him like new (5m…300leds).

Nodemcu i use pin D6.