ESPHome Christmas Effect

Hey guys,

Im trying to add a second ESPhome effect to some lights, but getting this error.

ERROR Error while reading config: Invalid YAML syntax:

while parsing a block collection
  in "/config/esphome/printer-lamp.yaml", line 47, column 8:
           - lambda:
           ^
expected <block end>, but found '<block sequence start>'
  in "/config/esphome/printer-lamp.yaml", line 76, column 9:
            - lambda:
            ^

From what I can find of people having multiple effects, Im doing it right. So whats the issue?

    effects:
       - lambda:
           name: "Breathing Red"
           update_interval: 16s #Finetune to your liking with the transition lenght below
           lambda: |-
            #define Color1 1.0, 0.0, 0.0 //These are the colors defined, feel free to change or extend the list
                                         //if you extend the list, dont forget to add them in the switch loop below
                                         //and remember to adjust the reset counter at the bottom
            static int state = 0;
            static int color = 1;
            auto call = id(printer_lamp).turn_on(); //put the id for your light in here
            call.set_transition_length(15000);
            if (state == 0) 
            {
             call.set_brightness(0.01);
             
            }
             else if (state == 1)
            {
              call.set_rgb(Color1); 
              call.set_brightness(1.0);
            }
             
             state ++;
             if (state == 2){
             state = 0;
             }
             call.perform();
        
        
        - lambda:
           name: RGB Breathing
           update_interval: 16s #Finetune to your liking with the transition lenght below
           lambda: |-
            #define Color1 1.0, 0.0, 0.0 //These are the colors defined, feel free to change or extend the list
            #define Color2 1.0, 0.5, 0.0 //if you extend the list, dont forget to add them in the switch loop below
            #define Color3 1.0, 1.0, 0.0 //and remember to adjust the reset counter at the bottom
            #define Color4 0.5, 1.0, 0.0
            #define Color5 0.0, 1.0, 0.0
            #define Color6 0.0, 1.0, 0.5
            #define Color7 0.0, 1.0, 1.0
            #define Color8 0.0, 0.5, 1.0
            #define Color9 0.0, 0.0, 1.0
            #define Color10 0.5, 0.0, 1.0
            #define Color11 0.5, 0.0, 1.0
            #define Color12 1.0, 0.0, 0.5
            static int state = 0;
            static int color = 1;
            auto call = id(frontfan).turn_on(); //put the id for your light in here
            call.set_transition_length(15000);
            if (state == 0) 
            {
             call.set_brightness(0.01);
             
            }
             else if (state == 1)
            {
               switch(color)
               {
                 case 1: call.set_rgb(Color1);
                         break;
                 case 2: call.set_rgb(Color2);
                         break;
                 case 3: call.set_rgb(Color3);
                         break;
                 case 4: call.set_rgb(Color4);
                         break;
                 case 5: call.set_rgb(Color5);
                         break;
                 case 6: call.set_rgb(Color6);
                         break;
                 case 7: call.set_rgb(Color7);
                         break;
                 case 8: call.set_rgb(Color8);
                         break;
                 case 9: call.set_rgb(Color9);
                         break;
                 case 10: call.set_rgb(Color10);
                          break;
                 case 11: call.set_rgb(Color11);
                          break;
                 case 12: call.set_rgb(Color12);
                          break;
               }
              call.set_brightness(1.0);
            }
             
             state ++;
             if (state == 2){
             state = 0;
             }
             color++;
             if(color == 7)
             {
               color = 1;
             }
             call.perform();

Thanks guys

Ok I needed a } to close it off and I had the wrong indentation for it initially, fixed that.

    effects:
       - lambda:
           name: Breathing Red
           update_interval: 16s #Finetune to your liking with the transition lenght below
           lambda: |-
            #define Color1 1.0, 0.0, 0.0 //These are the colors defined, feel free to change or extend the list
                                         //if you extend the list, dont forget to add them in the switch loop below
                                         //and remember to adjust the reset counter at the bottom
            static int state = 0;
            static int color = 1;
            auto call = id(printer_lamp).turn_on(); //put the id for your light in here
            call.set_transition_length(15000);
            if (state == 0) 
            {
             call.set_brightness(0.01);
             
            }
             else if (state == 1)
            {
              call.set_rgb(Color1); 
              call.set_brightness(1.0);
            }
             
             state ++;
             if (state == 2){
             state = 0;
             }
             call.perform();
             }
        
        
       - lambda:
           name: Christmas
           update_interval: 16s #Finetune to your liking with the transition lenght below
           lambda: |-
            #define Color1 1.0, 0.0, 0.0 //These are the colors defined, feel free to change or extend the list
            #define Color2 0.0, 1.0, 0.0 //if you extend the list, dont forget to add them in the switch loop below
                                         //and remember to adjust the reset counter at the bottom

            static int state = 0;
            static int color = 1;
            auto call = id(printer_lamp).turn_on(); //put the id for your light in here
            call.set_transition_length(15000);
            if (state == 0) 
            {
             call.set_brightness(0.01);
             
            }
             else if (state == 1)
            {
               switch(color)
               {
                 case 1: call.set_rgb(Color1);
                         break;
                 case 2: call.set_rgb(Color2);
                         break;
               }
              call.set_brightness(1.0);
            }
             
             state ++;
             if (state == 2){
             state = 0;
             }
             color++;
             if(color == 2)
             {
               color = 1;
             }
             call.perform();

