Support for SwitchBot Plug Mini (W1901400) with bluetooth proxying

Great write-up! I think about converting mine to ESPHome as well. BTW, what do you mean by “legacy format” for ESPHome Firmware?

In the ESPHome interface when you click Install then “Manual Download” it offers you options for either the “Modern format” or “Legacy format”, I selected Legacy.

Thanks! I only used command line for OTA, didn’t know those options from GUI.

Great work! Can you check if BLE Gateway works in this device?

I tried loading it up and can see it detecting BLE packets so think it should be good. At some point I’ll likely replace my existing BLE gateway devices with these but they’re already working well so not a priority.

As an alternative to ESPHome, you can use Tasmota32 Bluetooth firmware with the Switchbot Mini Plug to get reliable BLE updates from temp sensors like the Xiaomi LYWSD03MMC. See my write up here: Using Switchbot Mini Plug with Tasmota32 and MQTT as BLE Gateway for Xiaomi LYWSD03MMC Temp Sensors

Thanks for posting this, just saw the plugs on Slickdeals and glad I found your thread!

YW. That was a great deal for the plugs :+1:

Hey @taylormia & @apnar I’ve done the initial flash from official to tasmota and want to move it to esphome.

I’m worried that if I flash something incorrect that I won’t be able to recover it without opening up the physical smart plug – so I’m trying to think of all situations on how I can maintain access through esphome.

I noticed that the captive portal throws an error on the YAML. Does the AP under the wifi section still work even if captive portal is not in the config?

I also came across BLE Improv Component – can I add this on the first flash to use this to recover in the event of incorrect wifi credentials or are the BLE features not enabled until I add this on the second flash:

    sdkconfig_options:
      CONFIG_BT_BLE_50_FEATURES_SUPPORTED: y
      CONFIG_BT_BLE_42_FEATURES_SUPPORTED: y
      CONFIG_ESP_TASK_WDT_TIMEOUT_S: "10"

thanks for your input!

I’m using only the Tasmota BLE functions of the ESP32 via Tasmota32 firmware. I’m not using ESPHome - so can’t help you.

1 Like

@LUNZ I haven’t used either of the components you reference so I can’t confirm they’d work. I will say that I did try doing the initial Tasmota to ESPHome conversion flash with the config options and ble config in place and that was successful so a step wise approach isn’t necessarily required.

1 Like

Thank you!

Does the official Bluetooth Proxy feature work with these BLE sdkconfig options? Has anyone tried the new active BLE proxy option?

I see that esp32_ble_tracker does seem to work on the plugs, and that bodes well because the Bluetooth Proxy component documentation says that it depends on this.

But then the Bluetooth Proxy feature page says that “This option only works for “plain” ESP32 and not for ESP32-C3 or other variants”…

I decided to give this a try today and to my surprise it seems to work!

Added the following to my config:

esp32_ble_tracker:
  scan_parameters:
    interval: 1100ms
    window: 1100ms
    active: true

bluetooth_proxy:
  active: true

I haven’t tried any active connections yet but I do seem to be getting some BLE packets hitting my BLE monitor and into iBeacon. I’ll update the top post.

2 Likes

When I included the scan_parameters: elements my plug stopped connecting over WiFi. This meant I had to disassemble the plug and re-flash over serial.

After reverting to an empty esp32_ble_tracker: entry and flashing using https://web.esphome.io, I ran into a boot loop which was solved with:

esphome:
  # only needed for initial UART flash
  # can be removed for subsequent uploads
  platformio_options:
    board_build.flash_mode: dio  

Hopefully this was a one-time glitch, but in case it wasn’t I’ll be sticking to the default values for esp32_ble_tracker or possibly even removing it entirely.

1 Like

Hi,

I am trying to use SwitchBot Plug Mini as a Bluetooth Proxy.

After some effort, I was able to flash Tasmota on my SwitchBot Plug Mini, largely with the help of this video:: NO Solder Upgrade SwitchBot ESP32-C3 Plug & Bulb to TASMOTA or ESPHome

When I go to use @apnar 's ESPHome config (after putting in my wifi information and removing the api and ota passwords), I get the following error:

Error: Could not find the package with ‘espressif/toolchain-xtensa-esp32s2 @ 8.4.0+2021r2-patch2’ requirements for your system ‘linux_aarch64’

Any idea how to get past this?

Just guessing here, but it looks like you’re trying to run ESPHome on a box with an arm processor and one of the needed components in the toolchain isn’t available for arm. I’ve only run ESPHome on x86 (amd64) machines so don’t know how well it is supposed to work on arm.

I am running Home Assistant on a Raspberry Pi 4.

It looks like you were right! I loaded up HassOS on a virtual machine, installed the ESPHome add on, created and uploaded the firmware with your config and it seems to be working now.

Hopefully an update will come out that will allow this to work on arm processors.

Thanks for your help.

Has anyone figured out a way to hard reset these after getting Esphome loaded? I must have screwed something up in the yaml causing 2 of my plugs to not connect to my home wifi. I can see it has defaulted to its own AP but connecting to that does not give out an IP. I tried manually setting my device to something in the 192.168.4.x network but I cannot ping 192.168.4.1.

Other than figuring out how to open the plug up I’m guessing its bricked?

The partition table that is generated here switchbota/part.csv at b622e9096dcbfd76caaa33ef2293c4743b4ce57f · kendallgoto/switchbota · GitHub might not be large enough for the Bluetooth proxies so the performance might be slow connecting to devices unless you do a serial flash