Flashing Tuya Ceiling light

That would be the first option when you run the tool

ok ok, I just started watching video from this guy too, https://youtu.be/VFsuza3UAhk?si=FpuPbScLavCBBtdZ will this be enough for me to do it or do you have some other recommendation of what I should watch to understand it so I can do it?

Do you have recommendation on what device should I use to run coudcutter? I can buy raspberry pi 5 or I have few old laptops lying around and I also have Orange pi 5

Orange Pi 5 is good enough

It’s worth taking the time to learn how to do this kind of thing. It opens up some cool options.

You just have to follow the right guides, freak out when something doesn’t quite go to plan, and then realise it’s probably because you didn’t follow the instructions.

A good learning project.

1 Like

In the video the guy says it needs to be able to create access point but orange pi 5 doesn’t have wifi, so that won’t work right? So I am just probably going to just buy raspberry pi 5 to have something to run linux on for these projects or maybe I could run VM on my laptop?

Really? They don’t include wifi like rpi?
Then just add usb wifi adaptor to it

Sounds like you can just use a spare laptop? Dunno about the VM side of things.

Or perhaps you could buy a pi zero w.

Ok so I bought wifi dongle (TP-Link TL-WN823N) that ahould be able to create hotspot but it doesn’t work so I probably need to install drivers first amd TP-Link has manual for Ubuntu, pi3, Mint 18.03 and Kali 2018.1 so what OS should I install? I tried using Debian and using the guide for Kali but it did not work Iz failed on headers although orange pi has official installers for that

Try with armbian
Anyway if you’re still having problem getting the driver to work. Just install debian on the old laptop, connect LAN cable and cloudcutter should just the built in wifi for hotspot

If it helps, here is my howto for Tuya devices. I did use this a few weeks back so steps still valid. If you can’t cut through wifi then biggest pain is getting connections to the board.

USING TUYA-CLOUDCUTTER and LIBRETUYA for ESPHOME

REFERENCES;

a\ tuya-cloudcutter/INSTRUCTIONS.md at f1029fe5194cd09a1681090f39d38ada16763dc4 · tuya-cloudcutter/tuya-cloudcutter · GitHub
b\ click on latest release, GitHub - openshwprojects/OpenBK7231T_App: Open source firmware (Tasmota/Esphome replacement) for BK7231T, BK7231N, BL2028N, T34, XR809, W800/W801, W600/W601 and BL602
c\ Release 1.16.1 · openshwprojects/OpenBK7231T_App · GitHub
d\ How To Guide - Tuya CloudCutter with ESPHome LibreTiny - No soldering | digiblurDIY
and
https://www.youtube.com/watch?v=i9HokGpj-kE&t=1649s
e\ Flashing ESPHome - LibreTiny

The youtube video and digiblur gives good guidance. The RPi3 is already configured so as long as it is
powered up and connected to the LAN (not WiFi) then the Libretuya ESPHome fork is up and running.

1\ Launch Libretuya ESPHome, http://192.168.1.105:6052/

2\ Go +New Device, Continue, enter a name, select LibreTuya, and select board type.

3\ We now have a basic YAML file. It’s highly recommended to always include the web_server
and captive_portal components - even in your first “empty” upload. “use_address” will
be used later. For initial config I enter the actual ssid & pword.

Enable web server

web_server:
port: 80

Enable Home Assistant API

api:

ota:
safe_mode: true

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
power_save_mode: none
manual_ip:
static_ip: !secret ip_antbms1
gateway: !secret ip_gateway
subnet: !secret ip_subnet
dns1: !secret ip_dns1
#use_address: 192.168.1.28

Enable fallback hotspot in case wifi connection fails

ap: {} # This spawns an AP with the device name and mac address, no password.
#ssid: “Power-Switch1 AP”
#password: “password”

captive_portal:

4\ Save the yaml and close. Using the 3 dots, select Install, Manual download, and select Modern Format.
This will save the binaries on the RPi.

5\ Connect to the RPi using WinSCP. Navigate to the root and then opt folder. Do a search for *ug.bin and
the Focus on the result to enter the folder. Drag the required *ug.bin file to the local desktop and rename
to something meaningful. Navigate back to “/home/janos-pi/tuya-cloudcutter/custom-firmware” and drag the
bin file into this folder.

6\ SSH into the RPi and navigate to “/home/janos-pi/tuya-cloudcutter”.

