The Qiji Yinqiao series uses PVE to build its own smart device management platform based on Home Assistant OS
本文最后更新于 295 天前,其中的信息可能已经有所发展或是发生改变,如有失效可到评论区留言。

Preface

I started playing with smart home when Xiaomi first launched it. I should be considered one of the earliest people to play with smart home. I bought whatever was released (I replaced the regular switches of the lights at home with remote control ones, but they broke down in less than 3 years...), so there are a lot of Xiaomi smart and automated products at home:

image.png

Then we started to build the Apple ecosystem:
image.png

Although Xiaomi's smart phone can be directly added to Siri in Mi Home:
image.png

But it's not very convenient, and I've now switched to Siri and don't want to call Xiao Ai anymore, so how can I connect Xiaomi devices with the Apple ecosystem? At this time, I remembered Home Assistant (HA). I had no motivation to study it before, but now I finally found a reason to try it out.

Deploy Home Assistant

Installation options

Home Assistant provides four different installation modes (HA OS, HA container, HA Supervised, and HA Core). The official recommendation is to use HA OS.

Experienced users can also choose other methods according to their specific needs, for example, running HA in a virtual environment (such as Proxmox) or running HA on top of an existing operating system (such as Windows, macOS, Linux).

Note: While these installation styles can provide some flexibility for advanced users, they can also have some significant limitations. For example, add-ons and other important Home Assistant features may not be available:

image.png

Because I have a ready-made PVE environment, I deployed HA OS on PVE. You can choose the most suitable method according to your actual environment.

Create a virtual machine for Home Assistant OS

Download the latest version of Home Assistant OS qcow2 file suitable for installation on PVE from the following link:
https://github.com/home-assistant/operating-system/releases.

image.png

The latest version I downloaded was 12.2.rc1. After decompression, upload the qcow2 file to the /root directory of pve.

Note: This was when the backdoor of xz-utils was first exposed. Please note that the xz version should not be 5.6.0 or 5.6.1.

