ESPHome integration for the Xiaomi Mijia Bedside Lamp v2.
Note: This release requires ESPHome 2023.4.0 and Home Assistant 2021.8.0 or newer.
esp_mac.h
not being found.The basic steps for upgrading are:
If you have used the example.yaml to create your configuration, then update the configuration package ref: to point to 2023.4.0
.
packages:
bslamp2:
url: https://github.com/mmakaay/esphome-xiaomi_bslamp2
ref: 2023.4.0 <--- update this one
files:
...
...
If you use a different configuration method, then make sure that the external_component: and esp32: sections match the ones from the example.yaml for this release.
Note: This release requires ESPHome 2022.12.0 and Home Assistant 2021.8.0 or newer.
ESPHome 2022.12.0 upgraded the ESP-IDF framework to 4.4.2. Changes were required to make the bslamp2 firmware compatible with this version. Without these changes, the upgrade could render the device non-functional (a.k.a. "bricked").
This release of the firmware fixes this issue, by explicitly reverting the used framework version to 4.3.2 (i.e. the previous version that was working correctly). This is a stop gap work-around at best. I am working on fully supporting the new framework version in my next release.
Basically, no. Based on user reports, there are still ways to break the operations of the lamp, depending on the exact configuration file that you use. There are no security issues, nor new functionality to enjoy, so my general recommendation for now would be to simply keep your lamp at the pre-2022.12.0 firmware.
I am in the process of getting things fixed in a future-proof way, but that depends on cooperation of the Espressif ESP-IDF team. I did a proposal for a change, as from what I see, it is going to be implemented. Once that change is in place, I can implement a new version of the firmware that should be rock solid.
Unfortunately, simply flashing the device with never firmware over a serial connection does not bring it back into working state. Things can be fixed though with a little flashing dance. Check out the instructions from the related GitHub issue report: Fix recipe from issue #104
The basic steps for upgrading are:
If you have used the example.yaml
to create your configuration, then update the configuration package ref:
to point to release/2022.12.0
.
packages:
bslamp2:
url: https://github.com/mmakaay/esphome-xiaomi_bslamp2
ref: release/2022.12.0 <--- update this one
files:
...
...
If you use a different configuration method, then make sure that the external_component:
and esp32:
sections match the ones from the example.yaml
for this release.
Note: This release requires ESPHome 2021.10.0 and Home Assistant 2021.8.0 or newer.
This release brings compatibility with ESPHome 2021.10.0.
Configuration file changes
Due to changes in ESPHome, the core configuration for the lamp had to be changed (the esphome base configuration, board configuration and I2C + GPIO hardware configuration). This means that existing configuration files have to be updated accordingly.
To make configuration as easy as possible, the example.yaml
configuration now makes use of configuration packages that are stored on GitHub. This reduces the amount of configuration that is required in your own device configuration file, making future configuration changes easier.
No more custom platform packages ESPHome 2021.10.0 has brought us support for using ESP-IDF instead of the Arduino framework. ESP-IDF is the "Espressif IoT Development Framework", which is the native development framework for ESP32 SoCs. I switched to this framework for building the lamp firmware. This made it possible to get the required ESP32 unicore support and to ignore the MAC CRC using a vanilla build. No more need for hacked up platform packages to get things going! <3
Note: This release requires ESPHome 2021.10.0 and Home Assistant 2021.8.0 or newer.
This release brings compatibility with ESPHome 2021.10.0.
Configuration file changes
Due to changes in ESPHome, the core configuration for the lamp had to be changed (the esphome base configuration, board configuration and I2C + GPIO hardware configuration). This means that existing configuration files have to be updated accordingly.
To make configuration as easy as possible, the example.yaml
configuration now makes use of configuration packages that are stored on GitHub. This reduces the amount of configuration that is required in your own device configuration file, making future configuration changes easier.
No more custom platform packages ESPHome 2021.10.0 has brought us support for using ESP-IDF instead of the Arduino framework. ESP-IDF is the "Espressif IoT Development Framework", which is the native development framework for ESP32 SoCs. I switched to this framework for building the lamp firmware. This made it possible to get the required ESP32 unicore support and to ignore the MAC CRC using a vanilla build. No more need for hacked up platform packages to get things going! <3
Note: This release requires ESPHome 2021.8.0 and Home Assistant 2021.8.0 or newer.
Random
light effect).To make use of this release, you can use the following in your YAML configuration:
external_components:
- source:
type: git
url: https://github.com/mmakaay/esphome-xiaomi_bslamp2
ref: 2021.9.1
At the time of writing, ESPHome 2021.9.0 is in beta. While testing this beta, I found that a compilation error came up in ESPHome. This release fixes that error.
This release can also be used with ESPHome 2021.8.0 and up.
To make use of this release, you can use the following in your YAML configuration:
external_components:
- source:
type: git
url: https://github.com/mmakaay/esphome-xiaomi_bslamp2
ref: 2021.9.0
Along with the new custom light transformer code (to make the firmware compatible with the latest and greatest Home Assistant and ESPHome) came some issues in transition handling. This release fixes the following issues:
Fixed transitioning from the off to on state. Thanks to @marcel1988 for informing me about his non-functional wake-up light script. Before this fix, the light would stay off during the full transformation, only to turn on at the very end.
The on_brightness
trigger is now also called at the start of a transition. This fixes a problem with the brightness slider illumination not following along when you slide your finger over it.
Suppressing a transition time for transitioning to a night light color is now only instant when starting from a night light setting. Before this change, moving from for example 80% brightness to 1% brightness (i.e. night light), would be instant. Now an actual transformation is done.
Recently, Home Assistant introduced explicit color modes (RGB, Color Temperature, etc.). ESPHome had to follow by adding color modes to its API as well. This did cause some head aches along the way. For users of the Bedside Lamp 2 most noticably the disappearing RGB and Color Temperature tabs in the GUI control panel of Home Assistant. For me as developer, various compatibility issues between my code and the progressing ESPHome code.
But the suffering should now be over 😄 With the release of ESPHome 2021.8.0, the code base has been stabilized and I can release new code that is fully compatible with ESPHome and Home Assistant again.
The changes for this release
group
and preset
) for the preset.activate
action are now validated at compile time.example.yaml
has been updated to not use underscores in the hostname anymore. Since recently, using an underscore in the name yields a warning during the firmware compilation, because hostnames can only contain letters, numbers and dashes "-".Home Assistant 2021.8.0 introduced support for Color Modes in the ESPHome integration. This release implements the required compatibility for this.
The code for this release depends on upcoming changes in ESPHome, which will be available from v1.21.0 on. Because that version is still in development, this release is published as a release candidate, so people with bleeding edge setups can test this.
Today, ESPHome v1.20.0 was released. It contains a couple of changes that I was waiting for before declaring the v1.1.0 release stable.
The main changes for this release:
See the CHANGELOG.md in the repo for a full list of changes.
Upgrading an existing lamp
When you want to upgrade, then make sure that you are running ESPHome v1.20.0 or later.
In the YAML configuration, it is best to use ref: v1.1.0
explicitly to make use of this release.
external_components:
- source:
type: git
url: https://github.com/mmakaay/esphome-xiaomi_bslamp2
ref: v1.1.0
You could also use ref: main
, but when doing so, beware that ESPHome might be running
off an older version of the code, because external_components:
doesn't currently pull fresh
code from GitHub when starting a compile.