Custom firmware ESPHome-Xiaomi_bslamp2

Hello,

I use the lamp as a wake up lamp for mornings, it really work great. But I have a little problem, I want to power on the lamp with a fixed color, it always power on with the last color I use. Is it possible to power on the lamp with red color always?

I have this in HA:

Thanks for your help.

Regards.

Instead of using “Device” as the action type, you can use “Call service” instead. That route gives you a lot more control over the action to perform. This is how you would set “red” in that config:

1 Like

Thanks!

Yes, this way really have more configuration.

Best regards.

Hi! This is a great job, congratulations!!!

I want to install this custom firmware to the lamp (because it stops to work anymore).

I follow the steps on the guide:
I already did all the connections with the serial USB and it’s connected.
I did a copy of the original firmware and it’s done.
But… I can’t generate the firmware, because I don’t know how.

I have HA in docker, so I don’t have Supervisor, so I don’t have ESPHome as an addon, I have ESPHome in docker too, and I don’t know how to create the firmware in this situation.

Can someone help me, please?

Thanks in advance

Finally, I get it, with the docker instance of ESPHome, I can manage the device and compile the firmware.

And… it’s working again :slightly_smiling_face:

Works like a charm!!! Thank you so much!!!

Ah, great that you got it to work already!
Enjoy your lamp :grinning_face_with_smiling_eyes:

1 Like

Hello, the track broke and I had to solder directly on ESP32, is this correct?


As I saw some image above it seems correct but it does not seem to work like that. Any ideas?

Another question that maybe goes away from this project… would it be possible to have WLED using this main board?

Thanks!!

The pad that broke is TX. That corresponds to the pin that you soldered to now. So that looks okay to me. Maybe try reversing RX/TX on the nano? I never used that setup to flash, but if you get no results at all, then reversing them might be a plan.

I have exactly zero knowledge about the WLED implementation. I am pretty convinced that you won’t be able to use this directly with WLED, because WLED is about Neopixel and not at all about the kind of circuitry that is used for this lamp.

Hello mmakaay. Again with the update ESPHome version: 2022.2.3 broke. The firmware stopped building.

Without any log info no one can help you. Just compiled the custom firmware with version 2022.2.3 and had only the warning about the strapping pin as described on the github page.

What did you changed in the YAML file? If you didn’t changed anything and the lamp is working fine, then there is no reason to build the firmware again just because there is a new version of ESPHome.

I’ve got the same experience as @jsuanet
I have upgraded three devices using 2022.2.3 and compilation worked perfectly.
So please share logging that shows us what goes wrong. Maybe try a clean build to make sure that you’re using the same build as us.

Yes, please, here is the log.

INFO Reading configuration /config/esphome/example.yaml…
INFO Updating https://github.com/mmakaay/esphome-xiaomi_bslamp2@dev
INFO Updating https://github.com/mmakaay/esphome-xiaomi_bslamp2@dev
WARNING GPIO12 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See Frequently Asked Questions — ESPHome
WARNING GPIO4 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See Frequently Asked Questions — ESPHome
INFO Generating C++ source…
INFO Compiling app…
Processing bedside-lamp (board: esp32doit-devkit-v1; framework: espidf; platform: platformio/espressif32 @ 3.5.0)

HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

  • framework-espidf 3.40302.0 (4.3.2)
  • tool-cmake 3.16.9
  • tool-ninja 1.10.2
  • toolchain-riscv32-esp 8.4.0+2021r2-patch2
  • toolchain-xtensa-esp32 8.4.0+2021r2-patch2
  • toolchain-xtensa-esp32s2 8.4.0+2021r2-patch2
    Reading CMake configuration…
    – The C compiler identification is unknown
    – The CXX compiler identification is unknown
    – The ASM compiler identification is unknown
    – Found assembler: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc
    – Check for working C compiler: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc
    – Check for working C compiler: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc – broken
    – Configuring incomplete, errors occurred!
    See also “/data/bedside-lamp/.pioenvs/bedside-lamp/CMakeFiles/CMakeOutput.log”.
    See also “/data/bedside-lamp/.pioenvs/bedside-lamp/CMakeFiles/CMakeError.log”.

fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
CMake Error at /data/cache/platformio/packages/tool-cmake/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler

"/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /data/bedside-lamp/.pioenvs/bedside-lamp/CMakeFiles/CMakeTmp

