More Light Programming

Building on yesterdays blog post, today I was tidying up my basement and realized I had 10 Recessed RGB CT lights (Globe Lighting 50323) that used Tuya and the BK7231 chipset and I could use Tuya Cloudcutter again!

Table of Contents

Plugging the devices in

I am not an electrian, this is not professional advice, seek the advice of a professional before doing this!

These devices are in two parts:

  • The 120VAC regulator -> I’m not 100% certain what the output is here, but the actual light itself connects to a 2 pin, polarised, and threaded connection
  • The light -> This has the chip in a box on the cable that connects to the light itself.

And the regulator as I’m calling it, even uses push connectors so no need to worry about marettes getting disconnected.

I connected a fused plug to a length of solid core Romex (grounded!), connected it to the push connectors in the box, and then plugged that into one of my previously flashed smart plugs so I could easily toggle the power.

Because the light itself has the chip in it, if you’re doing a bunch of these in a row, I found it easiest to

  • Turn off the outlet (you don’t want any live power when swapping out the light, it may spark if you do and this feels sketchy dangerous to me)
  • Disconnect the two pole light
  • Plug the new light in

To reset the device for AP mode, I just used the button on the smart plug, I could probably have written an automation to do this in Home Assistant, and if I was doing more than 10, I may have.

These used the usual 3x powercycle for EZ Flash mode, then 3x powercycle for API mode.

Cut the Cloud!

This time, I decided to “optimize” my flashing process.

  1. Create all my configurations in ESPHome Builder
  2. Build all the Tuya Cloudcutter .ug.bin files
  3. Immediately flash each device with the fully configured ESPHome firmware

Step One: Configs

So a quick google for ESPHome 50323 didn’t return me any preconfigured configurations, however, the awesome team at LibreTiny have a tool that can create the ESPHome config for you

The URLs even let you share the direct profile: https://upk.libretiny.eu/?profile=globe-electric-50323-rgbct-recessed-light

Now, I made some minor tweaks to this:

  • Use a substitutions block to set numbers on these (I realize there’s some duplications, but I don’t mind too much)
  • Remove the password from API (I’ve never needed this, I think ESPHome will inject it automatically for me)
  • Remove the password field from ota, I’m not sure why this is needed, but my other devices don’t have it. And if I want to reintroduce it, I just need to update my devices from ESPHome builder which is nice and fast.

So here’s my globe-50323-1.yaml, as with the previous blog post, I just needed to duplicate this file 9 times since I have ten lights! Updating the number line for each one.

substitutions:
  number: "1"
  # Default name
  name: "globe-50323-rgbct-recessed-${number}"
  # Default friendly name
  friendly_name: "Globe Lighting 50323 Recessed RGBCT Light (${number})"

esphome:
  name: "${name}"
  friendly_name: "${friendly_name}"

bk72xx:
  board: generic-bk7231t-qfn32-tuya

logger:

web_server:

captive_portal:

mdns:

api:

ota:
  platform: esphome

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

I did check this manually on one device first to make sure it fully worked before building the remaining 9

Step Two: Build the files

This time, from ESPhome Builder, when I selected install manually, I chose to download the Cloudcutter Image

This I downloaded to the tuya-cloudcutter/custom-firmwares folder (fun fact I discovered, anything in this directory becomes an optional target when going through the manual process to select a firmware)

Step 3: Flash the devices

As with the previous builds, the first time through I manually selected the device profile from the Command line interface, this gave me the following configuration output:

Selected Device Slug: globe-electric-50323-rgbct-recessed-light
Selected Profile: oem-bk7231s-light5-sleepwake-random-globe-1.1.0-sdk-1.0.2-40.00
Selected Firmware: globe-50323-rgbct-recessed-1-ota.ug.bin

As before, the device slug and selected firmware where the bits I needed for the CLI invocation:

sudo ./tuya-cloudcutter.sh -p globe-electric-50323-rgbct-recessed-light -f globe-50323-rgbct-recessed-1-ota.ug.bin

And I just needed to run this manually for each device and increment the -1- for each device. Nice and simple.

And done

Here’s my victory photo of a pile of flashed and labelled lights!

A friend who saw this photo is currently in a debate with me about whether the green label printer tape makes me good or evil. Maybe I should have used red….

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *