Skip to content

Commit 5e3a5bb

Browse files
authored
HomeAssistant-Core: update script for 2025.5+ (#4363)
* HomeAssistant-Core: update script for 2025.5+ * Update homeassistant-core-install.sh
1 parent 7413a03 commit 5e3a5bb

File tree

2 files changed

+63
-24
lines changed

2 files changed

+63
-24
lines changed

ct/homeassistant-core.sh

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ catch_errors
2121

2222
function update_script() {
2323
header_info
24-
25-
# OS Check
2624
if ! lsb_release -d | grep -q "Ubuntu 24.10"; then
2725
msg_error "Wrong OS detected. This script only supports Ubuntu 24.10."
2826
msg_error "Read Guide: https://github.com/community-scripts/ProxmoxVE/discussions/1549"
@@ -32,54 +30,88 @@ function update_script() {
3230
check_container_resources
3331
if [[ ! -d /srv/homeassistant ]]; then
3432
msg_error "No ${APP} Installation Found!"
35-
exit
33+
exit 1
3634
fi
37-
PY=$(ls /srv/homeassistant/lib/)
35+
setup_uv
3836
IP=$(hostname -I | awk '{print $1}')
3937
UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UPDATE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 4 \
4038
"1" "Update Core" ON \
4139
"2" "Install HACS" OFF \
4240
"3" "Install FileBrowser" OFF \
4341
3>&1 1>&2 2>&3)
42+
4443
if [ "$UPD" == "1" ]; then
4544
if (whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SELECT BRANCH" --yesno "Use Beta Branch?" 10 58); then
4645
clear
4746
header_info
4847
echo -e "${GN}Updating to Beta Version${CL}"
49-
BR="--pre "
48+
BR="--pre"
5049
else
5150
clear
5251
header_info
5352
echo -e "${GN}Updating to Stable Version${CL}"
5453
BR=""
5554
fi
55+
5656
msg_info "Stopping Home Assistant"
5757
systemctl stop homeassistant
5858
msg_ok "Stopped Home Assistant"
5959

60+
if [[ -d /srv/homeassistant/bin ]]; then
61+
msg_info "Migrating to .venv-based structure"
62+
$STD source /srv/homeassistant/bin/activate
63+
PY_VER=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
64+
$STD deactivate
65+
mv /srv/homeassistant "/srv/homeassistant_backup_$PY_VER"
66+
mkdir -p /srv/homeassistant
67+
cd /srv/homeassistant
68+
69+
$STD uv python install 3.13
70+
UV_PYTHON=$(uv python list | awk '/3\.13\.[0-9]+.*\/root\/.local/ {print $2; exit}')
71+
if [[ -z "$UV_PYTHON" ]]; then
72+
msg_error "No local Python 3.13 found via uv"
73+
exit 1
74+
fi
75+
76+
$STD uv venv .venv --python "$UV_PYTHON"
77+
$STD source .venv/bin/activate
78+
$STD uv pip install homeassistant mysqlclient psycopg2-binary isal webrtcvad wheel
79+
mkdir -p /root/.homeassistant
80+
msg_ok "Migration complete"
81+
else
82+
source /srv/homeassistant/.venv/bin/activate
83+
fi
84+
6085
msg_info "Updating Home Assistant"
61-
source /srv/homeassistant/bin/activate
62-
$STD pip install ${BR}--upgrade homeassistant
86+
$STD uv pip install $BR --upgrade homeassistant
6387
msg_ok "Updated Home Assistant"
6488

6589
msg_info "Starting Home Assistant"
90+
if [[ -f /etc/systemd/system/homeassistant.service ]] && grep -q "/srv/homeassistant/bin/python3" /etc/systemd/system/homeassistant.service; then
91+
sed -i 's|ExecStart=/srv/homeassistant/bin/python3|ExecStart=/srv/homeassistant/.venv/bin/python3|' /etc/systemd/system/homeassistant.service
92+
sed -i 's|PATH=/srv/homeassistant/bin|PATH=/srv/homeassistant/.venv/bin|' /etc/systemd/system/homeassistant.service
93+
$STD systemctl daemon-reload
94+
fi
95+
6696
systemctl start homeassistant
67-
sleep 2
97+
sleep 5
6898
msg_ok "Started Home Assistant"
6999
msg_ok "Update Successful"
70-
echo -e "\n Go to http://${IP}:8123 \n"
100+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8123${CL}"
71101
exit
72102
fi
103+
73104
if [ "$UPD" == "2" ]; then
74105
msg_info "Installing Home Assistant Community Store (HACS)"
75106
$STD apt update
76107
$STD apt install -y unzip
77-
cd .homeassistant
108+
cd /root/.homeassistant
78109
$STD bash <(curl -fsSL https://get.hacs.xyz)
79110
msg_ok "Installed Home Assistant Community Store (HACS)"
80111
echo -e "\n Reboot Home Assistant and clear browser cache then Add HACS integration.\n"
81112
exit
82113
fi
114+
83115
if [ "$UPD" == "3" ]; then
84116
set +Eeuo pipefail
85117
read -r -p "Would you like to use No Authentication? <y/N> " prompt
@@ -131,4 +163,4 @@ description
131163
msg_ok "Completed Successfully!\n"
132164
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
133165
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
134-
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8123${CL}"
166+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8123${CL}"

install/homeassistant-core-install.sh

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,33 @@ $STD apt-get install -y \
4646
pkg-config
4747
msg_ok "Installed Dependencies"
4848

49+
setup_uv
4950
msg_info "Setup Python3"
50-
$STD apt-get update
51-
$STD rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
52-
$STD apt-get remove --purge -y python3.12 python3.12-dev python3.12-venv
53-
5451
$STD apt-get install -y \
5552
python3.13 \
56-
python3-pip \
5753
python3.13-dev \
5854
python3.13-venv
59-
60-
ln -sf /usr/bin/python3.13 /usr/bin/python3
6155
msg_ok "Setup Python3"
6256

57+
msg_info "Preparing Python 3.13 for uv"
58+
$STD uv python install 3.13
59+
UV_PYTHON=$(uv python list | awk '/3\.13\.[0-9]+.*\/root\/.local/ {print $2; exit}')
60+
if [[ -z "$UV_PYTHON" ]]; then
61+
msg_error "No local Python 3.13 found via uv"
62+
exit 1
63+
fi
64+
msg_ok "Prepared Python 3.13"
65+
6366
msg_info "Setting up Home Assistant-Core environment"
64-
mkdir /srv/homeassistant
67+
rm -rf /srv/homeassistant
68+
mkdir -p /srv/homeassistant
6569
cd /srv/homeassistant
66-
python3 -m venv .
67-
source bin/activate
70+
$STD uv venv .venv --python "$UV_PYTHON"
71+
source .venv/bin/activate
6872
msg_ok "Created virtual environment"
6973

7074
msg_info "Installing Home Assistant-Core"
71-
$STD python3 -m pip install webrtcvad wheel homeassistant mysqlclient psycopg2-binary isal
75+
$STD uv pip install homeassistant mysqlclient psycopg2-binary isal webrtcvad wheel
7276
mkdir -p /root/.homeassistant
7377
msg_ok "Installed Home Assistant-Core"
7478

@@ -77,16 +81,19 @@ cat <<EOF >/etc/systemd/system/homeassistant.service
7781
[Unit]
7882
Description=Home Assistant
7983
After=network-online.target
84+
8085
[Service]
8186
Type=simple
8287
WorkingDirectory=/root/.homeassistant
83-
Environment="PATH=/srv/homeassistant/bin:/usr/local/bin:/usr/bin:/usr/local/bin/uv"
84-
ExecStart=/srv/homeassistant/bin/python3 -m homeassistant --config /root/.homeassistant
88+
Environment="PATH=/srv/homeassistant/.venv/bin:/usr/local/bin:/usr/bin"
89+
ExecStart=/srv/homeassistant/.venv/bin/python3 -m homeassistant --config /root/.homeassistant
8590
Restart=always
8691
RestartForceExitStatus=100
92+
8793
[Install]
8894
WantedBy=multi-user.target
8995
EOF
96+
9097
systemctl enable -q --now homeassistant
9198
msg_ok "Created Service"
9299

0 commit comments

Comments
 (0)