Once you have openbeken on the device you should see it on your lan. You then connect to this and upload your new firmware. Then it will be seen in HA. I just recovered a bricked devise and flashed a new one over the weekend. Not PC191HA’s but same process. This is my procedure for TUYA devices if it helps;
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
then 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 re-enter
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. Programme checks for BK7231N/T in the name.
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.