Led indicator for relay

Hi to all,
noob question but I’m lousy in coding :blush:
I’m building a electric water heater timer/conroller. I want it to heat when one press the button for 30 minutes and then turn off. Button have 3.3V led in it and I want that LED slowly blink. Here is part of my code:

switch:
  - platform: gpio
    pin:
      number: GPIO32
      inverted: false  
    name: heater
    id: heater_relay
  - platform: template
    name: "plavi led"
    id: blueled
    turn_on_action:
    - while:
          condition:
            lambda: 'return true;'
          then:
          - light.turn_on: HI
          - delay: 2s
          - light.turn_off: HI
binary_sensor:
  - platform: gpio  
    pin:
      number: GPIO33
      inverted: true
      mode:
        input: true
        pullup: true
    name: "Heater on"
output:
  - platform: ledc
    pin: GPIO25
    id: gpio_25
light:
  - platform: monochromatic
    output: gpio_25
    id: HI
    name: "Heater indicator"

Does it compile or error? What are the errors?

Do you want the light to blink anytime it is heating or only if triggered by your physical button press?

There is no error, but it doesn’t work when I turn on heater from HA. I want to blink when heater is on. Heater will be triggered by button, by timer, by low temperature of boiler and by HA. So, I want to LED be an indicator for heater.

1 Like

Not sure, but try the id as lowercase.

1 Like

Are you sure the led in the button will work on 3.3V?

The majority of backlit momentary switches have a resistor in circuit to allow them to operate on 12V.

Try it like this:

- while:
    condition:
      switch.is_on: heater_relay
    then:
      - light.turn_on: hi
      - delay: 1s 
      - light.turn_off: hi
      - delay: 1s
1 Like

Done! It should look like this:

switch:
  - platform: gpio
    pin:
      number: GPIO32
      inverted: false  
    name: heater
    id: heater_relay
    on_turn_on:
      - while:
          condition:
            switch.is_on: heater_relay
          then:
            - light.turn_on: HI
            - delay: 1s 
            - light.turn_off: HI
            - delay: 1s  
1 Like