syssi / esphome-yeelight-ceiling-light

ESPHome custom firmware for some Yeelight Ceiling Lights
Apache License 2.0
141 stars 22 forks source link

OTA progress effect #69

Closed MayorBug closed 2 months ago

MayorBug commented 1 year ago

I am using the following code on my yeelight_light_ceiling20 to enable OTA progress effect.
Got the idea from the Makaay's bslamp2 project. Going to leave this here if somebody wants to add it to their light or if Sebastian finds it useful then maybe this could be integrated this project by default

ota:
  password: "#YOUR_OTA_KEY"
  safe_mode: true

  on_begin:
    then:
      #turn lights off
      - output.turn_off: output_nightlight
      - output.turn_off: output_cold
      - output.turn_off: output_warm
      - output.turn_off: output_red
      - output.turn_off: output_green
      # enable blue leds to show that OTA process has begun
      - output.set_level:
          id: output_blue
          level: 15%

  on_progress:
    then:
      #Show OTA progress status using green leds. Effect is a bit choppy... 
      #I only get 2-3 brightness changes, but that is better than nothing ;)
      #Effect could probably be made smoother with a better custom lambda code?
      output.set_level:
        id: output_green
        level: !lambda |-
          // output value must be in range 0 - 1.0
          return x / 100.0;

  on_end:
    then:
      - output.turn_off: output_blue
      - output.turn_on: output_green

  on_error:
    then:
      - output.turn_off: output_green
      - output.turn_on: output_red