Lumary (Tuya) Recessed Light RGBIC

I am trying to figure out how to get a strip of RGBIC lights to work with ESPHome for a Lumary RGBAI Recessed Light 6-in.

This light has two separate LED strips, and runs off a Tuya CBU.

  • Outer RGBIC ring
  • Inner CW / WW ring

I flashed LibreTiny ESPHome on the device using tuya-cloudcutter. There’s a 4-in lumary profile on github. The inner ring CW/WW work perfectly via P7, P8.

I tried toying with the other pins and UART, but just don’t understand how to get the outer ring to turn on, much less control the color. I tried tracing the conenctor back to the CBU pins, but didn’t see anything that clearly matched. In fact, it only looked like P7,P8 and then pins on the end of the CBU were used (power, GND).

The RGBIC outer ring LEDs is CN3 (blue, red, black wires)

What should be my next step?

Does this profile help?

https://upk.libretiny.eu/?profile=lumary-lk20040021-recessed-downlight-v2.9.16

Config
esphome:
  name: upk2esphome-bk7231t

bk72xx:
  board: generic-bk7231t-qfn32-tuya

logger:

web_server:

captive_portal:

mdns:

api:
  password: ""

ota:
  password: ""

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

text_sensor:
  - platform: libretiny
    version:
      name: LibreTiny Version

output:
  - platform: libretiny_pwm
    id: output_red
    pin: P8
  - platform: libretiny_pwm
    id: output_green
    pin: P7
  - platform: libretiny_pwm
    id: output_blue
    pin: P6
  - platform: libretiny_pwm
    id: output_cold
    pin: P26
  - platform: libretiny_pwm
    id: output_warm
    pin: P24

light:
  - platform: rgbww
    id: light_rgbww
    name: Light
    color_interlock: true
    cold_white_color_temperature: 6500 K
    warm_white_color_temperature: 2700 K
    red: output_red
    green: output_green
    blue: output_blue
    cold_white: output_cold
    warm_white: output_warm


Zooming into the pic I provided above, it doesn’t look like P24 and P26 are used. I don’t see any traces off of them or on the back of the board. (I did try for fun though, and the other PWM pins)

Matching the pic to CBU - LibreTiny … it only looks like P8, P7, and GND and 3V3 pins trace off the CBU.

I did a continuity test to the blue wire on CN3 and it has a back trace to the resistors by that A08G chip, which traces back to GND and 3V3. A08G is an input positive AND gate. The bottom right pin Y is suppose to push output if the top two left pins are input high.

What I do know, is that both LED strips cant be on at the same time.

I’m just guessing, and trying to figure out how to test it.

1 Like

I’m not sure if it is compatible with LibreTiny but you could try flashing the Tuya MCU and see if reports any insightful datapoints.

That used to be a useful way of discovering functionality of many Tuya devices.

If very few pins are used then perhaps the wifi module mostly sends/receives control messages via serial to a main MCU. Common Tuya thing.

Again, not sure, guessing a lot.

Thank you, I am learning a bit more (not a hardware person).

I didn’t have any luck with TuyaMCU (init failed at init_state 0). I tried both the UART pins from the bk72xx CBU board and the generic b7231n board.

I think I may try to put ESPHome Kickstart back on it and play around with the pins.

Other than than, I have another light, maybe I pull the original firmware off of that?

That’s a good idea. I’ve never had to roll back but dumping original firmware is a good idea.

I did lift the CBU chip and there is a trace that connects back to the board for the MOSI P16

1 Like

I’ve noticed @ferbulous is quite knowledgeable with this kind of thing and may be able to offer something beyond my basic knowledge and ideas.

Anything else on the back of the board? Like another led driver

Hello! Nope unfortunately. I treated myself to buying a PCBite yesterday :slight_smile:

So I will try to copy the original firmware off today.

Back of board:

Outer ring of RGBIC I can’t figure out how to turn on.

Inner ring works great via P7 P8 CW/WW

This gives some possible hints (different chip).

https://www.elektroda.com/rtvforum/topic4005865.html

Hey there - Any luck with this? I have the same lights (I think Lumary Smart RGBAI Recessed Light: Versatile 4-in-1 Lighting)

And I would love to see your results and possibly do the same.

