The possibilities is quite endless, but this thread is strictly devoted to the Xiaomi bedside lamp 2. Please open a separate topic for any other integrations.
If you simply want to enable LAN mode in v1, install an old version of the Android Yeelight app from November 2020 or earlier (eg v3.2.59) from apk mirror and then enable LAN control in that. You can then uninstall the app and the setting will stay.
Thank you!
The simplest solution. I’ll go into that.
Hello, about a year and a half ago my Xiaomi Bedside Lamp 2 disconnected and since then I have not been able to reconnect it to the home network. I have tried several Routers, companies, network name, DNS … and with nothing I managed to put it on my network. Today I decided to disassemble it and inside I found an ESP32 so I thought I could reload a previous firmware with which to use it. The only thing I found is this great project but I have seen that to have it online I would have to have a Home Assistant server on a Raspberry Pi or ESPHome (I still don’t know how it works). My doubt is whether there is a way to put an official Xiaomi firmware on it and reuse it as. Thank you and regards friends.
I think you could attach the serial wires and check if you get connection. If it does, you should be able to flash an firmware to it.
Please be careful it has 110/230v in there!
Thanks for replying. I was thinking of doing that using the rx, tx , gnd and GPI0 pins that come on the board and flashing the firmware with esphomeflasher. The problem is that I don’t know how to get an original firmware
Welcome to the frustrated many Installation of Home Assistant is recommended, but I think it was Mmakaay that mentioned the possibility of controlling the lamp via MQTT. This would probably call for some alterations in the config, though. Sorry that I can’t help you with the original firmware with LAN enabled either. (I lost it together with all the others…) You will need a pre-xxxx.041 version and a old version of the app to enable LAN on your lamp.
Found the reference:
I will try to complete this project.
I’ve never done anything like it and I’ve never used Home Assistant so I’m kind of lost.
I have installed HomeAssistant in a virtual machine in VMWare, then I have added ESPHome and I have also installed ESPHomeFlasher on the PC for when I have the firmware generated by ESPHome. I have been looking at the code of example.yaml and I have some doubts:
api password → is it the password of Home Asssistant?
ota password → I don’t know what password it corresponds to?
Thanks for all this great reverse engineering work.
Not to worry, we’ve all been there and we’re still learning(I know that I am)
You have some reading to do. It may seem a bit overwhelming at first, but there will be
Have a look at ESPHome here for your questions:
https://esphome.io/components/api.html
https://esphome.io/components/ota.html
https://esphome.io/guides/faq.html
You’ve got Mmakaay to thank for this great FW
I have managed to backup the original firmware using an Arduino Nano as a USB module. If it helps someone I had to connect TX with TX and RX with RX, I will leave photos where the connections are seen.
On the other hand I have tried to put the ESPHome firmware but it seems that something is wrong in my code because the lamp did not work after that, I will check it again.
Finally, I couldn’t burn the firmware with ESPHomeFlasher, a permissions error occurred, so I had to run PowerShell as Administrator and burn the firmware using the command. If I finally get it, I’ll let you know.
Hi everyone,
Not sure if I missed something. I’ve been using the custom firmware for a while now but have not updated/upgraded in a while. I was having issues compiling and ended up killing off my entire config file, wanting to start fresh and install the firmware via the physical connections if needed. I have however not been able to compile at all and this might be where I am missing something.
I am much more comfortable with Tasmota.
I am running the latest version of Home Assistant with the latest ESPHome - I have no updates pending.
The error I get is
> INFO Reading configuration /config/esphome/caitlinlight.yaml...
> 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 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 girllight (board: esp32doit-devkit-v1; framework: espidf; platform: platformio/espressif32 @ 3.3.2)
> --------------------------------------------------------------------------------
> Tool Manager: Installing platformio/toolchain-xtensa32 @ ~2.80400.0
> Error: Could not find the package with 'platformio/toolchain-xtensa32 @ ~2.80400.0' requirements for your system 'linux_aarch64'
My config file looks like this:
# --------------------------------------------------------------------------
# Substitutions
#
# These are substitutions as used by the configuration packages from below.
# You can uncomment and update the ones that you want to modify.
# --------------------------------------------------------------------------
substitutions:
name: girllight
friendly_name: Girl Light
light_name: ${friendly_name}
#light_mode_text_sensor_name: ${friendly_name} Light Mode
#default_transition_length: 800ms
# --------------------------------------------------------------------------
# Load configuration packages
#
# These provide a convenient way to compose your device configuration from
# some functional building blocks. Pick and mix the blocks that you need.
#
# For customization you can override options in your config or you can
# copy the contents of these packages directly in your config file as
# an example for your own customizations.
#
# Available packages are:
# - core.yaml : core components & hardware setup
# - behavior_default.yaml : default device behavior
# - ota_feedback.yaml : enable visual feedback during OTA updates
# - activate_preset_svc.yaml : 'activate_preset' service for Home Assistant
# --------------------------------------------------------------------------
packages:
bslamp2:
url: https://github.com/mmakaay/esphome-xiaomi_bslamp2
ref: dev
files:
- packages/core.yaml
- packages/behavior_default.yaml
- packages/ota_feedback.yaml
- packages/activate_preset_svc.yaml
refresh: 6s
# --------------------------------------------------------------------------
# Use your own preferences for these components.
# --------------------------------------------------------------------------
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
password: !secret api_password
ota:
password: !secret ota_password
Any pointers would be appreciated.
Running HASSOS on a Pi4 with SSD
The issue with the toolchain is independent from your YAML config.
Unfortunately, it looks like the required part of the toolchain is not available for your current architecture.
Compiling on the raspberry will not work therefore.
See ESP32 S2 config file · Issue #2838 · esphome/issues (github.com)
Compiling on a different platform ought to work with your config.
Note that the lamp firmware uses the ESP-IDF framework and not the Arduino framework as its basis. One drawback from that is that ESP-IDF support is relatively new and the MQTT and webserver support have not yet been implemented. So the only control option for now is the ESPHome API, connected to Home Assistant.
Thank you for explaining this to me. I might get a friend to do the compile for me then instead in the meantime…
Yeah, that would work. Or see if you can setup a compile environment on a workstation, but that can feel a bit next-level.
Hello again, it seems that I am doing something wrong when adding a device to ESPHome in HomeAssistant because when loading the firmware the lamp stops working. I leave some screenshots of how I add it and of the .yaml code in case someone can help me:
As I know in the image, if I click on the last option, a menu opens with many types of devices and chips, maybe I have to choose one from there, but I don’t know.
I have tried with this code, and also with exameple.yaml from @mmakaay
substitutions:
name: bedside-lamp
friendly_name: Bedside Lamp
packages:
bslamp2:
url: https://github.com/mmakaay/esphome-xiaomi_bslamp2
ref: dev
files:
- packages/core.yaml
- packages/behavior_default.yaml
- packages/ota_feedback.yaml
- packages/activate_preset_svc.yaml
refresh: 0s
# Enable Home Assistant API
api:
ota:
password: "72d7ca57f3XXXXXXXXXXXXXX"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Xiaomi-Bslamp2 Fallback Hotspot"
password: "XRuHs3vyct5a"
If someone can help me to solve this error
The choices that you get when creating a new device in the dashboard are not important. The YAML file holds all configuration options for the device firmware. This means that the platform and board are also configured within the YAML file. So you could even start with an ESP8266 board initially, but when using my example.yaml the correct board is still used for the build.
In what way does the lamp stop working?
Good, when I loaded the firmware using the example.yaml file, the lamp simply didn’t turn on so I had to reload the original firmware that I had to have made a backup.
Both the backup and the firmware loading I did by commands by ESPHomeFlasher gives me permission error when trying to access the COM port. I don’t think the fault comes from not using ESPHomeFlasher since when reloading the original firmware everything worked correctly and during firmware loading no failure appears.
As I said above, I also used an Arduino Nano as a USB module and I don’t think anything from there will fail either since both when making the backup and recharging the original firmware does not fail.
The only possible flaws I see is that something got wrong in the example.yaml file or something I did wrong when installing HomeAssistant and ESPHome. Now I have hard weeks of university but as soon as I can I will get back on it and load H.A as an OS on an OdroidnC2 and start the process from 0.
Are you by any chance using Linux? If so, have you granted permissions for the user to usb?
sudo usermod -a -G dialout $USER
No, I was using Windows 11 because when installing wxPython it gave me an error and therefore I couldn’t install ESPHomeFlasher. Then I managed to install it but I couldn’t open the graphical interface.
Finally I just got it, I had to download the .exec give it permissions and give permissions to the port with
sudo chmod 777 /dev/ttyUSB0
The ocmando that you indicated to me did not work, but thanks anyway
I get a lot of permission denied errors when flashing stuff on one of my windows 11 machines.
When using esphome-flasher, I often have to unplug and replug the USB cable a few times, directly followed by a flash attempt, to get it going. It’s not esphome-flasher that is the problem here. On another machine, I can flash without having to jump the extra hoops. Something else on the machine seems to capture my COM port. Maybe this is the case for you too.
Note that ESPHome flasher will flash things like the boot loader code and partitioning layout as well, required for starting up the device. If you only flashed the firmware.bin file onto the ESP32, then things might be missing, causing a boot failure.