Trouble with "on_boot" for esphome

hi all,

i have a rgb light pannel using leds, i have a magic light rgb wifi controller reflashed to use esphome.

what I want to do is have the light cycle through red,green and blue, then settle on a custom colour every time the 12v power supply is plugged in. this would give me a visual indicator that the leds are still opperational, and that the controller is powering up…

the ideal option would be that the panel lights up red on power up, blue on searching for wifi, green on connecting to wifi and settles on a custom set colour after a few seconds, but in my mind this is a whole lot harder.

any help would be greatly accepted… this is what i have so far…

esphome:
  name: emergency_light
  platform: ESP8266
  board: esp01_1m
  on_boot:
    priority: 550.0
    switch.turn_on: emergency_light
    colors:
    - state: true
      brightness: 100%
      red: 100%
      green: 0%
      blue: 0%

yet when i try to validate i get this message

INFO Reading configuration...
Failed config

esphome: [source /config/esphome/emergency_light.yaml:2]
  name: emergency_light
  platform: ESP8266
  board: esp01_1m
  on_boot:  [source /config/esphome/emergency_light.yaml:6]
    
    Unable to find action with the name 'priority'.
    priority: 550.0 [source /config/esphome/emergency_light.yaml:6]
    switch.turn_on: emergency_light
    colors: 
      - state: True
        brightness: 100%
        red: 100%
        green: 0%
        blue: 0%

ive checked my spelling and as far as i can see its all correct… obviously i’m missing something though and I was hoping that a fresh set of eyes may be able to spot it

thank you for all and any help

Not sure if this is the problem, but looking at examples, after priority is a then:
So you would have something like:

esphome:
  name: emergency_light
  platform: ESP8266
  board: esp01_1m
  on_boot:
    priority: 550.0
    then:
      - switch.turn_on: emergency_light
        colors:
          - state: true
            brightness: 100%
            red: 100%
            green: 0%
            blue: 0%

Double check the indentation… I might have screwed up somewhere in there… but all the examples I found had a ‘then’ after the priority… The error message doesn’t seem to point to that, but examples do - give it a try!

BTW: what component are you using for emergency_light?
I am trying to find the “colors” and can’t find what component it is in.

Cheers!
DeadEnd

thanks DeadEnd

I’ve added the changes you mentioned and changed my indentation but still getting errors…


INFO Reading configuration...
Failed config

esphome: [source /config/esphome/emergency_light.yaml:2]
  name: emergency_light
  platform: ESP8266
  board: esp01_1m
  on_boot:  [source /config/esphome/emergency_light.yaml:6]
    priority: -100.0
    then: 
      - [source /config/esphome/emergency_light.yaml:8]
        
        Unable to find action with the name 'switch.turn_on'.
        switch.turn_on: emergency_light [source /config/esphome/emergency_light.yaml:8]
        colors: 
          - state: True
            brightness: 100%
            red: 100%
            green: 0%
            blue: 0%

thank you

Can you please paste in the code for the components?
I think you are mix and matching automation with component…

I found the colors I asked about, but it is buried in light automation effects (from esphome.io):

light:
  - platform: ...
    # ...
    effects:
      - addressable_color_wipe:
      - addressable_color_wipe:
          name: Color Wipe Effect With Custom Values
          colors:
            - red: 100%
              green: 100%
              blue: 100%
              num_leds: 1
            - red: 0%
              green: 0%
              blue: 0%
              num_leds: 1
          add_led_interval

Is your component a light or a switch?
Or is there a switch that controls the light?
The relevant parts of your yaml will help a lot - thanks!

hi DeadEnd

thank you for your help, below is the entire contents of the yaml file for the controller.

esphome:
  name: emergency_light
  platform: ESP8266
  board: esp01_1m
  on_boot:
    priority: -100.0
    then:
      - switch.turn_on: emergency_light
        colors:
        - state: true
          brightness: 100%
          red: 100%
          green: 0%
          blue: 0%
      

wifi:
  ssid: !secret ssid
  password: !secret password
  manual_ip:
    static_ip: 192.168.0.5
    gateway: 192.168.0.1
    subnet: 255.255.255.0

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:


