[report of a successful conversion]
I’ve recently bought a WiFi-controlled power strip, branded Lellki. I found it was interesting with 4 controlled plugs and a physical button next to each of them.
After taking it down (locked by triangle-shaped screws), it turned out it was based on the CBU (bk7231n) board.
I’ve tried my luck on it and installed ESPHome 2023.9.0b1 (pre-release) that sports a new integration: Support for LibreTiny platform (RTL8710, BK7231 & other modules).
I haven’t tried the tuya-convert method.
Instead, I’ve soldered wires to some pins of the board, connected to the FT232RL serial adapter, connected its USB cable to the server hosting ESPHome (running in a container on OpenMediaVault 6.8 with the compose plugin) and flashed using the option : Plug into the computer running ESPHome Dashboard
.
Here is a working YAML configuration with the pins :
substitutions:
name: esphome-powerstrip
friendly_name: powerstrip
comment: Lellki 4-plugs power strip, based on CBU board
log_level: INFO
bk72xx:
board: cbu #almost equivalent to : generic-bk7231n-qfn32-tuya
status_led:
pin:
number: P28
inverted: false
id: led_blue
switch:
- platform: gpio
name: ${friendly_name} Relay 1
id: relay1
pin: P14
icon: mdi:power-socket-fr
restore_mode: RESTORE_DEFAULT_ON
- platform: gpio
name: ${friendly_name} Relay 2
id: relay2
pin: P15
icon: mdi:power-socket-fr
restore_mode: RESTORE_DEFAULT_ON
- platform: gpio
name: ${friendly_name} Relay 3
id: relay3
pin: P16
icon: mdi:power-socket-fr
restore_mode: RESTORE_DEFAULT_ON
- platform: gpio
name: ${friendly_name} Relay 4
id: relay4
pin: P17
icon: mdi:power-socket-fr
restore_mode: RESTORE_DEFAULT_ON
binary_sensor:
- platform: gpio
pin: P22 #main button
id: "${friendly_name}_button_state0"
on_press:
then:
- if:
condition:
and:
- switch.is_off: relay1
- switch.is_off: relay2
- switch.is_off: relay3
- switch.is_off: relay4
then:
- switch.turn_on: relay1
- switch.turn_on: relay2
- switch.turn_on: relay3
- switch.turn_on: relay4
else:
- switch.turn_off: relay1
- switch.turn_off: relay2
- switch.turn_off: relay3
- switch.turn_off: relay4
- platform: gpio
id: button1
pin: P10
on_press:
- switch.toggle: relay1
- platform: gpio
id: button2
pin: P24
on_press:
- switch.toggle: relay2
- platform: gpio
id: button3
pin: P26
on_press:
- switch.toggle: relay3
- platform: gpio
id: button4
pin: P9
on_press:
- switch.toggle: relay4
### below : common yaml code used in all other projects
esphome:
name: ${name}
comment: ${comment}
logger:
level: ${log_level}
api:
encryption:
key: !secret api_encryption_key
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: ${friendly_name} Fallback Hotspot
password: !secret wifi_ap_password
ap_timeout: 3min
Last note : this device contains a power meter, but I haven’t been able to make it work : the sensor shows up in Home Assistant, but reported states are always 0. Below the yaml code anyway.
# Configuration entry for device BL0937 using inverted SEL pin functionality
sensor:
- platform: hlw8012
model: BL0937
sel_pin:
number: P8
inverted: true
cf_pin: P6
cf1_pin: P7
current:
name: "BL0937 Current"
voltage:
name: "BL0937 Voltage"
power:
name: "BL0937 Power"
update_interval: 10s