jueves, 30 de enero de 2025

Proxmox + Home Assistant + Frigate

 First set automatic power on your MiniPC:

  1. Enter BIOS setup
  2. Use the arrow keys to enter the Chipset page. Select “PCH-IO Configuration” and press the Enter key.  
  3. Select “State After G3”
  4. Select “S0 State”. “S0 State” is to enable auto power on and “S5 State” is to disable auto power on.  
  5. Press the F4 and select “Yes” to save the configuration.

 

Run post install script:

wget https://github.com/tteck/Proxmox/raw/main/misc/post-pve-install.sh
chmod 777 post-pve-install.sh

#Edit the version part, and change from 0-2 to 0-3
vi post-pve-install.sh

# if ! pveversion | grep -Eq "pve-manager/8.[0-3]"; then

./post-pve-install.sh

 

Install microcode of the post intall https://tteck.github.io/Proxmox/#proxmox-ve-processor-microcode: 

bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/microcode.sh)"
 

Install home assistant from https://tteck.github.io/Proxmox/#home-assistant-os-vm:

bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/vm/haos-vm.sh)"

The output will be:

Using HAOS Version: 14.2
Virtual Machine ID: 100
Using Machine Type: i440fx
Using Disk Cache: Write Through
Using Hostname: homeassistant
Using CPU Model: Host
Allocated Cores: 2
Allocated RAM: 4096
Using Bridge: vmbr0
Using MAC Address: 02:34:76:B9:2D:64
Using Vlan: Default
Using Interface MTU Size: Default
Start VM when completed: yes
Creating a HAOS VM using the above advanced settings
 ✓ Using local-lvm for Storage Location.
 ✓ Virtual Machine ID is 100.
 ✓ https://github.com/home-assistant/operating-system/releases/download/14.2/haos_ova-14.2.qcow2.xz
 

Install Docker LXC from https://tteck.github.io/Proxmox/#docker-lxc:

bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/docker.sh)"


The output will be:

Using Advanced Settings
Using Distribution: debian
Using debian Version: 12
Using Container Type: 0
Using Root Password: ********
Container ID: 101
Using Hostname: docker
Using Disk Size: 8
Allocated Cores: 2
Allocated RAM: 4048
Using Bridge: vmbr0
Using IP Address: dhcp
Using Gateway IP Address: Default
Using APT-Cacher IP Address: Default
Disable IPv6: no
Using Interface MTU Size: Default
Using DNS Search Domain: Host
Using DNS Server IP Address: Host
Using Vlan: Default
Enable Root SSH Access: yes
Enable Verbose Mode: yes
Creating a Docker LXC using the above advanced settings
 ✓ Using local for Template Storage.
 ✓ Using local-lvm for Container Storage.
 ✓ Updated LXC Template List

✓ Installed Docker v27.5.1
Would you like to add Portainer? <y/N> y
 /Unable to find image 'portainer/portainer-ce:latest' locally
 |latest: Pulling from portainer/portainer-ce
dc8df0f2921e: Pull complete
c82aa9c9fb45: Pull complete
d40df14c1d7a: Pull complete
a3939f2dc487: Pull complete
204b2fbb824e: Pull complete
a53c840f28bf: Pull complete
9e1dadc4be73: Pull complete
6f01ec19fa2b: Pull complete
e2f767fe3885: Pull complete
793e77bf062e: Pull complete
4f4fb700ef54: Pull complete
Digest: sha256:bd8f7a6d98e2a512e18272c38914abd1e92d663451f3c925d502a8557a3b92d7
Status: Downloaded newer image for portainer/portainer-ce:latest
 -e8ac9405b5dfd602304e261754293398739e875839136698bc1a1ffc89b211e7
 ✓ Installed Portainer 2.21.5
Would you like to add Docker Compose? <y/N> y
 ✓ Installed Docker Compose v2.32.4
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
 |0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
 ✓ Cleaned
 ✓ Completed Successfully!

 

Run the following on the terminal

Coral Install
# This was all done from root user