But now im getting;

/config/esphome/printer-lamp.yaml: In function 'void setup()':
/config/esphome/printer-lamp.yaml:75:3: error: expected ')' before '}' token
         
   ^
/config/esphome/printer-lamp.yaml:75:3: error: no matching function for call to 'esphome::light::LambdaLightEffect::LambdaLightEffect()'
/config/esphome/printer-lamp.yaml:75:3: note: candidates are:
In file included from src/esphome.h:23:0,
                 from src/main.cpp:3:
src/esphome/components/light/base_light_effects.h:105:3: note: esphome::light::LambdaLightEffect::LambdaLightEffect(const string&, std::function<void()>, uint32_t)
   LambdaLightEffect(const std::string &name, std::function<void()> f, uint32_t update_interval)
   ^
src/esphome/components/light/base_light_effects.h:105:3: note:   candidate expects 3 arguments, 0 provided
src/esphome/components/light/base_light_effects.h:103:7: note: esphome::light::LambdaLightEffect::LambdaLightEffect(const esphome::light::LambdaLightEffect&)
 class LambdaLightEffect : public LightEffect {
       ^
src/esphome/components/light/base_light_effects.h:103:7: note:   candidate expects 1 argument, 0 provided
src/esphome/components/light/base_light_effects.h:103:7: note: esphome::light::LambdaLightEffect::LambdaLightEffect(esphome::light::LambdaLightEffect&&)
src/esphome/components/light/base_light_effects.h:103:7: note:   candidate expects 1 argument, 0 provided
/config/esphome/printer-lamp.yaml:75:3: error: expected ';' before '}' token
         
   ^
/config/esphome/printer-lamp.yaml: At global scope:
/config/esphome/printer-lamp.yaml:75:4: error: mixing declarations and function-definitions is forbidden
         
    ^
/config/esphome/printer-lamp.yaml:75:6: error: expected unqualified-id before numeric constant
         
      ^
/config/esphome/printer-lamp.yaml:76:3: error: 'light_lambdalighteffect_2' does not name a type
         
   ^
/config/esphome/printer-lamp.yaml:116:4: error: expected unqualified-id before ',' token
     
    ^
/config/esphome/printer-lamp.yaml:116:6: error: expected unqualified-id before numeric constant
     
      ^
/config/esphome/printer-lamp.yaml:117:3: error: 'printer_lamp' does not name a type
 output:
   ^
/config/esphome/printer-lamp.yaml:117:81: error: expected unqualified-id before ')' token
 output:
                                                                                 ^
/config/esphome/printer-lamp.yaml:135:3: error: 'pwm_r' does not name a type
     frequency: 1000 Hz
   ^
/config/esphome/printer-lamp.yaml:136:3: error: 'pwm_r' does not name a type
     id: pwm_w
   ^
/config/esphome/printer-lamp.yaml:137:3: error: 'App' does not name a type
/config/esphome/printer-lamp.yaml:138:3: error: 'pwm_r' does not name a type
/config/esphome/printer-lamp.yaml:139:3: error: 'esphome_esp8266_esp8266gpiopin' does not name a type
/config/esphome/printer-lamp.yaml:140:3: error: 'esphome_esp8266_esp8266gpiopin' does not name a type
/config/esphome/printer-lamp.yaml:141:3: error: 'esphome_esp8266_esp8266gpiopin' does not name a type
/config/esphome/printer-lamp.yaml:142:3: error: 'esphome_esp8266_esp8266gpiopin' does not name a type
/config/esphome/printer-lamp.yaml:143:3: error: 'pwm_r' does not name a type
/config/esphome/printer-lamp.yaml:144:3: error: 'pwm_r' does not name a type
/config/esphome/printer-lamp.yaml:161:3: error: 'pwm_g' does not name a type
/config/esphome/printer-lamp.yaml:162:3: error: 'pwm_g' does not name a type
/config/esphome/printer-lamp.yaml:163:3: error: 'App' does not name a type
/config/esphome/printer-lamp.yaml:164:3: error: 'pwm_g' does not name a type
/config/esphome/printer-lamp.yaml:165:3: error: 'esphome_esp8266_esp8266gpiopin_2' does not name a type
/config/esphome/printer-lamp.yaml:166:3: error: 'esphome_esp8266_esp8266gpiopin_2' does not name a type
/config/esphome/printer-lamp.yaml:167:3: error: 'esphome_esp8266_esp8266gpiopin_2' does not name a type
/config/esphome/printer-lamp.yaml:168:3: error: 'esphome_esp8266_esp8266gpiopin_2' does not name a type
/config/esphome/printer-lamp.yaml:169:3: error: 'pwm_g' does not name a type
/config/esphome/printer-lamp.yaml:170:3: error: 'pwm_g' does not name a type
/config/esphome/printer-lamp.yaml:187:3: error: 'pwm_b' does not name a type
/config/esphome/printer-lamp.yaml:188:3: error: 'pwm_b' does not name a type
/config/esphome/printer-lamp.yaml:189:3: error: 'App' does not name a type
/config/esphome/printer-lamp.yaml:190:3: error: 'pwm_b' does not name a type
/config/esphome/printer-lamp.yaml:191:3: error: 'esphome_esp8266_esp8266gpiopin_3' does not name a type
/config/esphome/printer-lamp.yaml:192:3: error: 'esphome_esp8266_esp8266gpiopin_3' does not name a type
/config/esphome/printer-lamp.yaml:193:3: error: 'esphome_esp8266_esp8266gpiopin_3' does not name a type
/config/esphome/printer-lamp.yaml:194:3: error: 'esphome_esp8266_esp8266gpiopin_3' does not name a type
/config/esphome/printer-lamp.yaml:195:3: error: 'pwm_b' does not name a type
/config/esphome/printer-lamp.yaml:196:3: error: 'pwm_b' does not name a type
/config/esphome/printer-lamp.yaml:213:3: error: 'pwm_w' does not name a type
/config/esphome/printer-lamp.yaml:214:3: error: 'pwm_w' does not name a type
/config/esphome/printer-lamp.yaml:215:3: error: 'App' does not name a type
/config/esphome/printer-lamp.yaml:216:3: error: 'pwm_w' does not name a type
/config/esphome/printer-lamp.yaml:217:3: error: 'esphome_esp8266_esp8266gpiopin_4' does not name a type
/config/esphome/printer-lamp.yaml:218:3: error: 'esphome_esp8266_esp8266gpiopin_4' does not name a type
/config/esphome/printer-lamp.yaml:219:3: error: 'esphome_esp8266_esp8266gpiopin_4' does not name a type
/config/esphome/printer-lamp.yaml:220:3: error: 'esphome_esp8266_esp8266gpiopin_4' does not name a type
/config/esphome/printer-lamp.yaml:221:3: error: 'pwm_w' does not name a type
/config/esphome/printer-lamp.yaml:222:3: error: 'pwm_w' does not name a type
/config/esphome/printer-lamp.yaml:228:3: error: 'mdns_mdnscomponent' does not name a type
/config/esphome/printer-lamp.yaml:229:3: error: 'mdns_mdnscomponent' does not name a type
/config/esphome/printer-lamp.yaml:230:3: error: 'App' does not name a type
/config/esphome/printer-lamp.yaml:231:3: error: 'rgbw_rgbwlightoutput' does not name a type
/config/esphome/printer-lamp.yaml:232:3: error: 'rgbw_rgbwlightoutput' does not name a type
/config/esphome/printer-lamp.yaml:233:3: error: 'rgbw_rgbwlightoutput' does not name a type
/config/esphome/printer-lamp.yaml:234:3: error: 'rgbw_rgbwlightoutput' does not name a type
/config/esphome/printer-lamp.yaml:235:3: error: 'rgbw_rgbwlightoutput' does not name a type
/config/esphome/printer-lamp.yaml:237:3: error: 'App' does not name a type
/config/esphome/printer-lamp.yaml:238:1: error: expected declaration before '}' token
*** [/data/printer-lamp/.pioenvs/printer-lamp/src/main.cpp.o] Error 1
========================== [FAILED] Took 1.60 seconds ==========================

EDIT: So after removing the second effect and putting back to default. Im still getting the same errors.

Has something changed in ESPhome?

The braces in your first lambda are mismatched, there’s one more }.