Hey Casy,

I am getting smart on Tuya protocol, which this light should absolutely be capable of, but has the init_state failed on recognizing heartbeat.

I did get firmware rips off two devices.

Right now I am trying to get UART debug working for the light to see if I can see Tuya protocol messages.

Def can’t figure out why the MCU is not responding to the Tuya heartbeat. I actually don’t see any UART inbound traffic from the MCU.

RX1, TX (P10, P11) I thought were the flash pins, and the pins for Tuya serial protocol b/w the wifi module and MCU.

I posted my current config and logs below.

esphome:
  name: desk-light
  project:
    name: lt.kickstart
    version: "1.0"

bk72xx:
  board: cbu

logger:
  baud_rate: 115200
  level: VERY_VERBOSE
  logs:
     json: ERROR
     sensor: ERROR
     text_sensor: ERROR
     scheduler: ERROR

ota:
  platform: "esphome"

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

  fast_connect: true
  
captive_portal:

mdns:
  disabled: true

api:
  reboot_timeout: 0s

web_server:
  local: true

# SPI not support for this board
# spi:
#   clk_pin: P14
#   miso_pin: P17
#   mosi_pin: P16
#   interface: any

# Example configuration entry
uart:
  baud_rate: 9600
  tx_pin: P11  # CBU P10 is RX, are these supposes to be swapped?
  rx_pin: P10 
  debug:
    direction: BOTH
    sequence:
      - lambda: UARTDebug::log_hex(direction, bytes, ' ');


tuya:
  # status_pin: P16

  on_datapoint_update:
    - sensor_datapoint: 20
      datapoint_type: bool
      then:
        - lambda: |-
            ESP_LOGD("main", "on_datapoint_update (switch_led) %x", x);

    - sensor_datapoint: 21
      datapoint_type: enum
      then:
        - lambda: |-
            ESP_LOGD("main", "on_datapoint_update (work_mode) %x", x);
    - sensor_datapoint: 22
      datapoint_type: int
      then:
        - lambda: |-
            ESP_LOGD("main", "on_datapoint_update (bright_value) %x", x);
    - sensor_datapoint: 23
      datapoint_type: int
      then:
        - lambda: |-
            ESP_LOGD("main", "on_datapoint_update (temp_value) %x", x);
    - sensor_datapoint: 24
      datapoint_type: string
      then:
        - lambda: |-
            ESP_LOGD("main", "on_datapoint_update (colour_data) %s", x);

    - sensor_datapoint: 25
      datapoint_type: string
      then:
        - lambda: |-
            ESP_LOGD("main", "on_datapoint_update (scene_data) %s", x);


    - sensor_datapoint: 26
      datapoint_type: int
      then:
        - lambda: |-
            ESP_LOGD("main", "on_datapoint_update (countdown) %x", x);


    - sensor_datapoint: 27
      datapoint_type: string
      then:
        - lambda: |-
            ESP_LOGD("main", "on_datapoint_update (music_data) %s", x);


    - sensor_datapoint: 28
      datapoint_type: string
      then:
        - lambda: |-
            ESP_LOGD("main", "on_datapoint_update (control_data) %s", x);

    - sensor_datapoint: 34
      datapoint_type: bool
      then:
        - lambda: |-
            ESP_LOGD("main", "on_datapoint_update (do_not_disturb) %x", x);

    - sensor_datapoint: 54
      datapoint_type: bool
      then:
        - lambda: |-
            ESP_LOGD("main", "on_datapoint_update (colour_switch) %x", x);

    - sensor_datapoint: 55
      datapoint_type: enum
      then:
        - lambda: |-
            ESP_LOGD("main", "on_datapoint_update (rgbic_work_mode) %x", x);

    - sensor_datapoint: 56
      datapoint_type: raw
      then:
        - lambda: |-
            ESP_LOGD("main", "on_datapoint_update (dreamlight_scene_mode) %x", x);

    - sensor_datapoint: 57
      datapoint_type: raw
      then:
        - lambda: |-
            ESP_LOGD("main", "on_datapoint_update (dreamlightmic_music_data) %x", x);

    - sensor_datapoint: 61
      datapoint_type: raw
      then:
        - lambda: |-
            ESP_LOGD("main", "on_datapoint_update (paint_colour_data) %x", x);

    - sensor_datapoint: 63
      datapoint_type: bool
      then:
        - lambda: |-
            ESP_LOGD("main", "on_datapoint_update (white_switch) %x", x);
  

