Esphome Select turn on effect

have this

select:
  - platform: template
    id: set_interval
    name: "Rubbish Type"
    icon: mdi:trash-can-outline
    optimistic: true
    restore_value: true
    options:
      - Landfill
      - Glass
      - Recycling
      - Recycling/Glass
    on_value:
      then:
        - logger.log:
            format: "Chosen option: %s (index %d)"
            args: ["x.c_str()", "i"]
        - light.turn_on:  **??????????**

which I can see in home assistant the select box
the light bit

light:
  - platform: neopixelbus
    type: GRB
    variant: ws2812
    pin: GPIO4
    num_leds: 5
    name: wastebin_lid
    id: wastebin_lid
    # default_transition_length: 7.5s
    effects:
      # Use default parameters:
      - addressable_color_wipe:
          name: "Landfill"
          colors:
            - red: 100%
              green: 0%
              blue: 0%
              num_leds: 5
          add_led_interval: 50ms
      - addressable_color_wipe:

so when i select the Landfill in the select part how do i turn on its effects

 - light.turn_on:  **??????????**

am i barking up the wrong tree

as i have this in HA

Something like this?

select:
  - platform: template
    id: set_interval
    name: "Rubbish Type"
    icon: mdi:trash-can-outline
    optimistic: true
    restore_value: true
    options:
      - Landfill
      - Glass
      - Recycling
      - Recycling/Glass
    on_value:
      then:
        - logger.log:
            format: "Chosen option: %s (index %d)"
            args: ["x.c_str()", "i"]  then:
        - if:
            condition:
              lambda: |-
                return x == "Landfill";
            then:
              - light.turn_on:
                  id: waste bin_lid
        - if:
            condition:
              lambda: |-
                return x == "Glass";
         # etc for other states

Try this:


select:
  - platform: template
    id: set_interval
    name: "Rubbish Type"
    icon: mdi:trash-can-outline
    optimistic: true
    restore_value: true
    options:
      - Landfill
      - Glass
      - Recycling
      - Recycling/Glass
    on_value:
      then:
        - logger.log:
            format: "Chosen option: %s (index %d)"
            args: ["x.c_str()", "i"]
        # - light.turn_on:  **??????????**
        - lambda: |-
            auto call = id(wastebin_lid).turn_on();
            // set parameters (optional)
            // call.set_transition_length(1000); // in ms
            // call.set_brightness(1.0); // 1.0 is full brightness
            // call.set_color_mode(ColorMode::RGB_COLD_WARM_WHITE);
            // call.set_rgb(0.5, 0.25, 1.0); // color in RGB order, this example is purple
            // call.set_cold_white(0.5);
            // call.set_warm_white(0.75);
            call.set_effect(id(set_interval).state);
            // perform action:
            call.perform();


light:
  - platform: neopixelbus
    type: GRB
    variant: ws2812
    pin: GPIO4
    num_leds: 5
    name: wastebin_lid
    id: wastebin_lid
    # default_transition_length: 7.5s
    effects:
      # Use default parameters:
      - addressable_color_wipe:
          name: "Landfill"
          colors:
            - red: 100%
              green: 0%
              blue: 0%
              num_leds: 5
          add_led_interval: 50ms
      - addressable_color_wipe:

Thanks understand sort of what it doing

but if I add your bit

it does not connect to the wifi

if i take out the

call.set_effect(id(set_interval).state);

it joins the network

    on_value:
      then:
        - logger.log:
            format: "Chosen option: %s (index %d)"
            args: ["x.c_str()", "i"]
        # - light.turn_on:  **??????????**
        - lambda: |-
            auto call = id(wastebin_lid).turn_on();
            //call.set_effect(id(set_interval).state);
            call.perform();

looks like more reading

got it sorted

had to add a if statement

    on_value:
      then:
        - logger.log:
            format: "Chosen option: %s (index %d)"
            args: ["x.c_str()", "i"]
        # - light.turn_on:  **??????????**
        - if:
            condition:
              lambda: |-
                return x != "None";
            then:
            - lambda: |-
                auto call = id(wastebin_lid).turn_on();
                call.set_effect(id(set_interval).state);
                call.perform();

thank you
zoogara walberjunior

next problem how the hell do i turn off the BLUE status LED

here is full working code

esphome:
  name: wastebin

esp8266:
  # board: esp01_1m
   board: d1_mini

    
# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  - platform: esphome
    id: my_ota
    password: 'nottellingyou'


wifi:
  networks:
    ssid: "IOT"
    password: "imnottellyou"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Wastebin Fallback Hotspot"


captive_portal:


web_server:
  port: 80
  version: 3

select:
  - platform: template
    id: set_interval
    name: "Rubbish"
    icon: mdi:trash-can-outline
    optimistic: true
    restore_value: false
    options:
      - "OFF"
      - Landfill
      - Glass
      - Recycling
    on_value:
      then:
        - logger.log:
            format: "Chosen option: %s (index %d)"
            args: ["x.c_str()", "i"]
        # - light.turn_on:  **??????????**
        - if:
            condition:
              lambda: |-
                return x != "OFF";

            then:
            - lambda: |-
                auto call = id(wastebin_lid).turn_on();
                call.set_effect(id(set_interval).state);
                call.perform();
        - if:
            condition:
              lambda: |-
                return x == "OFF";
            then:
            - lambda: |-
                auto call = id(wastebin_lid).turn_off();
                call.perform();
light:
  - platform: neopixelbus
    type: GRB
    variant: ws2812
    pin: D2 #GPIO4
    num_leds: 5
    name: wastebin lid
    id: wastebin_lid
    # default_transition_length: 7.5s
    effects:
      # Use default parameters:
      - addressable_color_wipe:
          name: "Landfill"
          colors:
            - red: 100%
              green: 0%
              blue: 0%
              num_leds: 5
          add_led_interval: 50ms
      - addressable_color_wipe:
          name: "Glass"
          colors:
            - red: 0%
              green: 0%
              blue: 100%
              num_leds: 5
          add_led_interval: 50ms
      - addressable_color_wipe:
          name: "Recycling"
          colors:
            - red: 100%
              green: 100%
              blue: 0%
              num_leds: 5
          add_led_interval: 50ms
          reverse: false


binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      inverted: true
    name: wastebin lidswitch
    filters:
      # debounce delay
      - delayed_off: 10ms

switch:
  - platform: gpio
    pin: GPIO2
    name: wastebin lidswitch disable
    restore_mode: ALWAYS_OFF

Try creating an output on the gpio02 port and turning it off after booting is complete.

GPIO02 HIGH at boot
connected to on-board LED, boot fails if pulled LOW
1 Like

thanks bro

got it sorted

 - platform: monochromatic
    id: led
    disabled_by_default: True
    name: Status - LED
    output: out_led
    default_transition_length: 0s
    effects:
      - pulse:
          name: pulser
          transition_length: 0.0s
          update_interval: 0.25s
      - pulse:
          name: flashfast
          transition_length: 0.0s
          update_interval: 0.025s
    on_turn_on:
      - delay: 3s
      - light.turn_off: led

output:
  platform: esp8266_pwm
  pin:
    number: GPIO2
    inverted: true
  id: out_led

dont unstand how it works it works lol found is on line
and even found how to disable them looking good now
as I dont want them showing in HA

Remove the name, the entity will be internal only

1 Like

thanks, bro make cents

now the next part when we have recycling and glass on the same day

having the two colours half yellow and other half blue

bloody more reading