Close

LED lighting

A project log for Experiences with ESPhome

Setting up some ESPhome-devices

mabe42MaBe42 12/27/2024 at 21:570 Comments

An incomplete yaml file to control two LED strips for illumination using two buttons. The buttons allow only to switch between on and off. From HomeAssistant dimming is possible.

The device uses a Wemos D1 mini.

The LEDs are controlled using PWM output and are connected using a logic-level n-MOSFET (IRLU 024N). The maximum level is set to 95% to prevent the LEDs from to early degradation (at least I hope so).

The buttons used to toggle the lights include a very simple debouncing (filter).

esp8266:
  board: d1_mini

# LEDs: 13, 14 (D7, D5)
# Taster: 5, 4 (D2, D1)
    
output:
  - platform: esp8266_pwm
    pin: GPIO14 #D5
    id: Fenster_pwm
    frequency: 440 Hz
    min_power: 0
    max_power: 0.95

  - platform: esp8266_pwm
    min_power: 0
    max_power: 0.95
    frequency: 440 Hz
    id: Bett_pwm
    pin: GPIO13 #D7


light:
  - platform: monochromatic
    name: "Licht Fenster"
    id: Licht_Fenster
    output: Fenster_pwm
    default_transition_length: 3s

  - platform: monochromatic
    name: "Licht Bett"
    id: Licht_Bett
    output: Bett_pwm
    default_transition_length: 3s

#  - platform: status_led
#    name: "Status"
#    pin:
#      number: GPIO2
#      inverted: true
#    restore_mode: ALWAYS_OFF

binary_sensor:
  - platform: gpio
    name: "Taster_Fenster"
    pin: 
      number: GPIO4 #D1
      inverted: true
      mode: 
        input: true
        pullup: true
    filters:
      - delayed_on: 50ms
    on_click:
      max_length: 500ms
      then:
        - light.toggle: Licht_Fenster

  - platform: gpio
    name: "Taster_Bett"
    pin: 
      number: GPIO5 #D2
      inverted: true
      mode: 
        input: true
        pullup: true
    filters:
      - delayed_on: 50ms
    on_click:
      max_length: 500ms
      then:
        - light.toggle: Licht_Bett

sensor:
  - platform: wifi_signal
    name: "WiFi Signal Sensor"
    update_interval: 300s

Discussions