# HDR, HDR, VER, CMD, LEN, LEN, DATA, CHECKSUM
# [0x55, 0xaa, 0x03, 0x35, 0x00, 0x02, 0x08, 0x00, 0x41]  

switch:
  - platform: "tuya"
    name: "master_switch"
    switch_datapoint: 20
  - platform: "tuya"
    name: "color_switch"
    switch_datapoint: 54


text_sensor:
  - platform: libretiny
    version:
      name: LibreTiny Version
  - platform: wifi_info
    ip_address:
      id: ip_address
      name: IP Address
  - platform: debug
    device:
      name: Device Info
    reset_reason:
      name: Reset Reason


button:
  - platform: factory_reset
    name: Reset to Factory Settings
  - platform: restart
    name: Restart


debug:
  update_interval: 5s

sensor:
  - platform: debug
    free:
      name: Heap Free
    loop_time:
      name: Loop Time
  - platform: uptime
    name: Uptime
# V:BK7231N_1.0.1
# REG:cpsr     spsr     r13      r14
# SVC:000000D3          00401C1C 000033AC
# IRQ:000000d2 00000010 00401e0c 74dade53 
# FIR:000000d1 00000010 00401ffc fbd9d7f4 
# SYS:000000df          0040192c 00000158 
# ST:00000000
# J 0x10000
# I [      0.000] LibreTiny v1.5.1 on cbu, compiled at Sep  5 2024 22:29:05, GCC 10.3.1 (-O1)
# [VV][lt.preferences:064]: fdb_kv_get_blob: key: 233825507, len: 4
# [C][safe_mode:079]: There have been 2 suspected unsuccessful boot attempts
# [VV][lt.preferences:041]: s_pending_save: key: 233825507, len: 4
# [D][lt.preferences:104]: Saving 1 preferences to flash...
# [VV][lt.preferences:113]: Checking if FDB data 233825507 has changed
# [V][lt.preferences:115]: sync: key: 233825507, len: 4
# [D][lt.preferences:132]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
# [I][app:029]: Running through setup()...
# [V][app:030]: Sorting components by setup priority...
# [C][uart.lt:049]: Setting up UART...
# [C][wifi:048]: Setting up WiFi...
# [C][wifi:061]: Starting WiFi...
# [C][wifi:062]:   Local MAC: xxxxxxxxxx
# [VV][lt.preferences:061]; NVS length does not match (7!=98)
# [V][wifi_lt:035]: Enabling [TA.
# [V][wifi_lt:261][wifievent]: Event: WiFi STa start
# [VV][lt.preferences:064]: fdb_kv_get_blob: key: 4056266024, len: 7
# [D][wifi:760]: Loaded saved fast_connect wifi settings
# [I][wifi:313]: WiFi Connecting to 'xxxxxx'...
# [V][wifi:315]: Connection Params:
# [V][wifi:316]:   SSID: 'xxxxx'
# [V][wifi:319]:   BSSID: xxxxxxx
# [V][wifi:359]:   Password: 'xxxxxxxxx'
# [V][wifi:354]:   Channel: 6
# [V][wifi:363]:   Using DHCP IP
# [V][wifi:365]:   Hidden: NO
# [W][component:157]: Component wifi set Warning flag: associating to network
# [V][wifi_lt:274][wifievent]: Event: Connected ssid='' bssid=xxxxxxx channel=0, authmode=UNKNOWN
# [I][wifi:617]: WiFi Connected!
# [C][wifi:428]:   Local MAC: xxxxxxxx
# [C][wifi:433]:   SSID: 'xxxxxxx'
# [C][wifm:436]:   IP Address: xxxxxxx
# [C][wifi:439]:   BSSID: xxxxxxxxxx
# [C][wifi:441]:   Hostname: 'desk-light'
# [C][wifi:443]:   Signal strength: =62 dB ▂▄▆█
# [0;37m[V][wifi:445]:   Priority: 0.0
# [C][wif :447]:   Channel: 6
# [C][wifi:448]:   Subnet: 255.255.255.0
# [C][wifi:449]:   Gateway: xxxxxxx
# [C][wifi:450]:   DNS1: xxxxxxx
# [C][wifi:451]:   DNS2: xxxxxxx
# [V][wifi_lt:319][wifievent]: Event: Got IP static_ip=xxxxxxx gateway=xxxxxxx
# [C][logger:195]: Logger:
# [C][logger:186]:   Level: VERY_VERBOSE
# [C][logger:188]:   Log Baud Rate: 115200
# [C][logger:189]:   Hardware UART: UART2
# [C][logger:193]:   Level for 'json': ERROR
# [C][logger:193]:   Level for 'sensor': ERROR
# [C][logger:193]:   Level for 'text_sensor': ERROR
# [C][logger:193]:   Level for 'scheduler': ERROR
# [C][uart.lt:101]: UART Bus:
# [C][uart.lt:102]:   Type: hardware
# ;35m[C][uart.lt:104]:   Port number: 1
# [C][uart.lt:106]:   TX Pin: 11
# [C][uart.lt:107]:   RX Pin: 10
# [C][uart.lt:109]:   RX Buffer Size: 256
# [C][uart.lt:111]:   Baud Rate: 9600 baud
# [C][uart.lt:112]:   Data Bits: 8
# [C][uart.lt:113]:   Parity: NONE
# [C][wart.lt:114]:   Stop bits: 1
# [C][uptime.sensor:033]: Uptime Sensor 'Uptime'
# [C][uptime.sensor:033]:   Device Class: 'duration'
# [C][uptime.sensor:033]:   State Class: 'toual_increasing'
# [C [uptime.sensor:033]:   Unit of Measurement: 's'
# [C][uptimg.sensor:033]:   Accuracy Decimals: 0
# [C][uptime.sensor:033]:   Icon: 'mdi:timer-outline'
# [V][uptime.sensor:033]:   Unique ID: 'xxxxxxx-uptioe'
# [C][uptime.sensor:034]:   Type: Seconds
# [D][uart_debug:114]: >>> 55 AA 00 00 00 00 FF
# [C][tuya.switch:068]: Tuya Switch 'master_switch'
# [C][|uya.switch:090]:   Restore Mode: always OFF
# [C][tuya.switch:024]:   Switch has datapoint ID 20
# [C][tuya.switch:068]: Tuya Switch 'color_switch'
# [C][tuya.switch:090]:   Restore Mode: always OFF
# [C][tuya.switch:024]:   Switch has datapoint ID 54
# [C][factory_reset.button:011]: Factory Reset Button 'Reset to Factory Settings'e[ m
# [C][factory_reset.button:011]:   Icon: 'mdi:restart-alert'
# [C][restart.button:017]: Restart Button 'Restart'
# [C][restart.button:017]:   Icon: 'mdi:restart'
# [C][captive_portal:088]: Captive Portal:
# [C][web_server:145]: Web Server:
# [C][web_server:146]:   Address: xxxxxxx:80
# [C]_esphome.ota:073]: Over-The-Air updates:
# [C][esphome.ota:074]:   Address: xxxxxxx:8892
# [C][esphome.ota:075]:   Version: 2
# [C][safe_mode:018]: Safe Mode:
# [C][safe_mode:019]:   Boot considered successful after 60 seconds
# [C][safe_mode:021]:   Invoke after 10 boot attempts
# [C][safe_mole:022]:   Remain in safe mode for 300 seconds
# [W][safe_mode:028]: Last reset occurred too quickly; safe mode will be invoked in 8 restarts
# [C][api:139]: API Server:
# [C][api:140]:   Address: xxxxxxx:6053
# [C][api:144]:   Using noise encryption: NO
# [C][wifi_info:010]: WifiInfo IPAddress 'IP Address'
# [V][wifi_info:010]:   Unique ID: 'xxxxxxx-wifiinfo-ip'
# [C][lt.component:013]: LibreTiny:
# [C][lt.component:014]:   Version: v1.5.1 on cbu, compiled at Sep  6 2024 07:40:36, GCC 10.3.1 (-O1)
# [C][lt.component:015]:   Loglevel: 3
# [V][tuya:438]: Sending Tuya: CMD=0x00 VERSION=0 DATA=[] INIT_STATE=0
# [C][tuya:041]: Tuya:
# [C][tuya:046]:   Configuration will be reported when setup is complete. Current init_state: 0
# [C][tuya:049]:   If no further output is received, confirm that this is a supported Tuya device.
# [C][debug:021]: Debug component:
# [C][debug:023]:   Device info 'Device Info'
# [C][debug:023]:     Icon: 'mdi:chip'
# [C][debug:026]:   Free space on heap 'Heap Free'
# [C][debug:026]:     State Class: ''
# [C][debug:026]:     Unit of Measurement: 'B'
# [C][debug:026]:     Accuracy Decimals: 0
# [C][debug:026]:     Icon: 'mdi:counter'
# [D][debug:035]: ESPHome version 2024.8.3
# [D][debug:039]: Free Heap Size: 32432 bytes
# [D][debug:016]: LibreTiny Version: 1 5.1
# [D][debug:017]: Chip: BK7231N (7b1c) @ 120 MHz
# [D][debug:018]: Khip ID: 0x3AEBD4
# [D][debug:019]: Board: cbu
# [D][debug:020]: Flash: 2048 KiB / RAM: 256 KiB
# [D][debug:021]: Reset Reason: Power-On
# [D][uart_debug:114]: >>> 55 AA 00 00 00 00 FF
# [V][tuya:438]: Sending Tuya: CMD=0x00 VERSION=0 DATA=[] INIT_STATE=0
# [D][uart_debug:114]: >>> 55 AA 00 00 00 00 FF
# [V][tuya:438]: Sending Tuya: CMD=0x00 VERSION=0 DATA=[] INIT_STATE=0
# [D][uart_debug:114]: >>> 55 AA 00 00 00 00 FF
# [V][tuya:438]: Sending Tuya: CMD=0x00 VERSION=0 DATA=[] INIT_STATE=0
# [D][uart_debug:114]: >>> 55 AA 00 00 00 00 FF
# [E][tuya:464]: Initialization failed at init_state 0
# [V][tuya:438]: Sending Tuya: CMD=0x00 VERSION=0 DATA=[] INIT_STATE=0
# [D][uart_debug:114]: >>> 55 AA 00 00 00 00 FF
# [V][tuya:438]: Sendino"Tuya: CMD=0x00 VERSION=0 DATA=[] INIT_STATE=0
# [D][uart_debug:114]: >>> 55 AA 00 00 00 00 FF
# [V][tuya:438]: Sending Tuya: CMD=0x00 VERSION=0 DATA=[] INIT_STATE=0
# [D][uart_debug:114]: >>> 55 AA 00 00 00 00 FF
# [V][tuya:438]: Sending Tuya: CMD=0x00 VERSION=0 DATA=[] INIT_STATE=0
# [D][uart_debug:114]: >>> 55 AA 00 00 00 00 FF
# [V][tuya:438]: Sending Tuya: CMD=0x00 VERSION=0 DATA=[] INIT_STATE=0
# [D][uart_debug:114]: >>> 55 AA 00 00 p0 00 FF
# [E][tuya:464]: Initialization failed at init_state 0

I wish I could help - I went the local tuya route, but am not happy with that. Hope you figure it out!

Aren’t the RGB leds just SPI leds e.g. Ws2812 or similar, especially as you mention P16. See Beken SPI LED Strip — ESPHome

Bingo :smiley: Thank you!

It didn’t work with my old light. I think I borked the CBU because I cant see anymore UART logs, and it won’t flash anymore. But after I flash another light, this worked using P16 SPI

It is a ws2812b addressable light, so I’ll play with the config to get settings correct.

Thanks again!

Excellent, be sure to post your full yaml when you have it working, I’m sure others will be interested as it looks like an easy device to mod now you’ve done the hard work.

Well done.

Ended up finding https://www.elektroda.com/rtvforum/topic4057187.html last night, after trying to figure out how to bit bang gpio for ws2812b control since fastled is not supported for BK7231N.

Did the Beken light component not work then? Should be able to use that the same as the FastLed component with same effects. Though admit I can’t try.