7\ We first need to cut the device from Tuya cloud using tuya-cloudcutter.
-execute sudo ./tuya-cloudcutter.sh -s ssid pword -w wlan0
follow the prompts until completion. Device will now be local.
-execute sudo ./tuya-cloudcutter.sh -w wlan0 -f esphome.bin (or whatever the bin filename is)
follow the prompts until completion. Device will now have custom firmware loaded.

8\ If it fails for whatever reason and doesn’t connect to local network then it should create its own
Access Point. Use the phone to connect to this AP and load http://192.168.4.1/. From here your
can reenter WiFi credentials and/or load new firmware.

9\ If it works then the device will connect to local network and be discovered by ESPHome.

10\ To do any updates requires the Libretuya ESPHome fork. To upload just rem out the use_address line
and enter the actual IP address allocated to the device. Will compile and upload as per std ESPHome.

11\ I have soft bricked some devices so will need to try,
https://www.youtube.com/watch?v=YQdR7r6lXRY&list=PLzbXEc2ebpH0CZDbczAXT94BuSGrd_GoM

12\ I managed to soft brick a device but recovered using a USB to TTL adaptor.

  • Solder leads to the Tuya pins 3v3, gnd, tx, and rx. Connect to adaptor through a breadboard.
  • Download BK7231Flasher.exe and follow instructions in the video above.
  • It’s tricky but you need to get the Tuya into flash mode. This is done by shorting CEN pin to gnd.
    This did not work and while I was swapping the tx & rx cables it suddenly connected. I found it
    generally connected while disconnecting the +ve power while it was trying to connect.
  • It should then backup the current firmware, erase, and write new firmware.
  • Use the phone to connect to this AP and load http://192.168.4.1/. From here your can reenter
    WiFi credentials and/or load new firmware. Another option is to use WiFiman to find the device. Scan
    the ports and connect to port 80.
  • You can now disconnect from the usb adaptor.
  • The device will now have OpenBeken so it now needs to be converted to esphome.
  • When the yaml file was compiled in step 4 it also created a file called “bk7231n_app.ota.rbl” or
    whatever our device was. Grab this rbl file from build directory (note: without “UG” in the name!),
    rename it to something like OpenBK7231N_esphome.rbl (change T to N depending on the chip type), and
    drop it on the OTA panel. This is inside the WEB Application.
  • Disconnect from usb adaptor, power up, and check that all is working ok in Home Assistant. If all good
    then reassemble and it’s done.
1 Like

Ok so just an update on the cloudcutter, I ended up borrowing raspberry 4b 2g from my work and I have successfully flashes one of my plugs using this guide https://youtu.be/VFsuza3UAhk?si=FpuPbScLavCBBtdZ
By the end of the week I would like to have all of my devices flashed, I will let you know how the lights went but in any case, thank you all so much it is looking good

Very satisfying when you cut them from the cloud.:grinning:

Exactly :smiley: and it was the last realistic option from the list so I was starting to worry it wound not go the easy way but then it went through, cant wait to do the rest, I hope the lights will be possible, its the whole reason I started doing this :smiley:

Ok so I have a problem Ive got this YAML from ltchiptool, I just changed the name

esphome:
  name: stropni-svetlo-kuchyne
  friendly_name: Stropní světlo kuchyně

bk72xx:
  board: generic-bk7231n-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_cold
    pin: P26
  - platform: libretiny_pwm
    id: output_warm
    pin: P24

light:
  - platform: cwww
    id: light_cwww
    name: Light
    cold_white_color_temperature: 6500 K
    warm_white_color_temperature: 2700 K
    cold_white: output_cold
    warm_white: output_warm

remote_receiver:
  pin:
    number: P17
    inverted: true
    mode: INPUT_PULLUP
  # dump: all


but I get this error message

INFO ESPHome 2023.9.0-dev
INFO Reading configuration /config/libretuya-esphome/stropni-svetlo-kuchyne.yaml...
Failed config

output.libretiny_pwm: [source /config/libretuya-esphome/stropni-svetlo-kuchyne.yaml:33]
  
  Platform not found: 'output.libretiny_pwm'.
  platform: libretiny_pwm
  id: output_cold
  pin: P26
output.libretiny_pwm: [source /config/libretuya-esphome/stropni-svetlo-kuchyne.yaml:36]
  
  Platform not found: 'output.libretiny_pwm'.
  platform: libretiny_pwm
  id: output_warm
  pin: P24

any ideas? According to this post LibreTiny PWM Output — ESPHome everything should be all right this way but it isnt for some reason

I haven’t used pwm but here was another post for beken and pwm;

