pvvx / ATC_MiThermometer

Custom firmware for the Xiaomi Thermometers and Telink Flasher
https://github.com/pvvx/pvvx.github.io/tree/master/ATC_MiThermometer
Other
3.01k stars 208 forks source link

Lesson learned regarding Xiaomi LYWSD03MMC not being added as BTHome Device in HA #559

Open jksmurf opened 1 month ago

jksmurf commented 1 month ago

Hopefully this will help someone and wil be left here, I appreciate it is not 100% ATC FW related but if you did what I did and tried literally hundreds of FW flashes, downgarding to original Xiaomi Mi FW, updating to ATC_38 through ATC_48, trying all for advertising modes, trying Zigbee then back to BLE, and you STILL couldn't add a device to Home Assitant via BTHome, maybe you did what I did.

I have two identical HW 1.4 LYWSD03MMC H&T devices, one added to HA BTHome just fine, the other rmust have been added at soem point, but I deleted it and it was never to be seen NOR ABLE TO BE ADDED to HA, ever again.

I knew it worked as I could see it advertising itself when I checked bluetoothctl devices in a HA terminal and it added fine using Miijia advertsiing mode (Xiaomi BLE). As above, I though it was a bad flash, wroing advertising mode, integration wrong, settings wrong, a bad device. It was none of these.

So after four days, I found a FIX ... the issue is NOT that the device flashed with e.g. custom firmware LYWSD03MMC from pvvx (or whoever) using BTHome as the advertising type is not working in your Xiaomi H&T Sensor (all text for future searchers...), it is simply that at some stage you (like me) have "Dismissed" or ignored adding a device and BTHome simply remembers that.

Note that this applies to other integrations where things do not get added back in or found again...

So:

  1. Fire up WinSCP , (assuming you have FTP Access to your HA IP Address). I attach some screenshots from the Terminal & SSH Addon but will leave you to figure that out.
  2. Navigate to /homeassistant/.storage and find the file core.config_entries.
  3. Open it in a text edtor and carefully (without deleting or changing any other text) search for either BTHome (or if you are having other items ignored, try "source": "ignore" (this one with quotes "") or just ignore.
  4. Amend ignore (provided it is a bluetooth device that is being ignoed !!) to bluetooth.
  5. SAVE the file. Exit WinSCP. Exit HA or restart it. Go back in and check the BTHome integration. it shoudl have added your device back in.
  6. IF in the interim you added the device using a DIFFERENT advertising type (or integration), it MAY show the device under BTHome as having TWO integrations AND ALSO under e.g. Xiaomi BLE, TWO integrations. Just delete the oine you do not want (in my case Xiaomi BLE) and oit will shows a single advertsining type device under BTHOME.

HTH as it has taken me four days to find this out; I thought my device was stuffed. It wasn't. HA was just doing what you told it to do... and forgot :-).

k.

01-Install HA Addon for Terminal SSH 02-WinSCP to your HA 03-WinSCP to your HA 04-05-WinSCP to your HA 06-Change ignore to bluetooth in core config_entries

pvvx commented 1 month ago

1. Settings -> Devices & services: image

2. image

jksmurf commented 1 month ago

1. Settings -> Devices & services: ![

lol, that’s certainly one way of doing it, thank you. Oddly though I don’t think I saw that option on my system.

In any case it’s a good tip, thanks 🙏

g6094199 commented 3 weeks ago

anyother easy way is: take a esp32 and flash ESPhome with bluetooth proxy function. add the esphome device to HA and bthome units get visible automaticly.