syssi / esphome-yeelight-ceiling-light

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

Add YLXD05YL and YLXD01YL support (Mediatek devices) #10

Open splitatom44 opened 3 years ago

splitatom44 commented 3 years ago

Is it possible to assist with flashing the YLXD05YL and YLXD01YL models of the Yeelights? Photos attached of mainboards. Thankyou

20210403_074056 20210403_074107 20210403_074251 20210403_075015 20210403_075017 20210403_075709 20210403_075716

wmlex commented 9 months ago

Tell me why, when I turn off the light, the lamp (YLXD17YL) does not go out evenly? Cold&Warm 50/50 https://youtu.be/jaf6tGkBfgs Cold&Warm 0/100 https://youtu.be/ibINSGMekM0 Cold&Warm 100/0 https://youtu.be/JFTfzDFalsA photo_2023-11-18_10-17-32 photo_2023-11-18_10-18-02 photo_2023-11-18_10-17-59

output:
  - platform: ledc
    pin: GPIO19
    id: output_warm
    frequency: 4882Hz
    min_power: 0.07
    max_power: 0.92
    zero_means_zero: true

  - platform: ledc
    pin: GPIO21
    id: output_cold
    frequency: 4882Hz
    min_power: 0.07
    max_power: 0.92
    zero_means_zero: true

  - platform: ledc
    pin: GPIO23
    id: output_nightlight
    frequency: 9765Hz
    max_power: 0.92

light:
  - platform: monochromatic
    name: "${board_name}_nightlight"
    id: night_light
    output: output_nightlight
    gamma_correct: 0
    on_turn_on:
      - light.turn_off: ceiling_light
  - platform: cwww
    name: "${board_name}"
    id: ceiling_light
    cold_white: output_cold
    warm_white: output_warm
    cold_white_color_temperature: 6000 K
    warm_white_color_temperature: 2700 K
    gamma_correct: 0
    constant_brightness: true
    on_turn_on:
      - light.turn_off: night_light

Solved the problem by adding

gamma_correct: 0.4
default_transition_length: 200ms
bedson87 commented 9 months ago

I converted YLXD01YL - thx! I tore out this "Mediatek" chip with a regular soldering iron, losing a few pads, but fortunately they were unimportant (butcher) :P

20231207_160026_10Tp LMC JOLE 96

Everything works, but... in cwww mode, when the brightness is set to 1-30%, flickering occurs. This problem does not occur in "nightlight" mode. I tried different frequencies (9765Hz/20000Hz) but I didn't see any changes. Anyone have an idea how to fix this?

My yaml:

#Variables
substitutions:
  device_name: komputerowy-yeelight-ceiling
  friendly_name: komputerowy-yeelight-ceiling

esphome:
  name: ${device_name}
  friendly_name: komputerowy-yeelight-ceiling

esp32:
  board: esp32dev
  framework:
    type: arduino
#  framework:
#    type: esp-idf
#    version: recommended

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "XXXX"

ota:
  password: "XXXX"

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

#do pilota
#external_components:
#  - source: github://dentra/esphome-components

output:
  - platform: ledc
    pin: GPIO19
    id: output_warm
#    frequency: 9765Hz
#    frequency: 20000Hz
    frequency: 4882Hz
    min_power: 0.07
    max_power: 0.92
    zero_means_zero: true

  - platform: ledc
    pin: GPIO21
    id: output_cold
#    frequency: 9765Hz
#    frequency: 20000Hz
    frequency: 4882Hz
    min_power: 0.07
    max_power: 0.92
    zero_means_zero: true

  - platform: ledc
    pin: GPIO22
    id: output_nightlight
    frequency: 9765Hz
#    frequency: 20000Hz
    max_power: 0.92

light:
  - platform: monochromatic
    name: "${friendly_name} Nightlight"
    id: night_light
    output: output_nightlight
    gamma_correct: 0
    on_turn_on:
      - light.turn_off: ceiling_light
  - platform: cwww
    name: "${friendly_name}"
    id: ceiling_light
    cold_white: output_cold
    warm_white: output_warm
    cold_white_color_temperature: 6000 K
    warm_white_color_temperature: 2700 K
    gamma_correct: 0
    constant_brightness: true
    on_turn_on:
      - light.turn_off: night_light

external_components:
  - source: github://dentra/esphome-components

