esphome:
  name: updownlight

esp8266:
  board: esp01_1m
  restore_from_flash: true  
  
  
# Store the current Light Color in the flash every miniute only (MAX)
# The RAM will checked every minute - if there was a change in light color,
# this new color will be stored and restored on next boot (power off & on)
preferences:
  flash_write_interval: 1min  

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "2M3DWxk37LQNhf8ZCanRyh1eVcGWd82HcuqHyp4mvzU="

ota:
  password: "c4947f215eaa994ca91fa4d77db9552f"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

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

captive_portal:

sensor:
  - platform: wifi_signal
    name: "Updownlight WiFi Signal"
    update_interval: 60s
    
    
light:
  - platform: rgbww
    name: updownlight
    id: updownlight
    gamma_correct: 2.8
    red: red
    green: green
    blue: blue
    cold_white: cold_white
    warm_white: warm_white
    cold_white_color_temperature: 6200 K
    warm_white_color_temperature: 2800 K
    color_interlock: true
    restore_mode: RESTORE_AND_ON
    effects:
     - strobe:
         name: Strobe Effect
         colors:
            - state: True
              brightness: 80%
              red: 80%
              green: 0%
              blue: 80%
              duration: 500ms
            - state: False
              duration: 250ms
            - state: True
              brightness: 80%
              red: 0%
              green: 80%
              blue: 0%
              duration: 500ms
     - flicker:
          name: Flicker Effect
          alpha: 95%
          intensity: 2.0%
     - random:
          name: Slow Random Effect
          transition_length: 12s
          update_interval: 10s
     - random:
          name: Fast Random Effect
          transition_length: 4s
          update_interval: 5s

output:
  - platform: esp8266_pwm
    id: red
    pin: GPIO4
  - platform: esp8266_pwm
    id: green
    pin: GPIO12
  - platform: esp8266_pwm
    id: blue
    pin: GPIO14
  - platform: esp8266_pwm
    id: cold_white
    pin: GPIO5
    max_power: 0.85
  - platform: esp8266_pwm
    id: warm_white
    pin: GPIO13
    max_power: 0.85
    