Preface
I started playing with smart homes probably right when Xiaomi first launched theirs, so I should be considered one of the earliest smart home enthusiasts. I bought whatever they released (I even replaced all the regular light switches in my house with remote-controlled ones, though they almost all broke in less than 3 years...), so I have a ton of Xiaomi smart devices and automations at home:

Then I started building the Apple ecosystem:

Although Xiaomi's smart features can be added directly to Siri via the Mi Home app:

But it's not very convenient. Plus, I have now fully switched to Siri and don't want to call out to Xiao AI anymore. How can I bridge Mi Home devices with the Apple ecosystem? That's when I thought of Home Assistant (HA). I never really had the motivation to look into it before, but now I finally have a reason to play around with it.
Deploying Home Assistant
Choosing the Installation Method
Home Assistant provides four different installation methods (HA OS, HA container, HA Supervised, HA Core), and the official recommendation is to use HA OS.
Experienced users can also choose other methods based on their specific needs, such as running HA in a virtual environment (like Proxmox) or on top of an existing operating system (like Windows, macOS, Linux).
Note: While these installation methods can provide some flexibility for advanced users, they may also have significant limitations. For example, you might not be able to use add-ons and other important Home Assistant features:

Since I already have an existing PVE environment, I chose to deploy HA OS on PVE. You can choose the method that best suits your actual environment.
Creating a Home Assistant OS Virtual Machine
Download the latest version of the Home Assistant OS qcow2 file suitable for installation on PVE. The link is as follows:
https://github.com/home-assistant/operating-system/releases。

The latest version when I downloaded it was 12.2.rc1. After extracting it, upload the qcow2 file to the /root directory of PVE.
Note: This was right around the time the xz-utils backdoor vulnerability was exposed. Make sure your xz version is not 5.6.0 or 5.6.1.
Create a new virtual machine on PVE and remember its VM ID (here, taking 108 on my PVE as an example).
For the detailed process of creating a new virtual machine, please refer to my other article:OpenWrt Soft Router Series: Detailed Tutorial on Deploying OpenWrt (23.05.2) on PVE, the only difference is that after creation, you need to change the BIOS type to OVMF (UEFI) in the hardware settings:

Import the downloaded qcow2 hard disk into the virtual machine:
qm importdisk 108 /root/haos_ova-12.2.rc1.qcow2 local-lvm
Add the imported disk:


Modify the boot order of the virtual machine:


Enable the virtual machine:

Boot completed:

The IP shown in the red box in the image above is the IP address of Home Assistant OS, and the port is 8123.
Initializing Home Assistant
Usehttp://homeassistant.local:8123Log in to Home Assistant OS.
Upon first access, Home Assistant OS will perform preparation work:

Note 1: This step is best done with the help of a VPN or proxy (scientific internet access). Under normal domestic network conditions, there's no telling how long you'll have to wait. Personally, I was stuck at .675 for a very long time. Out of frustration, I routed the HAOS IP address directly through a proxy, which bypassed the .675 hang and completed the initialization in less than 10 minutes.
Note 2: If the network environment where HAOS is deployed has a public IPv6 address and you are also using a proxy, it is recommended not to assign an IPv6 address to HAOS. At this stage, the compatibility between IPv6 addresses and some proxy methods is not very good. If you must use IPv6, it is recommended to disable AAAA records in DNS resolution.
After the preparation is complete, you will enter the welcome page:

Create a username and password:



Then Home Assistant will discover compatible devices on the same subnet:

After clicking finish, you will enter the official interface:

Implementing Key Features
Batch Configuring Existing Xiaomi Devices into Home Assistant


