Introduction
This article mainly introduces how to install the Home Assistant smart home system on the Orange Pi Zero3 with the CasaOS light NAS system and easily achieve remote management of smart devices at home using the Cpolar internal network penetration tool, without the need for a public IP or complicated router settings.
Home Assistant is a smart home platform that can control devices such as Apple, Xiaomi, and MQTT. It can integrate smart home devices at home, allowing devices from different brands to connect to each other. A device, before connecting to HA, is a standalone device that can only interact within its own ecosystem. Once connected to HA, it becomes alive, capable of interacting across all connected platforms, achieving various automations.
Previously, I shared how to use VMware to create virtual machines and deploy using Docker on Synology NAS. Today, I will share how to install it on the power-efficient Orange Pi Zero3, which can stay connected like a router. The process is very simple, and I will demonstrate it in detail below.
1. Add Mirror Source
The environment I am demonstrating is the Orange Pi Zero3 small host that has already flashed CasaOS.
If you don’t know how to operate, you can check out this tutorial:How to Flash CasaOS Light NAS System on Orange Pi Zero3
First, we need to enter the Orange Pi IP address in the browser (check in the router for the one named orangepizero3), and enter the CasaOS management interface.
Then enter the terminal and log in using the root account password.
After entering the terminal, execute the command below:
nano /etc/docker/daemon.json
In the editor, enter the new mirror source address:
{
"registry-mirrors": [
"https://docker.m.daocloud.io",
"https://docker.1panel.live"
]
}
Then press Ctrl+X to save this mirror source, exit the editor, and return to the terminal to execute the command below to restart the docker service:
systemctl restart docker
2. Deploy Home Assistant
After completing the above operations, we return to the CasaOS main interface and click on the built-in App Store application center.
After installing the CasaOS system, you will find that the applications inside are too few. To add more applications, just click on more applications in the current APP drop-down box.
Then click the question mark, which will automatically open a page in the browser to add more applications:
Copy the addresses in this page, and then return to the CasaOS application center interface.
Paste the copied addresses into the input box with the question mark, then click add. The system will automatically update more applications to the application center interface, increasing from dozens to hundreds.
When adding applications, you can search for Home Assistant in the app store and click install to automatically deploy:
It takes some time, so please be patient. After installation, click the icon to open:
You can see that the browser opens the Home Assistant initialization process interface, and the address is the Orange Pi host IP +8123 port:
3. HA System Initialization Configuration
First, click to create my smart home button, which redirects to the user creation interface. Fill in the information and click create user:
Select the region, you can manually locate or choose automatic detection:
Click next:
Here it prompts that compatible devices have been found, you can click finish first, and set up later:
Now the initialization configuration is complete, and you have entered the HA system management interface:
4. Adding Smart Devices to HA System
4.1 Adding Discovered Devices
First, click the settings in the lower left corner:
Select Devices and Services:
Here you can configure the discovered devices:
Taking my currently discovered Synology NAS as an example, first click configure
Then enter your NAS login username and password, along with the port number used by the NAS, and click submit:
After a moment, the HA system can automatically create the configuration, just click finish.
Now on the Home Assistant homepage, you can see the relevant information of the newly added Synology NAS device.
4.2 Adding HACS Plugin to Install Devices
If you want to configure undiscovered smart devices, we can add devices by installing the HACS plugin.
First, we click on the CasaOS terminal, still log in with the root account password:
Execute the command below to view all installed container information:
docker ps -a
Copy the Home Assistant container ID
Then execute the command below
docker exec -it 容器ID bash
Then execute the command below to install the hacs plugin:
wget -O - https://get.hacs.xyz | bash -
After installation is complete, reopen the terminal and execute the command below to restart the docker service:
systemctl restart docker
Then reopen the Home Assistant management interface, click settings:
Select Devices and Services:
Click the add integration in the lower right corner, enter HACS:
After clicking HACS, in the pop-up prompt box, select all and click submit:
Then copy the string of characters in the pop-up prompt box and click the link in option 1 above:
Then log in to your account on the opened GitHub page, or register one if you don’t have an account, and paste this string of characters in there: click continue
Then click Authorize hacs to grant authorization to hacs:
Finally, click finish:
Now in the Devices and Services interface, we can see the added HACS plugin:
To configure undiscovered smart devices through the HACS plugin, I will demonstrate using Xiaomi’s Xiao Ai speaker.
First, we return to the Home Assistant management interface homepage and click on HACS in the sidebar to download the repository.
You can see that the first one, Xiaomi Miot Auto, is available. Click the icon to jump and click the download button in the lower right corner:
Continue to click download in the pop-up dialog:
After completion, you will see a notification requesting to restart HA in the settings:
Click the prompt icon, then click submit:
After a while, after HA restarts, the management interface will automatically refresh. Click HACS, and you will see that Xiaomi Miot Auto has been successfully installed:
Then click on the lower left corner settings – Devices and Services – lower right corner add integration:
Search for the Xiaomi Miot Auto installed earlier and click in:
Select account integration or LAN integration according to your situation, and click next:
Then enter the Xiaomi account password and click submit:
Then in the device list, select the Xiaomi speaker I want to add, click submit:
Click finish
Now we can see the added Xiaomi speaker on the HA system homepage and manage it accordingly.
5. Install Cpolar Internal Network Penetration
At this point, we have successfully deployed the Home Assistant smart home system on the local CasaOS Orange Pi Zero3 host and installed the HACS plugin to achieve integration configuration for undiscovered devices. However, we can currently only use the HA system on the local area network, which has some limitations. If we want to remotely access the HA system at home while on a business trip, for example, to turn on the air conditioning before arriving home, what should we do?
It’s simple. Just install a Cpolar internal network penetration tool on the Orange Pi, and you can easily achieve remote access to the services deployed on the internal network host. Next, I will introduce how to install Cpolar internal network penetration.
First, click the upper left corner to enter the terminal:
Enter the root account password to log in: (If you don’t know how to get the password, you can refer to the flashing tutorial mentioned above)
Then execute the command below in the terminal to install the Cpolar internal network penetration tool:
curl -fsSL https://get.cpolar.sh | sudo sh
After installation, you can execute the command below to check the service status:
systemctl status cpolar
The image below shows that the Cpolar internal network penetration service is running normally.
5.1 Configuring HA Public Address
Then we use the IP address of the CasaOS Orange Pi plus 9200 to open a new browser to log in to the Cpolar management interface:
PS: The IP address of the Orange Pi can be checked in the router, the one named orangepizero3 is it.
If you don’t have an account, you can click to register for free to access the Cpolar official website:https://www.cpolar.com
After entering the account password to log in to the Cpolar web UI management interface, click on the tunnel management in the left dashboard – create tunnel:
Tunnel name: customizable, be careful not to duplicate with existing tunnel names, in this example, I used: home assistant
Protocol: http
Local address: Orange Pi host IP + 8123 port
Domain type: random domain name
Region: select China Top
Click create
After the tunnel is created successfully, click on the status – online tunnel list on the left to view the generated public address, then copy the address
Open the browser and use the public address obtained earlier to connect and access. At this point, a 400 error will appear. If not, you can skip this step:
If there is an error, we need to check the logs to see the specific error prompt. Click the settings in the lower left corner, and click system:
Click logs:
After opening the logs, we can see a problem, which roughly means: received a request from the reverse proxy from 192.168.x.x, but the HTTP integration is not set up for the reverse proxy. Therefore, we need to modify the configuration file:
First, return to the CasaOS Orange Pi interface:
Click the file button:
Then enter the DATA-AppData-homeassistant folder:
Continue to enter the config folder:
Then click to open the configuration file named, and add the configuration below and save:
http:
use_x_forwarded_for: true
trusted_proxies:
- 192.168.50.215 (replace with your Orange Pi host IP)
Then enter the CasaOS terminal and execute the command below to restart the docker service:
systemctl restart docker
After restarting, we can now use the public address created earlier through Cpolar in the browser to successfully remote access the locally deployed Home Assistant smart home system:
Summary
For demonstration purposes, the public address generated by Cpolar in the above operations is randomly generated. The advantage of this random address is that it can be established quickly and used immediately. However, its disadvantage is that the URL is randomly generated and hard to remember, and this address will randomly change within 24 hours, making it more suitable for temporary testing.
If you have a long-term need for remote access to the local CasaOS Orange Pi’s Home Assistant smart home system or other local services, and do not want to reconfigure the public address every day, while also wanting the address to be good-looking and memorable, I recommend choosing to configure a fixed public address for remote access.
6. Configure Fixed Public Address
Log in to the Cpolar official website, click on the left reserve, select to reserve a secondary subdomain, choose the region China VIP, set a secondary subdomain name, and click reserve. After successful reservation, copy the reserved secondary subdomain name, here I filled in myha001
, you can also customize your favorite name.
After successful reservation, copy the name of the reserved secondary subdomain:myha001
, return to the Cpolar web UI management interface, click on the left dashboard’s tunnel management – tunnel list, find the tunnel to configure home assistant
, click edit on the right:
Modify the tunnel information, configuring the successfully reserved secondary subdomain into the tunnel
-
Domain type: select secondary subdomain
-
Sub Domain: fill in the successfully reserved secondary subdomain: myha001
-
Region: select China VIP
Click Update
(Note, click update once is enough, no need to submit repeatedly)
After the update is complete, open the online tunnel list. At this point, you can see that the public address has changed from a random address name to two fixed secondary subdomains (fixed public address):
Using any fixed public address in the browser, you can see access success. Thus, a fixed and permanent public address has been set up, allowing remote access to the CasaOS Orange Pi host’s Home Assistant smart home system anytime and anywhere!
The above is how to deploy the Home Assistant smart home system on the CasaOS light NAS system Orange Pi Zero3, install the HACS plugin, and use the Cpolar internal network penetration tool to configure a fixed public address with a secondary subdomain, achieving remote management of smart devices at home anytime and anywhere. Thank you for watching, and feel free to leave comments for any questions.
If you need to reprint, please indicate the source!
Leave a Comment
Your email address will not be published. Required fields are marked *