sensor:
  - platform: wifi_signal
    name: "Emergency light WiFi Signal"
    update_interval: 600s

  - platform: uptime
    name: "Emergency Light uptime"
    filters:
      - lambda: return (x/60)/60;
    unit_of_measurement: "Hrs"
    update_interval: 600s

text_sensor:
  - platform: version
    name: "Emergency Light ESPHome version"

light:
  - platform: rgb
    name: "Emergency light"
    red: red
    green: green
    blue: blue
    effects:
      - strobe:
          name: Emergency signal
          colors:
            - state: true
              brightness: 100%
              red: 100%
              green: 0%
              blue: 0%
              duration: 500ms
            - state: true
              brightness: 100%
              red: 0%
              green: 0%
              blue: 100%
              duration: 500ms


output:
  - platform: esp8266_pwm
    id: red
    pin: GPIO05
  - platform: esp8266_pwm
    id: green
    pin: GPIO12
  - platform: esp8266_pwm
    id: blue
    pin: GPIO13

hope that helps,

ive been trying to piece together things that i found while doing searching, though i guess i have quite a bit mixed up huh?

Okay - here’s what I think you’re missing (still learning):

  1. Your light component doesn’t have an ID, I believe that is a requirement to be used in automation within the esp module.

  2. The on_boot you are calling for a switch, but your RGB is actually a light - so you need to use this when calling it.

  3. The “colors” and “state” you are using in the automation appear to be specific to certain automations (strobe and color wipe) - so I think this can be removed.

So here’s my guess at what it should look like:

esphome:
  name: emergency_light
  platform: ESP8266
  board: esp01_1m
  on_boot:
    priority: -100.0
    then:
      - light.turn_on:
          id: emergency_light
          brightness: 100%
          red: 100%
          green: 0%
          blue: 0%
      

wifi:
  ssid: !secret ssid
  password: !secret password
  manual_ip:
    static_ip: 192.168.0.5
    gateway: 192.168.0.1
    subnet: 255.255.255.0

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:


sensor:
  - platform: wifi_signal
    name: "Emergency light WiFi Signal"
    update_interval: 600s

  - platform: uptime
    name: "Emergency Light uptime"
    filters:
      - lambda: return (x/60)/60;
    unit_of_measurement: "Hrs"
    update_interval: 600s

text_sensor:
  - platform: version
    name: "Emergency Light ESPHome version"

light:
  - platform: rgb
    name: "Emergency light"
    id: emergency_light
    red: red
    green: green
    blue: blue
    effects:
      - strobe:
          name: Emergency signal
          colors:
            - state: true
              brightness: 100%
              red: 100%
              green: 0%
              blue: 0%
              duration: 500ms
            - state: true
              brightness: 100%
              red: 0%
              green: 0%
              blue: 100%
              duration: 500ms


output:
  - platform: esp8266_pwm
    id: red
    pin: GPIO05
  - platform: esp8266_pwm
    id: green
    pin: GPIO12
  - platform: esp8266_pwm
    id: blue
    pin: GPIO13

summary:

  1. Add an ID to your light
  2. Change your on_boot from switch to light
  3. remove color and state, add ID as values within the light.turn_on.

Hopefully that gets the first step working - I know you want to do more - once you get this base working, I think adding the second and third color during boot will be trivial as you just duplicate what is working and change the priority and color.

Cheers!
DeadEnd

2 Likes

DeadEnd you are a legend!!!

that has worked perfectly! and like you say, now that i can see where i went wrong i can build on that and try to get the rest working… i just need to work out how to detect when the wifi is searching for a connection and when it has found one. but i’ll ponder over that for now and try to work it out.

once again though, thank you so much for your help :slight_smile: you are a true legend!!

I think if you want to add another priority, you have to add a dash for each priority to generate the list.
The wifi component has an automation for on connection:

esphome:
  name: emergency_light
  platform: ESP8266
  board: esp01_1m
  on_boot:
    - priority: 300.0 # after sensor setup, before WIFI initialization 
      then:
        - light.turn_on:
            id: emergency_light
            brightness: 100%
            red: 100%
            green: 0%
            blue: 0%
    - priority: 225.0 # after WIFI initialization
      then:
        - light.turn_on:
            id: emergency_light
            brightness: 100%
            red: 0%
            green: 0%
            blue: 100%
    - priority: -100.0 # everything is initialized, system is online - if condition waits for connection
      then:
        if:
          condition:
            wifi.connected:
          then:
            - light.turn_on:
                id: emergency_light
                brightness: 100%
                red: 0%
                green: 100%
                blue: 0%