Create a new virtual machine on PVE and remember its VM id number (here I use 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 PVE deployment OpenWrt (23.05.2) detailed tutorial,The only difference is that after the creation is completed, you need to change the BIOS type to OVMF (UEFI) in the hardware:

image.png


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:

image.png

image.png

To modify the boot order of a virtual machine:
image.png

image.png

Enable the virtual machine:
image.png

Startup completed:
image.png

The IP shown in the red box in the above picture is the IP address of Home Assistant OS, and the port is 8123.

Initialize Home Assistant

usehttp://homeassistant.local:8123Log in to Home Assistant OS.
When you first access Home Assistant OS, it will do some preparation:

image.png


Note 1: This step would require the blessing of science or magic. If it is based on the normal domestic network environment, I don’t know how long I would have to wait. Anyway, I was stuck at .675 for a long time and got angry. I let HAOS’s IP address go directly to science, and then I skipped 675 and went on. The initialization was completed in less than 10 minutes.
Note 2: If the network environment where HAOS is deployed has an IPv6 public address and scientific methods, it is recommended not to assign an IPv6 address to HAOS. At this stage, IPv6 addresses are not very compatible with some scientific methods. If you want to use IPv6, it is recommended to disable AAAA records in DNS resolution.


After the preparation is completed, enter the welcome page:

image.png

Create username and password:
image.png

image.png

image.png

Home Assistant will then discover compatible devices on the same network segment:
image.png

After clicking Finish, you will enter the formal interface:
image.png

Key functions realized

Existing Xiaomi devices are configured in batches into Home Assistant

image.png

image.png

It is obviously unrealistic to configure one by one, so it is necessary to introduce the existing products of the same platform into HA in batches through the integration function. The following will take Xiaomi devices as an example to demonstrate how to use the "Xiaomi Miot Auto" plug-in to introduce Xiaomi devices in my home into HA in batches. Since there is no "Xiaomi Miot Auto" in the default integration of HA OS (in fact, it comes with another plug-in "Xiaomi Miio", but it keeps reporting errors when logging into the Xiaomi cloud platform during the configuration process. It is said that this is because the host accessing HA is not in the same LAN as HA. This is possible because my HA host is scientific, but my host accessing HA is not scientific, but I am too lazy to study it, so I just change it to Xiaomi Miot Auto), so we need to install "Xiaomi Miot Auto" first in the following way.
Go to "Configuration" - "Add-ons":

image.png

Click on "Add-on Store" in the red box in the lower right corner:
image.png

Install "Terminal&SSH" in the red box:
image.png

After the installation is complete, enter and click "Open WEB UI" in the red box in the lower right corner:
image.png

Install HACS (Home Assistant Community Store):
image.png

The command is as follows:

wget -O - https://get.hacs.vip | DOMAIN=xiaomi_miot bash -

Note: In fact, in HA deployed in other ways, this command is used to install HACS (a third-party application store). After the installation is complete, a HACS option should appear in the lower left menu of the HA page, similar to the following:

image.png

But I don't know why there is no response after I installed it, except for an additional "Xiaomi Miot Auto" integration. Is it related to the HA OS version I installed (or some functions of HACS are integrated into the latest version of the add-on store)? I don't understand. You can research it yourself. I'm too lazy to spend energy.


Restart Home Assistant:

image.png

Then go back to "Devices & Services" and click "Add Integration" in the lower right corner:

image.png

You will find "Xiaomi Miot Auto" added:
image.png

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

Just keep the device connection mode in "automatic mode":
image.png

After submission, an error will be reported and the following interface will appear:
image.png

In fact, I also got a similar error when using the "Xiaomi Miio" plug-in, but there was no "Click here" option to continue. After selecting "Click here" to continue, the following interface appeared, just click "Yes":
image.png

The following interface selects the range of Xiaomi devices to be connected, which is equivalent to a blacklist or whitelist. If Exclude is left blank, all devices will be connected:
image.png

You can see that all Xiaomi devices under my Xiaomi account have been automatically configured:
image.png

Now go back to the overview and you can see all my Xiaomi devices:
image.png

(Optional) Add-on "Samba share"

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

image.png

The YAML here actually refers to a key configuration file in HA: "configuration.yaml". Many custom functions are implemented by directly editing it and adding content. Its default path is:

/root/config/configuration.yaml

You can edit it directly in the cli interface using the following command through the "Terminal&SSH" we installed earlier:

vim /root/config/configuration.yaml

However, this method is a little troublesome, after all, it requires vim, which some friends may not be familiar with, so I will use another simpler and more accustomed method in this section, that is, the add-on "Samba share", which can directly create a shared folder in the /root directory. Still in the "Add-on Store":

image.png

Click to install "Samba share":
image.png

After the installation is complete, configure it first:
image.png

Then start the service:
image.png

If it is a Windows system, directly use //HAOS IP address to access in "Run", enter the username and password configured above, and then use the resource manager to access:
image.png

In the above picture, addons is used to manually install plug-ins, and config is where "configuration.yaml" is located. You can directly edit "configuration.yaml" using a text editor on Windows.

Connect Xiaomi devices to HomeKit

Generally speaking, we mostly add devices from other platforms to HA through integration functions. However, sometimes there are reverse requirements, for example, adding Xiaomi devices that have joined HA to Apple's Home app through HomeKit. I believe that many Apple fans have this requirement. After all, compared with smart devices that directly support HomeKit, Xiaomi devices are much cheaper. At this time, HA is actually used as a bridge device. The steps to add are as follows:

image.png

Select "HomeKit Bridge":
image.png


Note: The "HomeKit Bridge" in the above picture is to add HA devices to Homekit, while the "HomeKit Device" is to add devices in Apple HomeKit to HA. The functions are completely different, so don't make the wrong choice.


Then select the domains to include, which is actually to select which devices on HA to add to Homekit:

image.png

This is still necessary. I have so many Xiaomi devices at home (48 devices, 157 entities), and it is a bit overwhelming to import all of them into HomeKit. I checked the binary sensor based on the default value (I made a mistake, I checked the binary sensor, and it killed me when I added it in the Home app later. I suggest that you don’t check it at the beginning, and you can add it and modify the option to achieve it if necessary):
image.png

image.png

image.png

Then you can see a lot more HomeKit pairings in the HA notification:
image.png

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

Scan the devices that need to scan the QR code in the notification one by one. The last one is HomeKit Bridge. After adding it, the information of Xiaomi devices will come (adding it makes me dead...). Finally, the content of the Home app is as follows:
image.png

And in "Devices and Services", "HomeKit Brideg" has been added to the configuration:
image.png

The contents are as follows (the previous domain options can also be modified in the "HASS Bridge" options in the figure below):
image.png

Other functions

If you want to add an automation scenario, add it in "Automation and Scenario":

image.png

image.png

For example, I want to create an automation so that whenever I turn on my Marantz amplifier, the TV wall lights turn on:
image.png

image.png

The function is so powerful, you can study it slowly on your own.

Home Assistant OS also supports additional features through the "Add-ons" store:

image.png

image.png

You can flexibly choose according to the hardware performance of your HA OS deployment and your own needs. I personally don't like this hodgepodge usage. I advocate the "specific" use of equipment. If a hodgepodge is needed, use a virtualization solution to carry out refined "specification".

Afterword

HA supports a lot of smart device brands. If you are interested in building a smart home, HA is worth studying. If you have higher requirements, you can also use special idle hardware to build dedicated devices. It depends on your needs.

The content of the blog is original. Please indicate the source when reprinting! For more blog articles, you can go toSitemapUnderstand. The RSS address of the blog is:https://blog.tangwudi.com/feed, welcome to subscribe; if necessary, you can joinTelegram GroupDiscuss the problem together.

Comments

  1. kk
    Windows Edge 127.0.0.0
    6 months ago
    2024-8-12 16:00:25

    After changing the uefi boot, it prompts uefi interactive shell v2.2 and cannot be started. My system is pve 8.2.2

    • Owner
      kk
      Macintosh Chrome 127.0.0.0
      5 months ago
      2024-8-15 10:25:49

      My PVE is 7.9.x, does 8.2.2 still have this problem? I searched the keywords "pve 8 uefi interactive shell v2.2" on the Internet and didn't see any similar messages. It seems that this is not a problem unique to PVE 8. I can only look for any points in the operation process that I have not noticed.

      • kk
        tangwudi
        Windows Edge 127.0.0.0
        5 months ago
        2024-8-15 10:30:00

        After searching the entire Internet, there are basically a few solutions: 1. Turn off secure boot, which works for another ros system, but not for ha. 2. Modifying the startup items given by the official website is still useless. Finally, I found a mirror made by someone else. I don’t know if this is an exception.

        • Owner
          kk
          Macintosh Chrome 127.0.0.0
          5 months ago
          2024-8-16 14:58:11

          I often have to admit that I have an ugly face.

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠(ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ°Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
Emoticons
Emoji
Little Dinosaur
flower!
Previous
Next
       

This site has disabled the right mouse button and various shortcut keys. The code block content can be copied directly by clicking the copy button in the upper right corner

en_US