kendallgoto / switchbota

Replaces the factory firmware on the SwitchBot Plug Mini via OTA, enabling the use of Tasmota without disassembling the unit.
GNU General Public License v3.0
105 stars 17 forks source link

Switchbot Plug Mini: HomeKit Version #19

Closed kendallgoto closed 2 years ago

kendallgoto commented 2 years ago

SwitchBot has already released the first new rev of the Plug Mini, featuring HomeKit support.

I haven't yet reviewed the HomeKit revision hands-on and SwitchbOTA support for it is not confirmed or guaranteed. I'm opening this thread for discussion into the revision relating to its internal hardware, Tasmota, and SwitchbOTA.

kendallgoto commented 2 years ago

HW: The overall product looks about identical. There was some Homekit-related differences on the packaging. The product model number has been bumped to W1901401. The manufacturing datecode on my new one says 2223 versus 2209 on my old one. Presumably this is 2022 week 23 (early june) compared to week 09 (early march). This corresponds to their rough release + presumed manufacturing dates. All of the 50 plugs I bought shortly after release shared a 2022-09 build date, so this is actually my first time seeing a non-first batch build. FCC ID, etc remained the same. Internally, they've added a loose piece of heatsink around the LED and the LED guide hole, presumably to prevent light leakage through the button hole and power socket. I doubt this is unique to the HK version though, and is just something they started to do after the first manufacturing run. A homekit sticker + info card is included in the box. They've switch the main PCB color to white instead of green, for style points presumably. The original date code on my first batch was 211119 (2021-11-19?) whereas my HK version says 220302. Given the build date, I assume they've been using these white PCB revisions for a while, I just have a PCB from an early batch / qualified PVT run or something (the product actually released in March, so this white board is still before the original release date). The ESP32-C3 module is dated 2212 (2022, 12th week) - so I guess the ESP32-C3 module lagged behind the mainboard. My original module looks identical, but has no printed date code. The new board is labeled with PLUG_ESP-C3_V1.3, same as the original. The homekit version actually had a Homekit sticker on the module itself. Presumably, the Homekit modules were made in a later batch and prepared+flashed with Homekit versions and just drop-in replaced on the existing plug mini boards. For this reason, I don't expect there to be any real differences between the Homekit version and the regular version of the plugs, besides the existence of Homekit keys on the newer versions. This also means you could likely "upgrade" a regular plug to be a Homekit plug. Although, for the purposes of Tasmota, who cares?

Overall summary on HW: they price differentiate the homekit version ~$5 more than the regular. However, that price differentiation appears to only matter in the software + otherwise the plugs are the same.

kendallgoto commented 2 years ago

FW: The device arrived flashed with v1.4 (http://www.wohand.com/version/wocaotech/firmware/WoPlugUS/WoPlugUS_V14.bin) When I flashed it back to v1.2, it came up in the app as a regular, non-homekit plug. Then I flashed to v1.4 again and it was recognized as a Homekit plug and had the homekit features enabled in the app.

# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
phy_init,data,phy,0x9000,4K,
otadata,data,ota,0xa000,8K,
keydata,data,254,0xc000,8K,
nvs,data,nvs,0xe000,24K,
region,data,253,0x14000,4K,
factory_nvs,data,nvs,0x15000,16K,
energydata,data,fat,0x19000,24K,
ota_0,app,ota_0,0x20000,1904K,
ota_1,app,ota_1,0x220000,1904K,

There was an added hap_ctrl section of NVS, which presumably stands for Homekit Accessory Protocol. Based on this, I assume the underlying module used is https://github.com/espressif/esp-homekit-sdk, which would make sense anyway. I didn't really want to dive too deeply into the Homekit specification, but presumably Switchbot is using all the off-the-shelf tooling from Espressif in order to bring up their devices on Homekit and provision the NVS in the factory. As per https://github.com/espressif/esp-homekit-sdk/tree/master/tools/factory_nvs_gen, it looks like the factory_nvs partition holds the base setup_id, setup_code, and setup_verifier used for homekit.

I noted above that the firmware was V1.4 -- Interestingly, this firmware binary differs from the original V1.4 I discovered on the Switchbot S3 servers back in April. This new firmware is dated May 9th 2022 3:24:15 GMT. V1.3 is still dated from March and V1.5 does not exist.

kendallgoto commented 2 years ago

FCC: Interestingly, the FCC info also came out recently and I haven't written anywhere about it. It's accessible here https://fccid.io/2AKXB-W1901400 but was sealed until mid-June 2022. In it, its written that all model numbers W1901400, W1901401, W1901402, W1901403, W1901404, W1901405 are identical electronically and in RF, confirming the belief that the HomeKit and regular Plug Mini only differ in software. Its unclear what the additional model#s are for. They could be different form factors, or otherwise differentiated products like the HomeKit version. This document was published in 2021, meaning the model numbers were reserved in advance. It's most likely, to me, that they just reserved them in advance for future uses in needed.

The schematic photo has some diagrams of the uncovered ESP-32 chip, which is cool. Interestingly, it was published with board revision "PLUG_ESP_C3_V1.3" so in truth, some changes have occurred.

kendallgoto commented 2 years ago

Testing: Of course, I only really care about running SwitchbOTA on this plug and confirming that it works. Again, since this is only a software revision, I doubt there's any concern. It should be noted that, since V1.4 is the shipping version and latest version of the firmware, there is no way to force an update via the UI. As such, you should connect over Bluetooth in order to force an update -- see here for my commentary on that.

After forcing a flash, the device reset and booted into Tasmota excellently. Further, from Tasmota, I applied the configuration template and the device / its buttons / its relay / its sensors all seemed to work just fine.