That’s a lot of stuff… I don’t doubt I could have mistyped / copy-pasted something.
BUT it should be pretty close :wink: to what your original request was…

  • red on startup
  • blue on wifi initialization
  • green on wifi connection

See how close that gets you!
I’m excited to know if it works!

(I left out the rest, this is just the first section, so don’t blindly copy paste - you’ll lose all the senors :laughing: ).

Cheers!
DeadEnd

1 Like

this is amazing!!!

here is the final setup

esphome:
  name: emergency_light
  platform: ESP8266
  board: esp01_1m
  on_boot:
    - priority: 300.0 # after sensor setup, before WIFI initialization 
      then:
        - light.turn_on: # indication that the controller has power
            id: emergency_light
            brightness: 100%
            red: 100%
            green: 0%
            blue: 0%
    - priority: 225.0 # after WIFI initialization
      then:
        - light.turn_on: # indication that the controller is looking for a wifi connection
            id: emergency_light
            brightness: 100%
            red: 0%
            green: 0%
            blue: 100%
        - delay: '00:00:05'    
    - priority: -100.0 # everything is initialized, system is online - if condition waits for connection
      then:
        if:
          condition:
            wifi.connected:
          then:
            - light.turn_on: # indication of wifi connection confirmation
                id: emergency_light
                brightness: 100%
                red: 0%
                green: 100%
                blue: 0%
            - delay: '00:00:05'
            - light.turn_on: # confirming that blue led's are working
                id: emergency_light
                brightness: 100%
                red: 0%
                green: 0%
                blue: 100%
            - delay: '00:00:05'
            - light.turn_off: # turns off light waiting on automation to start
                id: emergency_light

DeadEnd you are quite literally a life saver!! this project was to build an emergency signal light as I work in a loud environment and can’t hear or feel my phone ringing. my wife is waiting on a life saving operation and we can get called in any time day or night… getting this light to work, and knowing that the LED’s are receiving power, and connected to wifi not only sets my mind at a bit of ease but also means i won’t miss her call… so I honestly cannot thank you enough, it may be a small matter to you but it is larger than i can explain to me.

Thank you

4 Likes

Hello! i’m getting issues with the on_boot code too.

At this point i don’t know if is my logic or my code writing, but the limited debugging options on the IDE got blind!

esphome:
  name: uv_lamp1_0
  platform: ESP8266
  board: nodemcuv2
  on_boot:
    priority: 300
    then:
      - globals.set:
          id: iniciando
          value: 'false'
      - logger.log: "Esperando se inicialice el contador"
      - while:
          condition:
            lambda: |-
              if (id(iniciando) = false) {
                return true;
              } else {
                return false;
              }
          then:
           - logger.log: "Esperando aun..."
           - rtttl.play: "Xfiles:d=4,o=5,b=125:e,b,a,b,d6,2b.,1p,e,b,a,b,e6,2b.,1p,g6,f#6,e6,d6,e6,2b.,1p,g6,f#6,e6,d6,f#6,2b.,1p,e,b,a,b,d6,2b.,1p,e,b,a,b,e6,2b.,1p,e6,2b."
           - delay: 5s
  

if anyone can give me light with this will be appreciated !!

i got it! hehehe

esphome:
  name: uv_lamp1_0
  platform: ESP8266
  board: nodemcuv2
  on_boot:
    priority: 600
    then:
      - globals.set:
          id: iniciando
          value: 'false'
      - logger.log: "Esperando se inicialice el contador"
      - while:
          condition:
            lambda: |-
             if (id(iniciando)) {
                return false;
              } else {
                return true;
              }
          then:
           - logger.log: "Esperando aun..."
           - rtttl.play: "Xfiles:d=4,o=5,b=125:e,b,a,b,d6,2b.,1p,e,b,a,b,e6,2b.,1p,g6,f#6,e6,d6,e6,2b.,1p,g6,f#6,e6,d6,f#6,2b.,1p,e,b,a,b,d6,2b.,1p,e,b,a,b,e6,2b.,1p,e6,2b."
           - delay: 5s

was the lambda!

edit: it’s always the lambda…

2 Likes