#First verify your machine has MSI-X by running this command

lspci -vv | grep MSI-X

#Also make sure secure boot is disabled if you have that option



apt update && apt upgrade -y

# Not needed, just makes copy and pasting cmds easier
apt install sudo -y

echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list

curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

wget -O- https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/coral-edgetpu.gpg

apt update

sudo apt-get install gasket-dkms libedgetpu1-std -y

#likely not needed, but I was just being over cautious
reboot now  


mkdir /root/coral

cd /root/coral

apt remove gasket-dkms -y

apt install git devscripts dh-dkms -y

cd /home

git clone https://github.com/google/gasket-driver.git

cd gasket-driver/

debuild -us -uc -tc -b

cd ..

apt install pve-headers -y

dpkg -i gasket-dkms_1.0-18_all.deb

cd

apt update && apt upgrade -y

reboot now


# Verify the drivers are functioning properly

lspci -nn | grep 089a

ls /dev/apex_0


Install vim:

apt install vim


Prepare the directories for the containers:

mkdir /data

mkdir /data/cctv_clips
pct set 101 -mp0 /data/cctv_clips,mp=/cctv_clips
ll /data/cctv_clips/


Edit the conf to mount the google coral:

vim /etc/pve/lxc/101.conf


lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file 0, 0
lxc.mount.entry: /dev/apex_0 dev/apex_0 none bind,optional,create=file 0,0


ssh on the docker lxc

ssh root@10.2x.x.x


mkdir /opt/frigate
mkdir /opt/frigate/config
mkdir /opt/mqtt
mkdir /opt/mqtt/config

Edit the docker compose with the stuff of frigate pointing to the local IP.
vim /opt/frigate/docker-compose.yaml
vim /opt/frigate/config/config.yml


vim /opt/mqtt/docker-compose.yaml
vim /opt/mqtt/config/mosquitto.conf

vim /opt/mqtt/config/pwfile

cd /opt/mqtt/

docker compose up -d

cd /opt/frigate/

docker compose up -d

# docker ps
CONTAINER ID   IMAGE                                    COMMAND                  CREATED              STATUS                            PORTS                                                                                                                                                                                            NAMES
d5b6d1dce98b   ghcr.io/blakeblackshear/frigate:stable   "/init"                  33 seconds ago       Up 5 seconds (health: starting)   0.0.0.0:5000->5000/tcp, :::5000->5000/tcp, 0.0.0.0:8554-8555->8554-8555/tcp, :::8554-8555->8554-8555/tcp, 0.0.0.0:8971->8971/tcp, :::8971->8971/tcp, 0.0.0.0:8555->8555/udp, :::8555->8555/udp   frigate
7b57393e5d2a   eclipse-mosquitto                        "/docker-entrypoint.…"   About a minute ago   Restarting (3) 13 seconds ago                                                                                                                                                                                                      mqtt5
e8ac9405b5df   portainer/portainer-ce:latest            "/portainer"             31 minutes ago       Up 21 minutes                     0.0.0.0:8000->8000/tcp, :::8000->8000/tcp, 0.0.0.0:9443->9443/tcp, :::9443->9443/tcp, 9000/tcp 


You can test the connection to portainer 

https://10.255.x.x:9443/


Frigate

https://10.255.x.x:8971/



Go to the home assistant

http://10.255.101.16:8123/


Add HACS addon click on this link

https://my.home-assistant.io/redirect/supervisor_addon/?addon=cb646a50_get&repository_url=https%3A%2F%2Fgithub.com%2Fhacs%2Faddons

Click on install then click on start

 

 Restart home assistant 



Go to integrations and add HACS
Home Assistant > Settings > Devices & Services > Add Integration > HACS

Go to HACS and add Frigate and Frigate Card.

 

Go to integrations on settings  and add Frigate.

 Home Assistant > Settings > Devices & Services > Add Integration > Frigate

 Home Assistant > Settings > Devices & Services > Add Integration > MQTT

Configure you MQTT with your container.


Configure notifications

Go to settings > Automations