Custom firmware ESPHome-Xiaomi_bslamp2

Thanks!

OK, but is it possible to connect to the failover network and change the ssid manually? I try ssh and telnet to 192.168.4.1 but it doesn’t respond.

I want to avoid to open the lamp again.

Regards.

Hello,

I find which is the problem, the new SSID has WPA2-PSK/WPA3-SAE mixed mode encryption, and the bedlamp can not connect.

I change to WPA2-PSK encryption and now it works.

This is related to the bedlamp firmware or is ESPHome issue?

Thanks for your help.

Best regards.

The firmware fully depends on ESPHome for WiFi support, so that would be an ESPHome issue.

Hi,

Yesterday I tried to update to new version of ESPHome but unfortunatly I could not because following error:

I haven’t changed anything from previous working configuration.
As per logs I am not sure if the root cause is new version but I am unable to compile using previous one so…
Any idea what’s happening?

Thank you,

That doesn’t look like any compile issue that I have seen before.
I just upgraded ESPHome and recompiled my previous build and that worked without issues.

Maybe a clean build helps?

Might have found the cause of my lamp losing WiFi.

At about the same time as this started, I set up the sunrise effect wake-up light blueprint. Thinking this could be related, I disabled the automation and it didn’t disconnect from WiFi for a few weeks. Enabled the automation and it disconnected within a week.

@mmakaay if you have a moment, can you look over the blueprint below and see if you can find anything that would cause this issue?

Thanks!

That thing is too massive to look over it and decide if somethings causing issues.
Also, I’m wondering how it could be related to WiFi.
A single disconnect within a week also doesn’t feel like an extensive data set. It could easily be that it is not related to the blueprint.

It’s disconnected several times, at least three, with the automation enabled and zero with it disabled. Bad thing is it takes several days before it disconnects, so it’s difficult to troubleshoot.

Yes, it’s a complicated blueprint. I’ll try to look it over and figure out how it works. My guess is it’s either issuing a command the lamp doesn’t like or it’s issuing commands too quickly.

Thanks for taking a look at it.

Well, the most logical reason would be that the automation takes too much time/resources, interfering with the operation of WiFi. That would mean the automation ought to be improved.

BTW, one factor that might apply here, is that this device has a single core ESP32, meaning that the networking stack will not be running on its own thread on the second core. Because of that, this device might be more sensitive for code that is blocking the main thread (only assuming that this is the case here as a hypothesis).

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.