Skip to content

Commit f2bb48d

Browse files
authored
Merge pull request #493 from Paraphraser/20220209-hassio-master
20211116 hassio - master branch - PR 1 of 2
2 parents dc9df51 + a47dcf5 commit f2bb48d

File tree

3 files changed

+48
-263
lines changed

3 files changed

+48
-263
lines changed

.native/hassio_supervisor.sh

Lines changed: 0 additions & 51 deletions
This file was deleted.

docs/Containers/Home-Assistant.md

Lines changed: 48 additions & 196 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Home Assistant
22

3-
Home Assistant is a home automation platform running on Python 3. It is able to track and control all devices at your home and offer a platform for automating control.
3+
Home Assistant is a home automation platform. It is able to track and control all devices at your home and offer a platform for automating control.
44

55
## <a name="references"> References </a>
66

@@ -17,189 +17,23 @@ Home Assistant is a home automation platform running on Python 3. It is able to
1717

1818
There are two versions of Home Assistant:
1919

20-
* Hass.io (Home Assistant Core), and
21-
* Home Assistant Container.
20+
* Home Assistant Container; and
21+
* Supervised Home Assistant (also known as both "Hass.io" and "Home Assistant Core").
2222

2323
Each version:
2424

2525
* provides a web-based management interface on port 8123; and
2626
* runs in "host mode" in order to discover devices on your LAN, including devices communicating via multicast traffic.
2727

28-
IOTstack allows you to **install** either, or both, versions.
28+
Home Assistant Container runs as a **single** Docker container, and doesn't support all the features that Supervised Home Assistant does (such as add-ons). Supervised Home Assistant runs as a **collection** of Docker containers under its own orchestration.
2929

30-
Note:
30+
Technically, both versions of Home Assistant can be installed on your Raspberry Pi but you can't **run** both at the same time. Each version runs in "host mode" and binds to port 8123 so, in practice, the first version to start will claim the port and the second will then be blocked.
3131