Run Build Command(s):/data/cache/platformio/packages/tool-ninja/ninja cmTC_358ed && [1/2] Building C object CMakeFiles/cmTC_358ed.dir/testCCompiler.c.obj
FAILED: CMakeFiles/cmTC_358ed.dir/testCCompiler.c.obj 
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc   -mlongcalls -Wno-frame-address -o CMakeFiles/cmTC_358ed.dir/testCCompiler.c.obj   -c testCCompiler.c
/bin/sh: 1: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc: not found
ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
/data/cache/platformio/packages/framework-espidf/tools/cmake/project.cmake:311 (__project)
CMakeLists.txt:3 (project)

========================= [FAILED] Took 10.56 seconds =========================

What kind of environment are you using? If I use the official Docker v2022.2.3 container, the version numbers of tool-cmake and tool-ninja are different form the version numbers in your logging. See part of my logging:

root@460aa5c81b45:/config# esphome compile study-lamp.yaml 
INFO Reading configuration study-lamp.yaml...
INFO Updating https://github.com/mmakaay/esphome-xiaomi_bslamp2@release/2021.10.0
INFO Updating https://github.com/mmakaay/esphome-xiaomi_bslamp2@release/2021.10.0
WARNING GPIO12 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO4 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
INFO Generating C++ source...
INFO Compiling app...
Processing study-lamp (board: esp32doit-devkit-v1; framework: espidf; platform: platformio/espressif32 @ 3.5.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - framework-espidf 3.40302.0 (4.3.2) 
 - tool-cmake 3.16.4 
 - tool-ninja 1.7.1 
 - toolchain-riscv32-esp 8.4.0+2021r2-patch2 
 - toolchain-xtensa-esp32 8.4.0+2021r2-patch2 
 - toolchain-xtensa-esp32s2 8.4.0+2021r2-patch2
Reading CMake configuration...
Generating assembly for certificate bundle...
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
No dependencies
Compiling .pioenvs/study-lamp/src/esphome/components/api/api_connection.o

And in your logging it is ‘cmake’ who is complaining.

Deleted all files. Installed on a new one with git. Still gives an error. It is not clear what could be.


HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

  • framework-espidf 3.40302.0 (4.3.2)
  • tool-cmake 3.16.9
  • tool-ninja 1.10.2
  • toolchain-riscv32-esp 8.4.0+2021r2-patch2
  • toolchain-xtensa-esp32 8.4.0+2021r2-patch2
  • toolchain-xtensa-esp32s2 8.4.0+2021r2-patch2
    Reading CMake configuration…
    – The C compiler identification is unknown
    – The CXX compiler identification is unknown
    – The ASM compiler identification is unknown
    – Found assembler: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc
    – Check for working C compiler: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc
    – Check for working C compiler: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc – broken
    – Configuring incomplete, errors occurred!
    See also “/data/bedside-lamp/.pioenvs/bedside-lamp/CMakeFiles/CMakeOutput.log”.
    See also “/data/bedside-lamp/.pioenvs/bedside-lamp/CMakeFiles/CMakeError.log”.

fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
CMake Error at /data/cache/platformio/packages/tool-cmake/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler

"/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /data/bedside-lamp/.pioenvs/bedside-lamp/CMakeFiles/CMakeTmp

Run Build Command(s):/data/cache/platformio/packages/tool-ninja/ninja cmTC_11e30 && [1/2] Building C object CMakeFiles/cmTC_11e30.dir/testCCompiler.c.obj
FAILED: CMakeFiles/cmTC_11e30.dir/testCCompiler.c.obj 
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc   -mlongcalls -Wno-frame-address -o CMakeFiles/cmTC_11e30.dir/testCCompiler.c.obj   -c testCCompiler.c
/bin/sh: 1: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc: not found
ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
/data/cache/platformio/packages/framework-espidf/tools/cmake/project.cmake:311 (__project)
CMakeLists.txt:3 (project)

========================= [FAILED] Took 10.14 seconds =========================

I deleted esphome. I installed it again, I still get an error. Here is the esphome installation log


Platform Manager: Installing platformio/espressif32 @ 3.5.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Platform Manager: espressif32 @ 3.5.0 has been installed!
The platform ‘platformio/espressif32 @ 3.5.0’ has been successfully installed!
The rest of the packages will be installed later depending on your build environment.
Tool Manager: Installing platformio/toolchain-esp32ulp @ ~1.22851.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: toolchain-esp32ulp @ 1.22851.191205 has been installed!
Tool Manager: Installing espressif/toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch2
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch2 has been installed!
Tool Manager: Installing espressif/toolchain-xtensa-esp32s2 @ 8.4.0+2021r2-patch2
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: toolchain-xtensa-esp32s2 @ 8.4.0+2021r2-patch2 has been installed!
Tool Manager: Installing espressif/toolchain-riscv32-esp @ 8.4.0+2021r2-patch2
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: toolchain-riscv32-esp @ 8.4.0+2021r2-patch2 has been installed!
Tool Manager: Installing platformio/framework-espidf @ ~3.40302.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: framework-espidf @ 3.40302.0 has been installed!
Tool Manager: Installing platformio/tool-esptoolpy @ ~1.30100.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: tool-esptoolpy @ 1.30100.210531 has been installed!
Tool Manager: Installing platformio/tool-cmake @ ~3.16.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: tool-cmake @ 3.16.9 has been installed!
Tool Manager: Installing platformio/tool-ninja @ ^1.7.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: tool-ninja @ 1.10.2 has been installed!
Tool Manager: Installing platformio/tool-scons @ ~4.40300.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
Tool Manager: tool-scons @ 4.40300.1 has been installed!
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

  • framework-espidf 3.40302.0 (4.3.2)
  • tool-cmake 3.16.9
  • tool-ninja 1.10.2
  • toolchain-riscv32-esp 8.4.0+2021r2-patch2
  • toolchain-xtensa-esp32 8.4.0+2021r2-patch2
  • toolchain-xtensa-esp32s2 8.4.0+2021r2-patch2
    Installing ESP-IDF’s Python dependencies
    Collecting future>=0.15.2
    Downloading future-0.18.2.tar.gz (829 kB)
    Collecting pyparsing<2.4.0,>=2.0.3
    Downloading pyparsing-2.3.1-py2.py3-none-any.whl (61 kB)
    Building wheels for collected packages: future
    Building wheel for future (setup.py): started
    Building wheel for future (setup.py): finished with status ‘done’
    Created wheel for future: filename=future-0.18.2-py3-none-any.whl size=491058 sha256=18aff064aa447b43e3ebac825a7e4051696dd5017aeb8ae0619cb22a1fbfc7b5
    Stored in directory: /root/.cache/pip/wheels/2f/a0/d3/4030d9f80e6b3be787f19fc911b8e7aa462986a40ab1e4bb94
    Successfully built future
    Installing collected packages: pyparsing, future
    Successfully installed future-0.18.2 pyparsing-2.3.1
    Reading CMake configuration…
    – Found Git: /usr/bin/git (found version “2.30.2”)
    – The C compiler identification is unknown
    – The CXX compiler identification is unknown
    – The ASM compiler identification is unknown
    – Found assembler: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc
    – Check for working C compiler: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc
    – Check for working C compiler: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc – broken
    – Configuring incomplete, errors occurred!
    See also “/data/bedside-lamp/.pioenvs/bedside-lamp/CMakeFiles/CMakeOutput.log”.
    See also “/data/bedside-lamp/.pioenvs/bedside-lamp/CMakeFiles/CMakeError.log”.

fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
CMake Error at /data/cache/platformio/packages/tool-cmake/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler

"/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /data/bedside-lamp/.pioenvs/bedside-lamp/CMakeFiles/CMakeTmp

Run Build Command(s):/data/cache/platformio/packages/tool-ninja/ninja cmTC_c7083 && [1/2] Building C object CMakeFiles/cmTC_c7083.dir/testCCompiler.c.obj
FAILED: CMakeFiles/cmTC_c7083.dir/testCCompiler.c.obj 
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc   -mlongcalls -Wno-frame-address -o CMakeFiles/cmTC_c7083.dir/testCCompiler.c.obj   -c testCCompiler.c
/bin/sh: 1: /data/cache/platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc: not found
ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
/data/cache/platformio/packages/framework-espidf/tools/cmake/project.cmake:311 (__project)
CMakeLists.txt:3 (project)

========================= [FAILED] Took 277.24 seconds =========================

What operating system are yo using and how do you install esphome? Did you try to use the docker container?

Operating System
Raspbian GNU/Linux 10 (buster)

Docker version
20.10.7

image

What’s /data/cache? Is that something from your own setup?
The error “Stopping at filesystem boundary” is the most suspicous bit for me.
Is /data/cache a different docker volume from /data/bedside-lamp for example?

I’m quite sure that this is not an issue of the bslamp2 component code, since things are building correctly for me and @jsuanet using a vanilla container.

Hello. The example.yaml file itself is not corrected, only the wi-fi network and pass are registered as a secret. I don’t change anything else.

I have no doubt that the lamp config is correct. This is not an issue with the config, but a problem with the build setup. More interesting is how the docker container is started exactly here. What is your configuration for that?
When things keep failing, then maybe start a new specific topic for this in the ESPHome group, since it’s not firmware related.

Please check out this ESPHome issue:
Maybe there’s s work-around for your system.

(Thanks to @jsuanet for sending me the link)