Article Directory
foreword
Home Assistant (hereinafter referred to as HA) is an open source smart home platform, also called home assistant, just like a software, such as our QQ software, WeChat software.
Home Assistant integrates the smart home devices at home into HA. It can access many devices, such as the famous Xiaomi, Bolian, Yiweilian, Philips, Tesla, etc., and can also access software. Devices across brands can be networked.
A device, before it is connected to HA, is a single device and can only be linked in its own ecology. Once connected to HA, it will be alive, and it can be linked in all connected platforms to realize various All kinds of automation.
The following introduces the Home Assistant panel + cpolar intranet penetration to achieve remote access anytime, anywhere.
1. Install Home Assistant
Here, the vmwhere virtual machine is used for installation, downloaded through the download link on the Home Assistant official website, and decompressed after downloading.
vmdk file: https://www.home-assistant.io/installation/linux#install-home-assistant-container
Then create a virtual machine
Choose a custom virtual machine
direct next step
Choose to install the operating system later
Then select Linux
, version selection4.x内核64位
Set the name of the virtual machine, and then the location of the installation below can be chosen by yourself, or it can be defaulted
You can choose one processor and two cores. The more the number of configurations here, the greater the consumption of computer performance. You can set it according to the local configuration.
According to the requirements of the official website, more than 2G is required, here choose 3G
Select NET network mode
direct next step
The disk type can be default, or SATA can be selected
Here you need to select an existing disk
Here select the .vmdk file downloaded from our official website above
Then choose to keep the existing format
Finally, click Finish
After the installation is successful, start the virtual machine. After the startup is complete, we can see the LAN ip address and port information. 8123 is the port of the management panel.
2. Configure Home Assistant
After starting the virtual machine, we enter the LAN ip address of Home Assistant plus the port number of 8123 on the browser, and we can see the management panel
For the first visit and login, you need to create an account, fill in the relevant user name and password, and create an account
Region selection, you can manually locate, or you can choose to automatically detect
Next, click Next by default
Then click Finish, here you will be prompted to add a smart device, you can click Finish first, and then set it yourself
Then enter the control panel interface
3. Install cpolar intranet penetration
After the browser access in the LAN is successful, we then use cpolar intranet penetration to map it to the public network, so that the HA at home can be accessed remotely in the public network environment, without the need for a public network IP or setting up a router .
cpolar official website: https://www.cpolar.com/
Visit the cpolar official website, register an account, and then download and install the client. For specific installation tutorials, please refer to the official website documentation tutorial.
3.1 windows system
After downloading the installation package from the cpolar official website, double-click the installation package and install it by default.
3.2 Linux system
cpolar supports one-click automatic installation script, please refer to the article tutorial for details
3.3 macOS system
It can be installed through homebrew, please refer to the article tutorial
4. Map the Home Assistant port
After cpolar is successfully installed, visit the local port 9200 on the browser, access the cpolar web UI management interface [ http://localhost:9200 ], and log in with the cpolar account.
Click Tunnel Management on the left dashboard - Create Tunnel, create an http tunnel, pointing to port 8123, which is the port of Home Assistant
隧道名称
: You can customize the name, be careful not to duplicate the name of the existing tunnel协议
: select http本地地址
: home assistant LAN ip+port域名类型
: Choose a random domain name for free地区
: Select China VIP
click创建
After the tunnel is successfully created, click on the status on the left - online tunnel list, view the generated public network address, and then copy the address
5. Access Home Assistant from the public network
Open the browser and use the public network address just obtained to connect and access. At this time, a 400 error will appear. If not, you can skip this step
Let's check the log, see the prompt for specific errors, click on the configuration in the lower left corner, click on the system
You can see the log, click on the log
After opening the log, we can see such a problem, which roughly means: a request from the reverse proxy is received from 192.168.191.1, but the HTTP integration is not set for the reverse proxy, so we need to modify the configuration file
Solution: Open the panel, find the configuration in the lower left corner, and click Add-ons
Go to the store to download a file editor, we need to modify a configuration file
Find the File editor file editor
Click to install this File editor
After the installation is successful, click Start
Then, in order to facilitate the next use, you can check a display in the sidebar
After opening, we can enter from the sidebar, and then click on the file directory in the upper left corner
Find and click the configuration.yaml file, click it
Add the following configuration to the file, the following ip address is the ip address we checked the log prompt above:
http:
use_x_forwarded_for: true
trusted_proxies:
- 192.168.191.1
Then we turn on the virtual machine, restart the virtual machine, and then enter the public network address again to access, and it will be successful
6. Fixed public network address
Since the above tunnel created by using cpolar uses a random public network address, it will change randomly within 24 hours, which is not conducive to long-term remote access. Therefore, we can configure a second-level subdomain name for it, which is a fixed address and will not change randomly.
Note that the cpolar package needs to be upgraded to the basic package or above, and the bandwidth corresponding to each package is different.
6.1 Reserve a fixed second-level subdomain
Log in to the cpolar official website, click Reserve on the left, choose to reserve the second-level subdomain name, set a second-level subdomain name, click Reserve, and copy the reserved second-level subdomain name after the reservation is successful
After the reservation is successful, copy the reserved second-level subdomain address
6.2 Configure a fixed second-level subdomain name
Visit http://127.0.0.1:9200/, log in to the cpolar web UI management interface, click Tunnel Management on the left dashboard - Tunnel List, find the Home Assistant tunnel to be configured, and click Edit on the right
Modify the tunnel information, and configure the successfully reserved second-level subdomain name into the tunnel
域名类型
: Select a second-level subdomainSub Domain
: Fill in the successfully reserved second-level subdomain name
click更新
After the update is complete, open the online tunnel list. At this time, you can see that the public network address has changed, and the address name has also changed to the reserved second-level subdomain name. Copy it down
Then use the fixed https address to open the browser access, and the access is also successful, and the domain name will not change.
Reprinted from cpolar cloud article: [Smart Home] Home Assistant installation, and intranet penetration remote security control