Custom firmware ESPHome-Xiaomi_bslamp2

Hello,

I have the bedside lamp 2 workinf great with this hack. Now I want to update but I have this error:

This is my configuration:

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 logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

wifi:
  ssid: "XXX"
  password: "XXX"


  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "BedLamp Fallback Hotspot"
    password: "XXX"


web_server:
  port: 80

Is something wrong with the configuration?

Regards.

TL;DR The web_server component is not yet implemented for the new ESPhome ESP-IDF framework support that is used by the Bedside Lamp 2 firmware. Remove the web_server component will make the compile work.

More extended info:

The Bedside Lamp firmware makes use of the new ESP-IDF support in ESPHome. This is the framework that is supplied by the ESP32 manufacturer Espressif. By doing this, the whole Arduino library layer that was used before is dropped (especially good because of its code quality and the slow updates that it gets). Also, using ESP-IDF as the framework allows for building the firmware without needing hacked up, externally maintained platform packages.

The ESP-IDF support is relatively new though (added in 2021.10.0), and not all components have been updated to work with the ESP-IDF framework yet. Some of those components are web_server and mqtt.

And that’s where the problem with your config lies. The web_server is not supported yet.
You can fix the config by removing or commenting out the following bit:

web_server:
  port: 80

Thanks!!! It works!

I remove the webserver part and now I can install the new firmware by OTA. That is great.

Is there a plan to include the webserver and mqtt for the bedlamp2 devices? It will be great to get it working.

Best regards.

As soon as the ESPHome project gets an implementation for the web_server and mqtt, those will become available automatically as usable components for the bedside lamp. So, that would be a definite yes, but the dependency is on the ESPHome project, not the lamp firmware code.

Thanks Maurice!

Hello again,

I have other question, is it possible to chage this name?

Light 'Bedside Lamp RGBWW Light'

It appears in HA and I can not change it:

bedside2

This firmware is perfect!

Best regards.

Hi,

You can add the following lines at the begin (line 1) of your yaml:

substitutions:
  friendly_name: "your wanted name here" 

Thanks!

I will try it in the HA configuration.

No, you have to add these lines in you esphome yaml file for the lamp and compile it again. Also remove the HA integration for the lamp and reinstall it after you compiled the firmware with the new name.

Thanks!

I got it!

Best regards.

Finally!!! At last I found the time during the Christmas holidays to update my lamp with the code from Maurice - Thank you for all of the hard work.
Some feedback from my experience:

  • Get familiar with ESPHome before starting and make a simple project
  • Find that really small soldering iron bit
  • A small breadboard is really good for making the connections to DuPont wires
  • The config is a bit tricky as there have been some updates to ESPHome and frameworks

https://theoatmeal.com/comics/creativity_breathing?fbclid=IwAR1-pmL07Qe1SN3wsSAxMqHSWgi1rS8owujTPSVuu8fqiNV9jLi25CEtyVw

Haha, yeah, that helps a lot!
The pictures make it look like there are huge soldering pads on there.
In reality, they are tiny :smiley:

Thanks for the sponsoring, it’ll be put to good use!

Hi there!!!

I’m quite interested in this project since I have a bslamp2 with the last firmware.
But I don´t know how to install this. I have a lot of ESPhome devices, but if I try to install the example.yaml I get a lot of errors, like this:

INFO Reading configuration /config/esphome/xiaomi-bedside.yaml...
INFO Updating https://github.com/mmakaay/esphome-xiaomi_bslamp2@main
ERROR Unable to import component xiaomi_bslamp2.light:

ImportError: cannot import name 'I2CComponent' from 'esphome.components.i2c' (/usr/local/lib/python3.9/dist-packages/esphome/components/i2c/__init__.py)
ERROR Unable to import component xiaomi_bslamp2.text_sensor:

ImportError: cannot import name 'I2CComponent' from 'esphome.components.i2c' (/usr/local/lib/python3.9/dist-packages/esphome/components/i2c/__init__.py)
ERROR Unable to import component xiaomi_bslamp2.output:

ImportError: cannot import name 'I2CComponent' from 'esphome.components.i2c' (/usr/local/lib/python3.9/dist-packages/esphome/components/i2c/__init__.py)
ERROR Unable to import component xiaomi_bslamp2.binary_sensor:

ImportError: cannot import name 'I2CComponent' from 'esphome.components.i2c' (/usr/local/lib/python3.9/dist-packages/esphome/components/i2c/__init__.py)
ERROR Unable to import component xiaomi_bslamp2.sensor:

Unable to find action with the name 'preset.activate'.
Unable to find action with the name 'light.disco_on'.
Unable to find action with the name 'front_panel.set_level'.
Unable to find action with the name 'light.disco_on'.
Unable to find action with the name 'light.disco_on'.

Platform not found: 'light.xiaomi_bslamp2'.
Platform not found: 'text_sensor.xiaomi_bslamp2'.
Platform not found: 'output.xiaomi_bslamp2'.
Platform not found: 'binary_sensor.xiaomi_bslamp2'.
Platform not found: 'binary_sensor.xiaomi_bslamp2'.
Platform not found: 'sensor.xiaomi_bslamp2'.

I guess I have to install the repository somewhere but I don´t know jow and where

Which version of ESPHome are you using? Make sure you are using ESPHome 2021.10.0 or newer.

1 Like

I’m using 2021.12.3, the last one.

image

You don’t have to install the repository. It is included by means of the external_component feature of ESPHome. Did you use the base example.yaml configuration file as the starting point? That contains everything that is needed to build the firmware. The included core.yaml configuration package takes care of setting up the required external component.

1 Like

Hi!

I was using another example.yaml . With the one you gave me I don´t have any errors, but can I use that code to control my lamp?, or should I add extra lines?. Sorry is the firs time that I saw the packages

All aspects of the lamp can be controlled by ESPHome.
The example configuration provides a basic setup that acts a lot like the original firmware.
If you want specific behavior that is not covered by the default configuration, then you can use all features of ESPHome to get the required behavior.

All YAML config control options can be found in the documentation

1 Like

Thanks @mmakaay. I’ve installed the firmware and the lamp is working fine

Good job!

1 Like

Hi guys!
Do you think it’s possible to to the same with bedside V1?