Configuring them one by one is obviously impractical, so we need to use the integration feature to batch import existing products from the same platform into HA. Below, I will use Xiaomi devices as an example to demonstrate how to batch import my Xiaomi devices into HA using the "Xiaomi Miot Auto" plugin. Since "Xiaomi Miot Auto" is not in the default integrations of HA OS (actually, it comes with another plugin "Xiaomi Miio", but it kept throwing errors when logging into the Xiaomi cloud platform during configuration, supposedly because the host accessing HA and HA itself are not on the same local network. This is possible because my HA host was proxied, while the host I used to access HA was not, but I didn't bother to look into it and just switched directly to Xiaomi Miot Auto), we need to install "Xiaomi Miot Auto" first using the following method.
Go to "Settings" - "Add-ons":

Click on "Add-on Store" in the red box at the bottom right:

Install "Terminal & SSH" in the red box:

After installation is complete, enter and click "Open Web UI" in the red box at the bottom right:

Install HACS (Home Assistant Community Store):

The command is as follows:
wget -O - https://get.hacs.vip | DOMAIN=xiaomi_miot bash -
Note: Actually, in HA deployed through other methods, this command is for installing HACS (which is a third-party app store). After installation, a HACS option should appear in the bottom-left menu of the HA page, similar to the following:

But for some reason, after I installed it, nothing happened except that a "Xiaomi Miot Auto" integration was added. Could it be related to the HA OS version I installed (or maybe some HACS features have been integrated into the latest version of the Add-on Store)? I don't get it, you guys can look into it yourselves, I didn't want to spend the energy.
Restart Home Assistant:

Then return to "Devices & Services" and click "Add Integration" in the bottom right corner:

You will find that "Xiaomi Miot Auto" has been added:

After clicking to enter, the following interface appears. I chose the account integration, which will associate all devices in my Xiaomi account together:

Just keep the device connection mode as "Automatic mode":

After submitting, an error will be reported, and the following interface will appear:

Actually, when I used the "Xiaomi Miio" plugin, I also got a similar error as above, but there was no option to "click here" to continue. After choosing "click here" to continue, the following interface appears, just click "Yes":

The interface below is to select the scope of Xiaomi devices to be connected, which is equivalent to a blacklist/whitelist. If Exclude is left blank, all devices will be connected:

You can see that configurations have been automatically created for all the Xiaomi devices under my Xiaomi account:

At this time, returning to the overview, you can see all my Xiaomi devices:

In the "Developer Tools" menu, there are options related to YAML:

The YAML here actually refers to a key configuration file in HA: "configuration.yaml". Many custom functions need to be implemented by directly editing it and adding content. Its default path is at:
/root/config/configuration.yaml
You can directly edit it in the CLI interface using the following command through the "Terminal & SSH" we installed earlier:
vim /root/config/configuration.yaml
However, this method is slightly troublesome. After all, it requires using vim, which some friends might not be familiar with. Therefore, in this section, I will use another simpler method that is more in line with everyone's habits, which is the add-on "Samba share". It can directly expose the /root directory as a shared folder. It is still in the "Add-on Store":

Click to install "Samba share":

After the installation is complete, enter and configure it first:

Then start the service:

If it is a Windows system, access it directly in "Run" using \\HAOS IP address. After entering the username and password configured earlier, you can access it using File Explorer:

In the image above, addons is used to manually install plugins, and under config is where "configuration.yaml" is located. You can directly use a text editor on Windows to edit "configuration.yaml".
Connecting Xiaomi Devices to HomeKit
Generally speaking, we mostly add devices from other platforms to HA through integration functions. However, sometimes there is a reverse demand. For example, adding Xiaomi devices that have joined HA to Apple's Home app via HomeKit. I believe many Apple fans have this demand. After all, compared to smart devices that directly support HomeKit, Xiaomi's devices are much cheaper. At this time, it is actually using HA as a bridge device. The steps to add are as follows:

Select "HomeKit Bridge":

Note: "HomeKit Bridge" in the image above is to add HA devices to HomeKit, while "HomeKit Device" is to add devices in Apple HomeKit to HA. Their functions are completely different, so please do not choose the wrong one.
Then select the domains to include, which is actually choosing which devices on HA to add to HomeKit:

This is still necessary. Since I have so many Xiaomi devices at home (48 devices, 157 entities), importing all of them into HomeKit is a bit overwhelming... I checked binary sensors on top of the default values (I was wrong, checking binary sensors made adding them in the Home app later a nightmare... I suggest you don't check it at the beginning, you can modify the options to achieve it after adding if needed):



Then in HA's notifications, you can see that many HomeKit pairings have been added:

Open the "Home" app on your iPhone, click the "+" sign in the upper right corner, and select the first option "Add or Scan Accessory":

Scan and add the devices in the notifications that require scanning QR codes one by one. The last one is HomeKit Bridge. After adding, the information of the Xiaomi devices will come over (it exhausted me to death adding them...), and finally, the content of the Home app is as follows:

And "HomeKit Bridge" is also added to the configured list in "Devices & Services":

The content inside is as follows (the previous domain options can also be modified in the "HASS Bridge" options in the image below):

Other Features
If you want to add automation scenes, add them in "Automations & Scenes":


For example, I want to create an automation so that whenever I turn on my Marantz amplifier, the TV wall light turns on:


The functions are too powerful, you can explore them slowly on your own.
Home Assistant OS can also support other functions through the "Add-on" store:


You can choose flexibly according to the hardware performance of your HA OS deployment and your own needs. Personally, I don't really like this kind of hodgepodge usage. I advocate for "dedicated" use of devices. If a hodgepodge is needed, I use virtualization solutions for refined "dedication".
Afterword
HA supports a vast number of smart device brands. If you are interested in building a smart home, HA is highly worth studying. If you have higher requirements, you can also use dedicated idle hardware to build dedicated devices. This depends on your needs.
After changing to UEFI boot, it prompts "uefi interactive shell v2.2" and cannot start. My system is PVE 8.2.2.
My PVE is 7.9.x, does 8.2.2 still have this issue? I searched online for the keywords “pve 8 uefi interactive shell v2.2” and didn't seem to see similar news. It feels like it's not a problem unique to PVE 8. I can only look again to see if there is anything missed in the operation process.
Searching the entire network, there are basically only a few solutions: 1. Turn off secure boot, which works for another ROS system, but HA still doesn't work. 2. Modifying the boot options given by the official website is still useless. Finally, I found an image made by someone else. I don't know if mine is an isolated case.
Most of the time, I also have to admit that I just have bad luck~