sensor:
  # Presence based on MAC address
  - platform: miot_ylyk01yl
    mac_address: "XXXX"
    bindkey: "XXXX"
    on_click:
      # String (Required), The button name (case insensitive):
      #     on, off, dimmable or sun or moon, plus or +, moonlight or M, minus or -
      - button: "on"
        then:
          - logger.log: button ON click
          - light.turn_on: night_light
      - button: "off"
        then:
           - logger.log: button OFF click
           - light.turn_off: night_light
           - light.turn_off: ceiling_light
      - button: "+"
        then:
           - logger.log: button PLUS click
           - if:
              condition:
                light.is_on: ceiling_light
              then:
                - light.dim_relative:
                    id: ceiling_light
                    relative_brightness: 5%
                    transition_length: 0.1s
                - delay: 0.1s
           - if:
              condition:
                light.is_on: night_light
              then:
                - light.dim_relative:
                    id: night_light
                    relative_brightness: 5%
                    transition_length: 0.1s
                - delay: 0.1s      
           - if:
              condition:
                - light.is_off: night_light
                - light.is_off: ceiling_light
              then:
                - light.dim_relative:
                    id: ceiling_light
                    relative_brightness: 5%
                    transition_length: 0.1s
                - delay: 0.1s      

      - button: "-"
        then:
           - logger.log: button MIN click
           - if:
              condition:
                light.is_on: ceiling_light
              then:
                - light.dim_relative:
                    id: ceiling_light
                    relative_brightness: -5%
                    transition_length: 0.1s
                - delay: 0.1s
           - if:
              condition:
                light.is_on: night_light
              then:
                - light.dim_relative:
                    id: night_light
                    relative_brightness: -5%
                    transition_length: 0.1s
                - delay: 0.1s  
      - button: "M"
        then:
           - logger.log: button MOON click
           - if:
              condition:
                light.is_on: ceiling_light
              then:
                - light.turn_off: ceiling_light
                - light.turn_on: night_light
           - if:
              condition:
                light.is_on: night_light
              then:
                - light.turn_off: night_light
                - light.turn_on: ceiling_light
      - button: "sun"
        then:
          - light.control:
              id: ceiling_light
              color_temperature: !lambda |-
                if(id(ceiling_light).remote_values.get_color_temperature()==167){
                  return 370;
                }
                else{
                  return 167;
                }
          - logger.log: button SUN click

  - platform: miot_ylkg0xyl
    # String (Required), device MAC-address.
    mac_address: "XXXX"
    # String, (Optional), device bind key. Will use "xiaomi_account" from "miot" if absent to automaticaly get the bindkey.
    bindkey: "XXXX"
    # List, Automation (Optional), The automation activated when you make specified action
    on_short_press:
      # List, Any automation
      - then:
          - logger.log:
              format: knob was short pressed %u times
              args: ["x"]
          - if:
             condition:
               and:
                 - light.is_off: night_light
                 - light.is_off: ceiling_light
             then:
               - light.turn_on: night_light
#          - if:
#             condition:
#               light.is_on: ceiling_light
#             then:
#               - light.turn_off: ceiling_light
#               - light.turn_on: night_light
          - if:
             condition:
               light.is_on: ceiling_light
             then:
               - light.turn_off: ceiling_light
          - if:
             condition:
               light.is_on: night_light
             then:
               - light.turn_off: night_light
               - light.turn_on: ceiling_light
    on_long_press:
      - then:
          - logger.log: knob was long pressed
          - light.turn_off: night_light
          - light.turn_off: ceiling_light
    on_rotate_left:
      - then:
          - logger.log:
              format: knob was rotating left on %u
              args: ["x"]
          - if:
             condition:
               light.is_on: ceiling_light
             then:
               - light.dim_relative:
                   id: ceiling_light
                   relative_brightness: -15%
                   transition_length: 0.1s
               - delay: 0.1s
          - if:
             condition:
               light.is_on: night_light
             then:
               - light.dim_relative:
                   id: night_light
                   relative_brightness: -15%
                   transition_length: 0.1s
               - delay: 0.1s 
    on_rotate_right:
      - then:
          - logger.log:
              format: knob was rotating right on %u
              args: ["x"]
          - if:
             condition:
               light.is_on: ceiling_light
             then:
               - light.dim_relative:
                   id: ceiling_light
                   relative_brightness: 15%
                   transition_length: 0.1s
               - delay: 0.1s
          - if:
             condition:
               light.is_on: night_light
             then:
               - light.dim_relative:
                   id: night_light
                   relative_brightness: 15%
                   transition_length: 0.1s
               - delay: 0.1s      
          - if:
             condition:
               - light.is_off: night_light
               - light.is_off: ceiling_light
             then:
               - light.dim_relative:
                   id: ceiling_light
                   relative_brightness: 15%
                   transition_length: 0.1s
               - delay: 0.1s  
    on_rotate_left_pressed:
      - then:
          - logger.log:
              format: knob was pressed and rotating left on %u
              args: ["x"]
    on_rotate_right_pressed:
      - then:
          - logger.log:
              format: knob was pressed and rotating right on %u
              args: ["x"]
PsychoRS commented 8 months ago

Hi, I'm planning to replace the Mediatek board on my Jiaoyue 650, and I have a question: did I need a power supply to power the board and check the voltages on the outputs or will be fine with the current provided by the USB-TTL adapter (CP2012 and CH431 I have)? Can the Mediatek module connect to wifi when powered by those adapters?

justr0st commented 1 month ago

Replaced MTK board in my YLXD05YL with ESP32-WROOM-32UE and it worked perfectly, however i needed to change pwm frequency for night light pin to 19531Hz, because it produced audible whining noise on 4882Hz and 9765Hz.