Raspi - Homeassistant (Docker)

1. configure boot from SSD
https://www.tomshardware.com/how-to/boot-raspberry-pi-4-usb

sudo apt update -y
sudo apt full-upgrade -y
sudo rpi-update -y
sudo raspi-config
#change hostname
> System Options > Hostname (HassPi)
sudo reboot

#IF SSD disk BOOT needed
sudo rpi-eeprom-update -d -a
>Select Boot Options
>Select Boot ROM Version
>Select Latest > OK
>Select No to use the latest boot ROM
>Select Boot Order
>Select USB Boot and click Ok
>Select Finish 
##END IF

2. img load + enable SSH
# rufus rasbian image > SSD disk (same way as to uSD card)
# in  Total commander - add to root of Raspi disk file "ssh" (Shift+F4 -> name "ssh" + save empty file)


3. Keyboard
sudo raspi-config
> Localization option > Timezone; change keyboard to us, enable camera


3.5 Install NTP server for IoT network
sudo apt install ntp -y
sudo systemctl status ntp
sudo systemctl is-enabled ntp
#response should  be: enabled
sudo nano /etc/ntp.conf

#edit/replace:
...
#pool 0.debian.pool.ntp.org iburst
#pool 1.debian.pool.ntp.org iburst
#pool 2.debian.pool.ntp.org iburst
#pool 3.debian.pool.ntp.org iburst
server 0.europe.pool.ntp.org iburst
server 1.europe.pool.ntp.org iburst
server 2.europe.pool.ntp.org iburst
server 3.europe.pool.ntp.org iburst
...

restrict 10.0.0.0
restrict 192.0.0.0
keep: restric 127... and :::1

#save

sudo systemctl restart ntp
sudo systemctl enable ntp
sudo ntpq -p

#timedatectl list-timezones
#sudo timedatectl set-timezone Europe/Prague

sudo apt-get install ntpdate -y
sudo ntpdate -u 10.168.100.254
sudo crontab -e
10 7   *   *   *    sudo ntpdate -u 10.168.100.254


######################################
Network:

1. eth0 - 192.168.100.254 Inet (RAIV) 
2. eth1 (USB LAN) - 10.168.100.254 (IoT GW 1)
3. wlan0 - 10.168.100.253 (IoT GW 1)

sudo nano /boot/wpa_supplicant.conf
#add to file:
country=cz
update_config=1
ctrl_interface=/var/run/wpa_supplicant
 
network={
    scan_ssid=1
    ssid="RAIVIoT"
    psk="aklizdog"
}

sudo nano /etc/dhcpcd.conf

#wlan0 Mac addresses randomization disable
ip link show
sudo nano /etc/NetworkManager/NetworkManager.conf
#add
[device]
wifi.scan-rand-mac-address=no

###############
sudo nano /etc/dhcpcd.conf

#edit:
interface eth0
request 192.168.100.254
static ip_address=192.168.100.254/24
arping 192.168.100.254
#static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=192.168.100.253
static domain_name_servers=192.168.100.88 8.8.8.8

interface eth1
request 10.168.100.254
arping 10.168.100.254
static ip_address=10.168.100.254/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=10.168.100.1
static domain_name_servers=10.168.100.1 8.8.8.8

interface wlan0
request 10.168.100.253
arping 10.168.1000.253
static ip_address=10.168.100.253/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=10.168.100.1
static domain_name_servers=10.168.100.1 8.8.8.8

############

Save ctrl+x + Y
###


######################################
SOUND CARD:
sudo aplay -l
sudo arecord -L
sudo apt install pulseaudio mpg123
pacmd list-sources 
#or
pactl list 
# show PulseAudio devices. 


5. Docker HASS install
#https://github.com/home-assistant/supervised-installer
#https://community.home-assistant.io/t/homeassistant-docker-install-problem/211541/4

sudo -i

apt-get install -y software-properties-common apparmor-utils apt-transport-https avahi-daemon ca-certificates curl dbus jq network-manager socat

# continue

systemctl disable ModemManager

systemctl stop ModemManager

curl -fsSL get.docker.com | sh

curl -sL "https://raw.githubusercontent.com/Kanga-Who/home-assistant/master/supervised-installer.sh" | bash -s -- -m raspberrypi4

#!!!! Answer "NO" for changhes in Interfaces


########### SQL LITE >>> MySQL

Install the MariaDB add-on (Supervisor menu).
Follow the instructions (Documentation tab and Configuration tab of the add-on – you have to update one single line in the add-on configuration and add two lines to your HA config).
Start the add-on (check the add-on log to see whether all went well)
Restart HA

password: godzilka

#Addonstore - File Edit addon
#config.yaml

#add:
recorder:
  db_url: mysql://homeassistant:godzilka@core-mariadb/homeassistant?charset=utf8

#### Configure MQTT server

1. Supervisor > Install the Mosquitto add-on 160 with the default configuration via ‘Hass.io 36 > ADD-ON STORE’. (Don’t forget to start the add-on & verify that ‘Start on boot’ is enabled.) [DONE]
2. (enable Advanced Mode : click on User Icon (down/left) >>>> Enable Advanced Mode
3. Create a new user for MQTT via the Configuration > Users (manage users) . (Note: This name cannot be “homeassistant” or “addon”) [CAN’T CREATE A USER - JUST DELETE THE EXISTING ONE]
l: mqtb
p: godzilka

4. Once back on-line, return to Configuration > Integrations and select configure next to MQTT . [IT’s EMPTY - THIS INTEGRATION HAS NO DEVICES]


On Device - put user and password

# addon store  - Grafana
# addon store  - ESPHome
# addon store  - SambaShare
# addon store  - Portainer
>Settings> Remove all hidden containers
>Containers > homeassistant > _bash
#run:
apk add --no-cache libwebp ffmpeg-libs libdc1394 zlib 
apk add --no-cache --virtual .build-dependencies build-base cmake ncurses linux-headers ffmpeg-dev libwebp-dev libpng-dev zlib-dev libjpeg-turbo-dev tiff-dev libdc1394-dev 
pip3 install opencv-python

### Install ADA + Almond addons


Write a New Comment
Maximum number of characters for comment: 512
 If you cann't see Verification Code clearly.
Write Verification Code(Required field)