-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add software package: Home Assistant
- Loading branch information
1 parent
82cf417
commit 0d04aaf
Showing
5 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|Functionality|HAOS|Armbian with HA| | ||
|:--|:--:|:--:| | ||
|Automations|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:| | ||
|Dashboards|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:| | ||
|Integrations|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:| | ||
|Add-ons|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:| | ||
|One-click updates|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:| | ||
|Backups|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:| | ||
|General purpose server|:x:|:white_check_mark:| | ||
|Running on exotic hardware|:x:|:white_check_mark:| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Home Assistant is an open source smart home platform that allows you to connect your smart home devices like your TV, fan, cameras, thermostats, lights, and sensors. As a user, you can build intricate automation using Home Assistant's user-friendly, unified web-based user interface. | ||
|
||
Perfect to run on any single board computer with 4 cores and at least 512Mb of memory. Armbian installation is optimised to run from SD/eMMC media, but it is recommended to use SSD. | ||
|
||
=== "Access to the web interface" | ||
|
||
The web interface is accessible via port **8123**: | ||
|
||
- URL: `https://<your.IP>:8123` | ||
- Username/Password: Are set at first web interface login | ||
|
||
=== "Directories" | ||
|
||
Home Assistant on Armbian runs supervised in a Docker container. This secures same functionality as stock HAOS. | ||
|
||
- Config directory: `/usr/share/haos` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
declare -A module_options | ||
module_options+=( | ||
["module_haos,author"]="@igorpecovnik" | ||
["module_haos,feature"]="module_haos" | ||
["module_haos,example"]="help install uninstall" | ||
["module_haos,desc"]="Hos container install and configure" | ||
["module_haos,ports"]="8123" | ||
["module_haos,status"]="review" | ||
) | ||
# | ||
# Install haos container | ||
# | ||
module_haos() { | ||
|
||
case "${ARCH}" in | ||
armhf) MACHINE="tinker";; | ||
amd64) MACHINE="generic-x86-64";; | ||
arm64) MACHINE="odroid-n2";; | ||
esac | ||
|
||
|
||
# dependency | ||
# command -v unzip systemd-journal-remote apparmor cifs-utils nfs-common network-manager udisks2 | ||
|
||
# ha agent | ||
[[ "${ARCH}" == "armhf" ]] && local ha_os_agent_arch="armv7" | ||
[[ "${ARCH}" == "arm64" ]] && local ha_os_agent_arch="aarch64" | ||
[[ "${ARCH}" == "amd64" ]] && local ha_os_agent_arch="x86_64" | ||
local ha_os_agent_cache_dir=$(mktemp -d /tmp/XXXXXXXXXX) | ||
local ha_os_agent_version="1.6.0" | ||
local ha_os_supervised_commit="c99ffd00fcb32c06fc4140040c9ee7e919becce9" | ||
local ha_os_agent_filename="os-agent_${ha_os_agent_version}_linux_${ha_os_agent_arch}.deb" | ||
local ha_os_agent_url="https://github.com/home-assistant/os-agent/releases/download/${ha_os_agent_version}/${ha_os_agent_filename}" | ||
local ha_os_agent_cache_file="${ha_os_agent_cache_dir}/${ha_os_agent_filename}" | ||
|
||
# supervised deb: all | ||
local ha_supervised_version="1.6.0" | ||
local ha_supervised_filename="homeassistant-supervised_${ha_supervised_version}.deb" | ||
local ha_supervised_url="https://github.com/home-assistant/supervised-installer/releases/download/${ha_supervised_version}/homeassistant-supervised.deb" | ||
local ha_supervised_cache_file="${ha_os_agent_cache_dir}/${ha_supervised_filename}" | ||
|
||
if check_if_installed docker-ce; then | ||
local container=$(docker container ls -a | mawk '/home-assistant/{print $1}') | ||
local image=$(docker image ls -a | mawk '/home-assistant/{print $3}') | ||
fi | ||
# Convert the example string to an array | ||
local commands | ||
IFS=' ' read -r -a commands <<< "${module_options["module_haos,example"]}" | ||
|
||
case "$1" in | ||
"${commands[0]}") | ||
## help/menu options for the module | ||
echo -e "\nUsage: ${module_options["module_haos,feature"]} <command>" | ||
echo -e "Commands: ${module_options["module_haos,example"]}" | ||
echo "Available commands:" | ||
if [[ "${container}" ]] || [[ "${image}" ]]; then | ||
echo -e "\tstatus\t- Show the status of the $title service." | ||
echo -e "\tremove\t- Remove $title." | ||
else | ||
echo -e " install\t- Install $title." | ||
fi | ||
echo | ||
;; | ||
install) | ||
check_if_installed docker-ce || install_docker | ||
|
||
# hack to force install | ||
sed -i 's/^PRETTY_NAME=".*/PRETTY_NAME="Debian GNU\/Linux 12 (bookworm)"/g' "${SDCARD}/etc/os-release" | ||
|
||
# we host packages at our repository and version for both is determined: | ||
# https://github.com/armbian/os/blob/main/external/haos-agent.conf | ||
# https://github.com/armbian/os/blob/main/external/haos-supervised-installer.conf | ||
|
||
apt_install_wrapper apt-get -y install --download-only homeassistant-supervised os-agent | ||
|
||
# this we can't put behind wrapper | ||
MACHINE="${MACHINE}" apt-get -y install homeassistant-supervised os-agent | ||
|
||
# workarounding supervisor loosing healthy state https://github.com/home-assistant/supervisor/issues/4381 | ||
cat <<- SUPERVISOR_FIX > "/usr/local/bin/supervisor_fix.sh" | ||
#!/bin/bash | ||
while true; do | ||
if ha supervisor info 2>&1 | grep -q "healthy: false"; then | ||
echo "Unhealthy detected, restarting" | systemd-cat -t $(basename "$0") -p debug | ||
systemctl restart hassio-supervisor.service | ||
sleep 600 | ||
else | ||
sleep 5 | ||
fi | ||
done | ||
SUPERVISOR_FIX | ||
|
||
# add executable bit | ||
chmod +x "/usr/local/bin/supervisor_fix.sh" | ||
|
||
# generate service file to run this script | ||
cat <<- SUPERVISOR_FIX_SERVICE > "/etc/systemd/system/supervisor-fix.service" | ||
[Unit] | ||
Description=Supervisor Unhealthy Fix | ||
[Service] | ||
StandardOutput=null | ||
StandardError=null | ||
ExecStart=/usr/local/bin/supervisor_fix.sh | ||
[Install] | ||
WantedBy=multi-user.target | ||
SUPERVISOR_FIX_SERVICE | ||
|
||
if [[ -f /boot/armbianEnv.txt ]]; then | ||
echo "extraargs=systemd.unified_cgroup_hierarchy=0 apparmor=1 security=apparmor" >> "/boot/armbianEnv.txt" | ||
fi | ||
|
||
for s in {1..10};do | ||
for i in {0..100..10}; do | ||
j=$i | ||
echo "$i" | ||
sleep 1 | ||
done | ||
ha supervisor info --raw-json >/dev/null | ||
if [[ $status -eq 0 ]]; then break; fi | ||
done | $DIALOG --gauge "Preparing Home Assistant Supervised\n\nPlease wait! " 10 50 0 | ||
|
||
# enable service | ||
systemctl enable supervisor-fix >/dev/null 2>&1 | ||
systemctl start supervisor-fix >/dev/null 2>&1 | ||
|
||
$DIALOG --msgbox "Reboot is required to finish installation.\n\nAfter reboot, you need to wait few minutes that website on port 8123 becomes available! " 10 46 | ||
;; | ||
uninstall) | ||
# disable service | ||
systemctl disable supervisor-fix >/dev/null 2>&1 | ||
systemctl stop supervisor-fix >/dev/null 2>&1 | ||
apt_install_wrapper apt-get -y purge homeassistant-supervised os-agent | ||
TERM=linux $DIALOG --infobox "Removing Home Assistant containers.\n\nPlease wait! " 6 40 | ||
if [[ "${container}" ]]; then | ||
echo "${container}" | xargs docker stop >/dev/null 2>&1 | ||
echo "${container}" | xargs docker rm >/dev/null 2>&1 | ||
fi | ||
if [[ "${image}" ]]; then | ||
echo "${image}" | xargs docker image rm >/dev/null 2>&1 | ||
fi | ||
rm -f /usr/local/bin/supervisor_fix.sh | ||
rm -f /etc/systemd/system/supervisor-fix.service | ||
sed -i "s/ systemd.unified_cgroup_hierarchy=0 apparmor=1 security=apparmor//" /boot/armbianEnv.txt | ||
systemctl daemon-reload >/dev/null 2>&1 | ||
# restore os-release | ||
sed -i "s/^PRETTY_NAME=\".*/PRETTY_NAME=\"${VENDOR} ${REVISION} ($VERSION_CODENAME)\"/g" "/etc/os-release" | ||
;; | ||
status) | ||
[[ "${container}" ]] || [[ "${image}" ]] && return 0 | ||
;; | ||
esac | ||
} | ||
|
||
module_haos "$1" |