Draft work: Self hosting my home (part 1)
|
@ -1,88 +0,0 @@
|
|||
title: Home Assistant my home (part 1)
|
||||
---
|
||||
_discoverable: no
|
||||
---
|
||||
pub_date: 2021-12-31
|
||||
---
|
||||
body:
|
||||
|
||||
Summary
|
||||
|
||||
I wanted to install this on a USB Drive, but apparently that's still not supported for _Home Assistant OS_, so I'm stuck with an SD Card for now. The latest development version (as of writting) does support it but I'd rather go with the stable release.
|
||||
|
||||
## Base Home Assistant OS using an SD Card
|
||||
|
||||
For this just stick to the [official documentation](https://www.home-assistant.io/hassio/installation/). Only download the latest release [from github](https://github.com/home-assistant/operating-system/releases) and copy the _img_ card to your SD Card with `dd`, Balena or the tool of choice.
|
||||
|
||||
Put the SD Card on your Pi, turn it on and let's get started.
|
||||
|
||||
## Base installation
|
||||
|
||||
After booting, you will be welcomed with a wizard installation. Just follow the basic instructions to generate the main user/account, and the name and location for your home assistant.
|
||||
|
||||
Bonus: Use some website [like this](https://www.freemaptools.com/elevation-finder.htm) to get your elevenation if you're feeling picky.
|
||||
|
||||
After that, you will be greeted by something similar to this:
|
||||
|
||||
[](./base.png)
|
||||
|
||||
## Update the system
|
||||
|
||||
Go to your Supervisor tab and check if you have any pending updates.
|
||||
|
||||
## Moving to MariaDB
|
||||
|
||||
The default database backend is SQLite, and that has it's limitations, so let's move everything to MariaDB before any other configuration.
|
||||
|
||||
1. Install the File editor addon from **Supervisor > Add-ons > File editor** and start it.
|
||||
2. Install the MySQL addon from **Supervisor > Add-ons > MariaDB**
|
||||
3. Once installed, go to the configuration tab and set a password
|
||||
4. Under the Info tab start the MariaDB Service and enable the Watchdog service
|
||||
5. Go to the file editor interface and edit the `configuration.yaml` file.
|
||||
6. Add the configuration for the [`recorder`](https://www.home-assistant.io/integrations/recorder/) integration:
|
||||
``` yaml
|
||||
recorder:
|
||||
db_url: mysql://homeassistant:<password>@core-mariadb/homeassistant?charset=utf8
|
||||
commit_interval: 5
|
||||
purge_keep_days: 90
|
||||
|
||||
history:
|
||||
```
|
||||
|
||||
In this case I also set data to be stored for 90 days and a 5s delay between disk writes (since I'm using an SD Card and their lifespan is not very long with abundant I/O).
|
||||
|
||||
More information on the documentation: [`recorder`](https://www.home-assistant.io/integrations/recorder/), [`history`](https://www.home-assistant.io/integrations/history/)
|
||||
7. Restart Home Assistant for the changes to take effect under **Configuration > Server Constrols > Restart**.
|
||||
|
||||
## Backups
|
||||
|
||||
TODO
|
||||
|
||||
## Setting up accounts and users that will use the system
|
||||
|
||||
This used to be more complex a while ago, now you only need to go to **Configuration > People** and add the users you need.
|
||||
|
||||
Now you can even add the avatar directly from the interface! Back in the day you required to upload the file and fidling with YAMLs.
|
||||
|
||||
## Adding integrations
|
||||
|
||||
TODO Summary
|
||||
|
||||
[](./notification.png)
|
||||
|
||||
### Chromecast
|
||||
|
||||
One of the simplest things to set up, just go to your integrations and add it. It will prompt you to select in which rooms each chromecast device is and that's it.
|
||||
|
||||
[](./chromecast.png)
|
||||
|
||||
### Weather (OpenWeatherMap)
|
||||
|
||||
Can't say much than I'm using the [`OpenWeatherMap`]() integration. You just need to register to the service and enable the integration under **Configuration > Integrations > OpenWeatherMap**, supply your API key and set the mode to __onecall_hourly__.
|
||||
|
||||
I had to wait for an hour or so until the API Key was valid for the integration to use.
|
||||
|
||||
## Phillips Hue
|
||||
|
||||
---
|
||||
_discoverable: no
|
BIN
content/blog/15-self-hosting-my-home-part-1/advanced-mode.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
229
content/blog/15-self-hosting-my-home-part-1/contents.lr
Normal file
|
@ -0,0 +1,229 @@
|
|||
|
||||
|
||||
title: Self-hosting my home: Installation and configuration, plug and play integrations
|
||||
---
|
||||
_discoverable: no
|
||||
---
|
||||
pub_date: 2021-12-31
|
||||
---
|
||||
body:
|
||||
|
||||
Summary
|
||||
|
||||
I wanted to install this on a USB Drive, but apparently that's still not supported for _Home Assistant OS_, so I'm stuck with an SD Card for now. The latest development version (as of writting) does support it but I'd rather go with the stable release.
|
||||
|
||||
## Base Home Assistant OS using an SD Card
|
||||
|
||||
For this just stick to the [official documentation](https://www.home-assistant.io/hassio/installation/). Only download the latest release [from github](https://github.com/home-assistant/operating-system/releases) and copy the _img_ card to your SD Card with `dd`, Balena or the tool of choice.
|
||||
|
||||
Put the SD Card on your Pi, turn it on and let's get started.
|
||||
|
||||
## Base installation
|
||||
|
||||
After booting, you will be welcome with a wizard installation. Just follow the basic instructions to generate the main user/account, and the name and location for your home assistant.
|
||||
|
||||
Bonus: Use some website [like this](https://www.freemaptools.com/elevation-finder.htm) to get your elevenation if you're feeling picky.
|
||||
|
||||
After that, you will be greeted by something similar to this:
|
||||
|
||||
[](./base.png)
|
||||
|
||||
## Update the system
|
||||
|
||||
Go to your Supervisor tab and check if you have any pending updates.
|
||||
|
||||
## Moving to MariaDB
|
||||
|
||||
The default database backend is SQLite, and that has it's limitations, so let's move everything to MariaDB before any other configuration.
|
||||
|
||||
1. Install the File editor addon from **Supervisor > Add-ons > File editor** and start it.
|
||||
2. Install the MySQL addon from **Supervisor > Add-ons > MariaDB**
|
||||
3. Once installed, go to the configuration tab and set a password
|
||||
4. Under the Info tab start the MariaDB Service and enable the Watchdog service
|
||||
5. Go to the file editor interface and edit the `configuration.yaml` file.
|
||||
6. Add the configuration for the [`recorder`](https://www.home-assistant.io/integrations/recorder/) integration:
|
||||
``` yaml
|
||||
recorder:
|
||||
db_url: mysql://homeassistant:<password>@core-mariadb/homeassistant?charset=utf8
|
||||
commit_interval: 5
|
||||
purge_keep_days: 90
|
||||
|
||||
history:
|
||||
```
|
||||
|
||||
In this case I also set data to be stored for 90 days and a 5s delay between disk writes (since I'm using an SD Card and their lifespan is not very long with abundant I/O).
|
||||
|
||||
More information on the documentation: [`recorder`](https://www.home-assistant.io/integrations/recorder/), [`history`](https://www.home-assistant.io/integrations/history/)
|
||||
7. Restart Home Assistant for the changes to take effect under **Configuration > Server Constrols > Restart**.
|
||||
|
||||
## Backups
|
||||
|
||||
Now another if not the most important of them all, automatic snapshots in case something goes wrong.
|
||||
|
||||
Go to **Configuration > Automations > Add automation**, and in top-right hamburger menu press **Edit as YAML**.
|
||||
|
||||
This configuration will perform a Weekly Snapshot every Monday at 3.00 AM. It is a sensible default once Home Assistant is running, but if you're going to play with it you may need to consider more frequency on the execution.
|
||||
|
||||
``` yaml
|
||||
alias: Weekly Snapshot
|
||||
description: 'Performs a weekly snapshot'
|
||||
mode: single
|
||||
trigger:
|
||||
- platform: time
|
||||
at: '03:00'
|
||||
condition:
|
||||
- condition: time
|
||||
weekday:
|
||||
- mon
|
||||
action:
|
||||
- service: hassio.snapshot_full
|
||||
data:
|
||||
name: 'weekly_{{ now().strftime(''%Y-%m-%d'') }}'
|
||||
```
|
||||
|
||||
## Setting up accounts and users that will use the system
|
||||
|
||||
This used to be more complex a while ago, now you only need to go to **Configuration > People** and add the users you need.
|
||||
|
||||
Now you can even add the avatar directly from the interface! Back in the day you required to upload the file and fidling with YAMLs.
|
||||
|
||||
Also, for some options and add-ons to display, you need to enable "Advanced mode" on your user profile page.
|
||||
|
||||

|
||||
|
||||
## SSH Access
|
||||
|
||||
Easily handled by an integration, as almost everything with Home Assistant.
|
||||
|
||||
> For this add-on to show up you need to enable Advanced mode as shown in the previous step.
|
||||
|
||||
Just install the **Terminal and SSH** addon, add your ssh key under the configuration tab under the `authorized_keys` property, and expose a port for the SSH server on the host. After that Start the service and enable the Watchdog to monitor it in case it fails.
|
||||
|
||||
## Enable SSL
|
||||
|
||||
Nginx addon
|
||||
|
||||
```
|
||||
openssl genrsa -out homeassistant.key 2048
|
||||
openssl req -new -key homeassistant.key -out homeassistant.csr
|
||||
openssl x509 -req -in homeassistant.csr -CA ../CA.pem -CAkey ../CA.key -CAcreateserial -out homeassistant.crt -days 1825 -sha256
|
||||
```
|
||||
|
||||
## Getting the Home Assistant Companion
|
||||
|
||||
Download the application from your phone's store and after logging in you can setup the sensors to be sent to Home Assistant, this will be linked to your account so you could perform automations with them on the server.
|
||||
|
||||
Apart from using the app to control your home devices, the sensors will be useful to generate automations in the future.
|
||||
|
||||
Another useful thing to setup here is the local (LAN) address to use when the phone is connected to Wifi at home, using an external hostname when connecting via VPN/RemoteControl.
|
||||
|
||||
## Add system sensors
|
||||
|
||||
I want to control how the Raspberry is doing, so I'm going to enable some system sensors using the [`systemmonitor`](https://www.home-assistant.io/integrations/systemmonitor) sensor.
|
||||
|
||||
Edit the `configuration.yaml` file and add the following:
|
||||
|
||||
``` yaml
|
||||
sensor:
|
||||
- platform: systemmonitor
|
||||
resources:
|
||||
- type: disk_use_percent
|
||||
- type: memory_use_percent
|
||||
- type: swap_use_percent
|
||||
- type: load_1m
|
||||
- type: load_5m
|
||||
- type: load_15m
|
||||
- type: processor_use
|
||||
- type: processor_temperature
|
||||
- type: last_boot
|
||||
- type: throughput_network_in
|
||||
arg: eth0
|
||||
- type: throughput_network_out
|
||||
arg: eth0
|
||||
```
|
||||
|
||||
This requires a Home Assistant restart for the changes to take effect.
|
||||
|
||||
I also added a custom lovelace dashboard to monitor everything easily, here is the YAML configuration:
|
||||
|
||||
``` yaml
|
||||
views:
|
||||
- title: Overview
|
||||
path: overview
|
||||
icon: 'mdi:eye'
|
||||
badges: []
|
||||
cards:
|
||||
- type: gauge
|
||||
entity: sensor.processor_use_percent
|
||||
min: 0
|
||||
max: 100
|
||||
name: Processor
|
||||
severity:
|
||||
green: 50
|
||||
yellow: 75
|
||||
red: 80
|
||||
- type: gauge
|
||||
entity: sensor.memory_use_percent
|
||||
min: 0
|
||||
max: 100
|
||||
severity:
|
||||
green: 50
|
||||
yellow: 65
|
||||
red: 75
|
||||
name: Memory
|
||||
- type: history-graph
|
||||
entities:
|
||||
- entity: sensor.processor_use_percent
|
||||
- entity: sensor.memory_use_percent
|
||||
- entity: sensor.processor_temperature
|
||||
hours_to_show: 24
|
||||
refresh_interval: 0
|
||||
- type: history-graph
|
||||
entities:
|
||||
- sensor.disk_use_percent
|
||||
hours_to_show: 24
|
||||
refresh_interval: 0
|
||||
title: System
|
||||
```
|
||||
|
||||
## Adding integrations
|
||||
|
||||
At this point if you already have devices on your network your Home Assistant will send you a notification like this:
|
||||
|
||||
[](./notification.png)
|
||||
|
||||
So I'm going to setup the base integrations with the server to start controlling some devices.
|
||||
|
||||
### Chromecast
|
||||
|
||||
> But you said self-hosted! Yeah, yeah... And I want to, but there's no real alternative to the Cast protocol to self host, the speakers with Chromecast devices are just so convenient...
|
||||
|
||||
One of the simplest things to set up, just go to your integrations and add it. It will prompt you to select in which rooms each chromecast device is and that's it.
|
||||
|
||||
[](./chromecast.png)
|
||||
|
||||
### Weather (OpenWeatherMap)
|
||||
|
||||
I'm going to use the [`OpenWeatherMap`](https://www.home-assistant.io/integrations/openweathermap/) integration because it provides more sensors than the one setup by default.
|
||||
|
||||
You just need to [register to the service](https://openweathermap.org/) and enable the integration under **Configuration > Integrations > OpenWeatherMap**, supply your API key and set the mode to __onecall_hourly__ which will download 3h forecasts each hour, enough for the free tier.
|
||||
|
||||
> I had to wait for an hour or so until the API Key was valid for the integration to use, it keep saying **Invalid API Key** until I received a confirmation email for my account.
|
||||
|
||||
## Phillips Hue
|
||||
|
||||
Linking the Phillips Hue is super easy, you only need to add the Hue integration, select the bridge IP from the dropdown (or input one manually) and press the button on the bridge to confirm.
|
||||
|
||||
After selecting in which area the bridge and bulbs are in, you're good to go.
|
||||
|
||||
> **BONUS:** Since the comunication is done via LAN with the bridge, the bridge itself doesn't need internet access to work (as I have mine blocked in my firewall).
|
||||
|
||||
## Tuya (Smart Things)
|
||||
|
||||
This is one of the dependencies I have that I'm most eager to get rid off, but for now there are some smart plugs at home that I need to control.
|
||||
|
||||
To setup, you need to enter your username, password and country code for the integration to communicate with the Tuya API, so your devices will require internet connection.
|
||||
|
||||
The plan is to replace the plugs (and the water sensor which is not Home Assistant compatible) with ZigBee devices.
|
||||
---
|
||||
_discoverable: no
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |