Install Home Assistant on Android

# Download Tmux APK
https://f-droid.org/de/packages/com.termux/
https://f-droid.org/repo/com.termux_118.apk

#pkg update -y
pkg upgrade -y
pkg install -y openssh # libcrypt
#ssh-keygen -A
sshd
passwd
id
ifconfig
 
# connect
ssh-copy-id -p 8022 u0_a63@192.168.178.114
ssh u0_a63@192.168.178.114 -p 8022
 
pkg install -y  python nano openssh termux-api make libjpeg-turbo vim
pkg install -y dbus-python python-apsw python-apt python-bcrypt python-cryptography python-numpy python-pillow python-tkinter python-tldp python-xcbgen binutils rust wget c-ares
 
python -m venv hass
source hass/bin/activate
 
wget https://files.pythonhosted.org/packages/01/50/e3015e6e03a3cf64113f509e8b86b71af37169b59ccedfcb182f3d031329/pycares-4.3.0.tar.gz
wget https://files.pythonhosted.org/packages/ff/4f/62d9859b7d4e6dc32feda67815c5f5ab4421e6909e48cbc970b6a40d60b7/aiohttp-3.8.3.tar.gz
tar -xvf pycares-4.3.0.tar.gz
tar -xvf aiohttp-3.8.3.tar.gz
 
cp -r ../usr/lib/python3.11/site-packages/* ./hass/lib/python3.11/site-packages/
# ln -s /data/data/com.termux/files/usr/lib/python3.11/site-packages ./hass/lib/python3.11/site-packages
 
pip install setuptools
 
cd aiohttp-3.8.3
sed -i s/3.8.3/3.8.1/g PKG-INFO
sed -i s/3.8.3/3.8.1/g  aiohttp/__init__.py
sed -i s/3.8.3/3.8.1/g aiohttp.egg-info/PKG-INFO
python setup.py install
cd
 
 
cd pycares-4.3.0
sed -i 's/#define HAVE_GETSERVBYPORT_R 1/\/\/#define HAVE_GETSERVBYPORT_R 1/g' deps/build-config/config_android/ares_config.h
python setup.py install
cd 
 
export RUSTFLAGS=" -C lto=no"
export CARGO_BUILD_TARGET="$(rustc -vV | sed -n 's|host: ||p')"
 
pip install wheel tzdata
 
MATHLIB=“m” pip install PyTurboJPEG==1.6.7
pkg install git
pip install git+https://github.com/amitdev/lru-dict
 
 
CFLAGS=-Wno-implicit-function-declaration MATHLIB=m pip install numpy==1.23.2
 
pip install git+https://github.com/boto/botocore
 
pip install homeassistant
./hass

Disable app background closing

https://appuals.com/xiaomi-phone-closes-background-apps/

Restore homeassistant backup to android

mv .homeassistant/ .homeassistant.$(date -I)
scp -P 8022 homeassistant.*.tar.bz2  u0_a172@192.168.178.222:/data/data/com.termux/files/home/

Home Assisstand client APK download
https://f-droid.org/packages/io.homeassistant.companion.android.minimal/
https://f-droid.org/repo/io.homeassistant.companion.android.minimal_10992.apk

# Mqtt Broker App
https://d.apkpure.com/b/APK/server.com.mqtt?version=latest

Backup

tar cjf homeassistant.$(date -I).tar.bz2 .homeassistant
scp  -P 8022 u0_a114@192.168.178.222:/data/data/com.termux/files/home/homeassistant.$(date -I).tar.bz2  ~/backup/

Links
https://community.home-assistant.io/t/homeassistant-core-on-android-guide-dec22/512168
https://community.home-assistant.io/t/home-assistant-core-on-android-tablet/250174
https://updato.com/how-to/manage-android-apps-running-background/
https://lucacesarano.medium.com/install-home-assistant-hass-on-android-no-root-fb65b2341126