32-
* Technically, both versions can **run** at the same time but it is not **supported**. Each version runs in "host mode" and binds to port 8123 so, in practice, the first version to start will claim the port and the second version will then be blocked.
33-
34-
### <a name="versionHassio"> Hass.io </a>
35-
36-
Hass.io uses its own orchestration:
37-
38-
* hassio\_supervisor
39-
* hassio\_audio
40-
* hassio\_cli
41-
* hassio\_dns
42-
* hassio\_multicast
43-
* hassio\_observer
44-
* homeassistant.
45-
46-
IOTstack can only offer limited configuration of Hass.io since it is its own platform.
47-
48-
### <a name="versionHAContainer"> Home Assistant Container </a>
49-
50-
Home Assistant Container runs as a single Docker container, and doesn't support all the features that Hass.io does (such as add-ons).
51-
52-
## <a name="menuInstallation"> Menu installation </a>
53-
54-
### <a name="installHassio"> Installing Hass.io </a>
55-
56-
Hass.io creates a conundrum:
57-
58-
* If you are definitely going to install Hass.io then you **must** install its dependencies **before** you install Docker.
59-
* One of Hass.io's dependencies is [Network Manager](https://wiki.archlinux.org/index.php/NetworkManager). Network Manager makes **serious** changes to your operating system, with side-effects you may not expect such as giving your Raspberry Pi's WiFi interface a random MAC address both during the installation and, then, each time you reboot. You are in for a world of pain if you install Network Manager without first understanding what is going to happen and planning accordingly.
60-
* If you don't install Hass.io's dependencies before you install Docker, you will either have to uninstall Docker or rebuild your system. This is because both Docker and Network Manager adjust your Raspberry Pi's networking. Docker is happy to install after Network Manager, but the reverse is not true.
61-
62-
#### <a name="uninstallDocker"> Step 1: If Docker is already installed, uninstall it </a>
63-
64-
```bash
65-
$ sudo apt -y purge docker-ce docker-ce-cli containerd.io
66-
$ sudo apt -y remove docker-compose
67-
$ sudo pip3 uninstall docker-compose
68-
```
69-
70-
Note:
71-
72-
* Removing Docker does **not** interfere with your existing `~/IOTstack` folder.
73-
74-
#### <a name="aptUpdate"> Step 2: Ensure your system is fully up-to-date </a>
75-
76-
```bash
77-
$ sudo apt update
78-
$ sudo apt upgrade -y
79-
```
80-
81-
#### <a name="hassioDependencies1"> Step 3: Install Hass.io dependencies (stage 1) </a>
82-
83-
```bash
84-
$ sudo apt install -y apparmor apparmor-profiles apparmor-utils
85-
$ sudo apt install -y software-properties-common apt-transport-https ca-certificates dbus
86-
```
87-
88-
#### <a name="useEthernet"> Step 4: Connect to your Raspberry Pi via Ethernet </a>
89-
90-
You can skip this step if you interact with your Raspberry Pi via a screen connected to its HDMI port, along with a keyboard and mouse.
91-
92-
If, however, you are running "headless" (SSH or VNC), we **strongly recommend** connecting your Raspberry Pi to Ethernet. This is only a temporary requirement. You can return to WiFi-only operation after Hass.io is installed.
93-
94-
When the Ethernet interface initialises, work out its IP address:
95-
96-
```bash
97-
$ ifconfig eth0
98-
99-
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
100-
inet 192.168.132.9 netmask 255.255.255.0 broadcast 192.168.132.255
101-
ether ab:cd:ef:12:34:56 txqueuelen 1000 (Ethernet)
102-
RX packets 4166292 bytes 3545370373 (3.3 GiB)
103-
RX errors 0 dropped 0 overruns 0 frame 0
104-
TX packets 2086814 bytes 2024386593 (1.8 GiB)
105-
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
106-
```
107-
108-
In the above, the IP address assigned to the Ethernet interface is on the second line of output, to the right of "inet": 192.168.132.9.
109-
110-
Drop out of your existing session (SSH or VNC) and re-connect to your Raspberry Pi using the IP address assigned to its Ethernet interface:
111-
112-
```bash
113-
114-
```
115-
116-
or:
117-
118-
```
119-
120-
```
121-
122-
The reason for stipulating the IP address, rather than a name like `raspberrypi.local` is so that you are *definitely* connected to the Ethernet interface.
123-
124-
If you ignore the advice about connecting via Ethernet and install Network Manager while your session is connected via WiFi, your connection will freeze part way through the installation (when Network Manager starts running and unconditionally changes your Raspberry Pi's WiFi MAC address).
125-
126-
You *may* be able to re-connect after the WiFi interface acquires a new IP address and advertises that via multicast DNS associated with the name of your device (eg `raspberrypi.local`), but you may also find that the only way to regain control is to power-cycle your Raspberry Pi.
127-
128-
The advice about using Ethernet is well-intentioned. You should heed this advice even if means you need to temporarily relocate your Raspberry Pi just so you can attach it via Ethernet for the next few steps. You can go back to WiFi later, once everything is set up. You have been warned!
129-
130-
#### <a name="hassioDependencies2"> Step 5: Install Hass.io dependencies (stage 2) </a>
131-
132-
Install Network Manager:
133-
134-
```bash
135-
$ sudo apt install -y network-manager
136-
```
137-
138-
#### <a name="disableRandomMac1"> Step 6: Consider disabling random MAC address allocation </a>
139-
140-
To understand why you should consider disabling random MAC address allocation, see [why random MACs are such a hassle ](#aboutRandomMACs).
141-
142-
You can stop Network Manager from allocating random MAC addresses to your WiFi interface by running the following commands:
143-
144-
```bash
145-
$ sudo sed -i.bak '$a\\n[device]\nwifi.scan-rand-mac-address=no\n' /etc/NetworkManager/NetworkManager.conf
146-
$ sudo systemctl restart NetworkManager.service
147-
```
148-
149-
Acknowledgement:
150-
151-
* This tip came from [@steveatk on Discord](https://discordapp.com/channels/638610460567928832/638610461109256194/758825690715652116).
152-
153-
#### <a name="reinstallDocker"> Step 7: Re-install Docker </a>
154-
155-
You can re-install Docker using the IOTstack menu or one of the scripts provided with IOTstack but the following commands guarantee an up-to-date version of `docker-compose` and also include a dependency needed if you want to run with the 64-bit kernel:
156-
157-
```bash
158-
$ curl -fsSL https://get.docker.com | sh
159-
$ sudo usermod -G docker -a $USER
160-
$ sudo usermod -G bluetooth -a $USER
161-
$ sudo apt install -y python3-pip python3-dev
162-
$ [ "$(uname -m)" = "aarch64" ] && sudo apt install libffi-dev
163-
$ sudo pip3 install -U docker-compose
164-
$ sudo pip3 install -U ruamel.yaml==0.16.12 blessed
165-
$ sudo reboot
166-
```
167-
168-
Note:
169-
170-
* Installing or re-installing Docker does **not** interfere with your existing `~/IOTstack` folder.
171-
172-
#### <a name="runHassioInstall"> Step 8: Run the Hass.io installation </a>
173-
174-
Start at:
175-
176-
```bash
177-
$ cd ~/IOTstack
178-
$ ./menu.sh
179-
```
180-
181-
Hass.io installation can be found inside the `Native Installs` menu on the main menu. You will be asked to select your device type during the installation.
182-
183-
The installation of Hass.io takes up to 20 minutes (depending on your internet connection). You may also need to respond "Y" to a prompt during the installation process. Refrain from restarting your machine until it has come online and you are able to create a user account.
184-
185-
Hass.io installation is provided as a convenience. It is independent of, is not maintained by, and does not appear in the `docker-compose.yml` for IOTstack. Hass.io has its own service for maintaining its uptime.
186-
187-
#### <a name="disableRandomMac2"> Re-check random MAC address allocation </a>
188-
189-
Installing Hass.io can re-enable random MAC address allocation. You should check this via:
190-
191-
```bash
192-
$ tail -3 /etc/NetworkManager/NetworkManager.conf
193-
[device]
194-
wifi.scan-rand-mac-address=no
195-
196-
```
197-
198-
If you do **NOT** see `wifi.scan-rand-mac-address=no`, repeat [Step 6](#disableRandomMac1).
32+
IOTstack used to offer a menu entry leading to a convenience script that could install Supervised Home Assistant but that stopped working when Home Assistant changed their approach. Now, the only method supported by IOTstack is Home Assistant Container.
19933

20034
### <a name="installHAContainer"> Installing Home Assistant Container </a>
20135

202-
Home Assistant can be found in the `Build Stack` menu. Selecting it in this menu results in a service definition being added to:
36+
Home Assistant (Container) can be found in the `Build Stack` menu. Selecting it in this menu results in a service definition being added to:
20337

20438
```
20539
~/IOTstack/docker-compose.yml
@@ -222,40 +56,58 @@ $ cd ~/IOTstack
22256
$ docker-compose up -d
22357
```
22458

225-
## <a name="deactivateHassio"> Deactivating Hass.io </a>
59+
### <a name="installHASupervised"> Installing Supervised Home Assistant </a>
22660

227-
Because Hass.io is independent of IOTstack, you can't deactivate it with any of the commands you normally use for IOTstack.
61+
The direction being taken by the Home Assistant folks is to supply a ready-to-run image for your Raspberry Pi. That effectively dedicates your Raspberry Pi to Home Assistant and precludes the possibility of running alongside IOTstack and containers like Mosquitto, InfluxDB, Node-RED, Grafana, PiHole and WireGuard.
22862

229-
To deactivate Hass.io you first need to stop the service that controls it. Run the following commands in the terminal:
63+
It is possible to run Supervised Home Assistant on the same Raspberry Pi as IOTstack. The recommended approach is to start from a clean slate and use [PiBuilder](https://github.com/Paraphraser/PiBuilder).
23064

231-
```bash
232-
$ sudo systemctl stop hassio-supervisor.service
233-
$ sudo systemctl disable hassio-supervisor.service
234-
```
65+
When you visit the PiBuilder link you may well have a reaction like "all far too complicated" but you should try to get past that. PiBuilder has two main use-cases:
23566

236-
This will stop the main service and prevent it from starting on the next boot. Next you need to stop and remove the dependent services:
67+
1. Getting a Raspberry Pi built for IOTstack (and, optionally, Supervised Home Assistant) with the least fuss.
68+
2. Letting you record all your own customisations so that you can rebuild your Pis quickly with all your customisations already in place (the "magic smoke" scenario).
23769

238-
```bash
239-
$ docker stop hassio_audio hassio_cli hassio_dns hassio_multicast hassio_observer homeassistant
240-
$ docker rm hassio_audio hassio_cli hassio_dns hassio_multicast hassio_observer homeassistant
241-
```
70+
It's the second use-case that produces most of the apparent complexity you see when you read the [PiBuilder README](https://github.com/Paraphraser/PiBuilder/blob/master/README.md) for the first time.
71+
72+
The first time you use PiBuilder, the process boils down to:
73+
74+
1. Clone the PiBuilder repo onto your support host (Mac, Windows, etc).
75+
2. Customise two files within the PiBuilder scope:
76+
77+
- `wpa_supplicant.conf`
78+
- `options.sh` where, among other things, you will enable:
79+
80+
- `HOME_ASSISTANT_SUPERVISED_INSTALL=true`
81+
82+
3. Choose a Raspbian image and transfer it to your installation media (SD/SSD). The imaging tools typically finish by ejecting the installation media.
83+
4. Re-mount the installation media on your support host and either:
24284

243-
Double-check with `docker ps` to see if there are other containers running with a `hassio_` prefix. They can stopped and removed in the same fashion for `hassio_audio` and so-on.
85+
- Run the supplied `setup_boot_volume.sh` script (if your support host is macOS or Unix); or
86+
- Just drag the *contents* of the PiBuilder "boot" folder into the top level of the "/boot" partition on your installation media (if your support host is Windows).
24487

245-
The stored files are located in `/usr/share/hassio` which can be removed if you need to.
88+
5. Move the installation media to your Raspberry Pi and apply power.
89+
6. Run the scripts in order:
24690

247-
You can use Portainer to view what is running and clean up the unused images.
91+
Step | Command run on support host | Command run on Raspberry Pi
92+
:---:|-----------------------------------|-------------
93+
1 | `ssh -4 [email protected]` |
94+
2 | | `/boot/scripts/01_setup.sh «name»`
95+
3 | `ssh-keygen -R raspberrypi.local` |
96+
4 | `ssh -4 pi@«name».local` |
97+
5 | | `/boot/scripts/02_setup.sh`
98+
6 | `ssh pi@«name».local` |
99+
7 | | `/boot/scripts/03_setup.sh`
100+
8 | `ssh pi@«name».local` |
101+
9 | | `/boot/scripts/04_setup.sh`
102+
10 | `ssh pi@«name».local` |
103+
11 | | `/boot/scripts/05_setup.sh`
248104

249-
At this point, Hass.io is stopped and will not start again after a reboot. Your options are:
105+
where «name» is the name you give to your Raspberry Pi (eg "iot-hub").
250106

251-
* Leave things as they are; or
252-
* Re-install Hass.io by starting over at [Installing Hass.io](#installHassio); or
253-
* Re-activate Hass.io by:
107+
After step 9, Supervised Home Assistant will be running. The `04_setup.sh` script also deals with the [random MACs](#aboutRandomMACs) problem. After step 11, you'll be able to either:
254108

255-
```bash
256-
$ sudo systemctl enable hassio-supervisor.service
257-
$ sudo systemctl start hassio-supervisor.service
258-
```
109+
1. Restore a backup; or
110+
2. Run the IOTstack menu and choose your containers.
259111

260112
## <a name="aboutRandomMACs"> Why random MACs are such a hassle </a>
261113

scripts/native_installs.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,6 @@ def onResize(sig, action):
3030
if (screenActive):
3131
mainRender(1, mainMenuList, currentMenuItemIndex)
3232

33-
def installHassIo():
34-
print(term.clear())
35-
print("Install Home Assistant Supervisor")
36-
print("./.native/hassio_supervisor.sh")
37-
res = subprocess.call("./.native/hassio_supervisor.sh", shell=True)
38-
print("")
39-
if res == 0:
40-
print("Preinstallation complete. Your system may run slow for a few hours as Hass.io installs its services.")
41-
print("Press [Up] or [Down] arrow key to show the menu if it has scrolled too far.")
42-
else:
43-
print("Preinstallation not completed.")
44-
input("Process terminated. Press [Enter] to show menu and continue.")
45-
time.sleep(0.5)
46-
return True
47-
4833
def installRtl433():
4934
print(term.clear())
5035
print("Install RTL_433")
@@ -93,7 +78,6 @@ def goBack():
9378
return True
9479

9580
mainMenuList = [
96-
["Hass.io (Supervisor)", installHassIo],
9781
["RTL_433", installRtl433],
9882
["RPIEasy", installRpiEasy],
9983
["Upgrade Docker and Docker-Compose", upgradeDockerAndCompose],

0 commit comments

Comments
 (0)