Ok so the problem was that I was using LibreTiny addon while I should have been using just normal ESPHome so I compiled it, uploaded added the integration into HA and I can sontroll the settings, well theoretically, nothing happends when I change any settings, it doesnt turn on, change color or brightness so I am again at point where I dont know what to do, I thought that ltchiptool was right, it looked right

Where did you get the pin mappings from? If I recall correctly the openbeken gui provides the pin mapping from the device as originally setup. Have not used the itchiptool.

From the lchiptools, it pulls it from the device after flashing

What is your current yaml? Don’t see any switches or controls in the one posted above.

This is my current YAML, I dont think there should be switches, its controlled by PWM

esphome:
  name: stropni-svetlo-kuchyne
  friendly_name: Stropní světlo kuchyně

bk72xx:
  board: generic-bk7231n-qfn32-tuya

# Enable logging
logger:

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

ota:
  - platform: esphome
    password: "***"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Stropni-Svetlo-Kuchyne"
    password: "***"

captive_portal:

web_server:


mdns:

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

output:
  - platform: libretiny_pwm
    id: output_cold
    pin: P26
  - platform: libretiny_pwm
    id: output_warm
    pin: P24

light:
  - platform: cwww
    id: light_cwww
    name: Light
    cold_white_color_temperature: 6500 K
    warm_white_color_temperature: 2700 K
    cold_white: output_cold
    warm_white: output_warm

remote_receiver:
  pin:
    number: P17
    inverted: true
    mode: INPUT_PULLUP
  # dump: all

Everything seems to be working just fine when I control the light while looking into console, might be wring pins, there are more pins that have PWM ability but I dont know if its safe to just try it

[12:45:53][D][text_sensor:064]: 'LibreTiny Version': Sending state 'v1.5.1 on generic-bk7231n-qfn32-tuya, compiled at Sep  6 2024 00:23:36, GCC 10.3.1 (-O1)'
[12:48:21][D][light:036]: 'Light' Setting:
[12:48:21][D][light:047]:   State: ON
[12:48:21][D][light:085]:   Transition length: 1.0s
[12:48:25][D][light:036]: 'Light' Setting:
[12:48:25][D][light:051]:   Brightness: 75%
[12:48:25][D][light:085]:   Transition length: 1.0s
[12:48:27][D][light:036]: 'Light' Setting:
[12:48:27][D][light:051]:   Brightness: 56%
[12:48:27][D][light:085]:   Transition length: 1.0s
[12:48:30][D][light:036]: 'Light' Setting:
[12:48:30][D][light:051]:   Brightness: 86%
[12:48:30][D][light:085]:   Transition length: 1.0s
[12:48:34][D][light:351]: 'Light' - Setting cold/warm white channels using white/color temperature values.
[12:48:34][D][light:036]: 'Light' Setting:
[12:48:34][D][light:066]:   Color temperature: 277.7 mireds
[12:48:34][D][light:070]:   Cold white: 90%, warm white: 100%
[12:48:34][D][light:085]:   Transition length: 1.0s
[12:48:37][D][light:351]: 'Light' - Setting cold/warm white channels using white/color temperature values.
[12:48:37][D][light:036]: 'Light' Setting:
[12:48:37][D][light:066]:   Color temperature: 228.7 mireds
[12:48:37][D][light:070]:   Cold white: 100%, warm white: 80%
[12:48:37][D][light:085]:   Transition length: 1.0s
[12:48:38][D][light:351]: 'Light' - Setting cold/warm white channels using white/color temperature values.
[12:48:38][D][light:036]: 'Light' Setting:
[12:48:38][D][light:066]:   Color temperature: 218.6 mireds
[12:48:38][D][light:070]:   Cold white: 100%, warm white: 74%
[12:48:38][D][light:085]:   Transition length: 1.0s
[12:48:39][D][light:351]: 'Light' - Setting cold/warm white channels using white/color temperature values.
[12:48:39][D][light:036]: 'Light' Setting:
[12:48:39][D][light:066]:   Color temperature: 153.8 mireds
[12:48:39][D][light:070]:   Cold white: 100%, warm white: 0%
[12:48:39][D][light:085]:   Transition length: 1.0s
[12:48:40][D][light:351]: 'Light' - Setting cold/warm white channels using white/color temperature values.
[12:48:40][D][light:036]: 'Light' Setting:
[12:48:40][D][light:066]:   Color temperature: 370.4 mireds
[12:48:40][D][light:070]:   Cold white: 0%, warm white: 100%
[12:48:40][D][light:085]:   Transition length: 1.0s