Cheap Temp/Humidity Sensing in HAS
If your house is like mine you have some rooms that run a little hotter than others (especially if you have servers running). Because of this the need to monitor temperature readings in rooms became a little more important, now there's a multitude of different ways to tackle this problem but this is by far the cheapest (although more time consuming on the front end) and doesn't require any cloud services to keep it running. I'd be unfair if I didn't mention some other good alternatives that use Zigbee/ZWave if you don't want to go through all this (these are not affiliate links, im not that important).
Requirements
In order to pull this off youre going to need the following.
Xiaomi Mijia Bluetooth Temperature and Humidity Sensor (i get mine from cloudfree.shop but you can get them off amazon or aliexpress).
A development board compatable with ESPhome (i used the ESP-WROOM-32).
A microusb chord for power/data transfer.
A Bluetooth capable device (this wont work on iPhone).
Xiaomi
So this is going to be the most time-consuming part, although its really not that bad in case these instructions go out of date check out the github page for the flashing tool https://github.com/pvvx/ATC_MiThermometer#getting-started .
To begin, youre going to need to be using google chrome or edge from there youre going to need to go to your chrome settings and enable the Experimental Web Platform features by pasting this URL into your address bar chrome://flags/#enable-experimental-web-platform-features make sure to restart the browser after.
From there you're going to want to open the OTA Flasher, click the Connect button, and you should see bluetooth devices. Yours should be named something like LYWSD03MMC .
After your connection is established click the Do Activation button and this will start pulling your keys (technically you could stop here and grab the keys for the Xiaomi Home Assistant plugin, but the ESP method is much better for continuity purposes).
After that, click Custom Firmware to flash the new firmware it should disconnect when its finished.
If you run into issues like I did, you can go to the alternate flasher and download the latest ATC version from Github and install it here.
If successful, when you turn your device off and on (by removing and reinstalling the battery) it should show you the last 6 digits of its MAC Address (the OUI is A4:C1:38) remember this because you'll .need it.
From here you should have everything you need from the Xiaomi sensor.
ESP Home
Install the ESPHome add-on in Home Assistant
Once you have it installed click the Open Web UI option if this is your first device it will open a setup wizard (evrything in there is spelled out for you very clearly), if not just click New Device.
From here, you need to have your board connected to your computer in a browser that supports WebSerial (Chrome is probably your best bet).
I recommend using the configuration file created for you by ESPHome, from there we can add what we need to after.
From here, just make sure to validate and install your config onto your board.
In the Devices & Services option under the Home Assistant settings, you can go to ESPHome and set your device to the room of your choosing.
After that, paste the following template into your configuration file with your device MAC and preferred names (The spacing may be off due to the site, so make sure to validate and clean build)
esp32_ble_tracker:
sensor:
- platform: atc_mithermometer
mac_address: "A4:C1:38:XX:XX:XX"
temperature:
name: ["Example Name"]
humidity:
name: ["Example Name"]
battery_level:
name: ["Example Name"]
battery_voltage:
name: ["Example Name"]
signal_strength:
name: ["Example Name"]
[Important Note: If you add multiple devices, the esp32_ble_tracker and sensor: options are only specified once, and new devices begin at - platform:]
From here, your sensors should show up in your home asstant dashboard in the same room as your ESPHome. You can add as many sensors as your home can handle you'll just have to buy a new board for every 8 or so devices (i believe that's what the Bluetooth threshold is).