Home Assistant Core on Android Tablet

Had this error, managed to fix it somehow (can’t remember how) and worked for several days without any issues. Today I restarted Termux and now I get this error again.
I can start with --safe-mode but nothing in the logs (no errors, no warnings, no failures)

EDIT:
I think I solved it. Try this:

pkg in proot
termux-chroot
source hass/bin/activate
hass -v
1 Like

I’ve built an installer for HA Core on Android / Termux (ARM64). It’s alpha, but works on my LineageOS 19 rooted device, and on Termux / ARM64 machines in the cloud.

For anyone eager to try, there is a one-liner web install (although please be prepared for this to possibly break Termux entirely - this is not production ready):

curl -sL https://github.com/talss89/termux-home-assistant-installer/releases/download/v2023.4.4-alpha.3/remote-install.sh | bash

Would be interested to see how this works for others. Please raise issues via the GitHub repo.

5 Likes

Congratulations for the work Talss89!
Awesome works on my Samsung Tab S2 lineage os 18(homeassistant 2023.5.3)! I just have an error for ha-av how can I fix?

talss89, I express my great gratitude to you for the work done! This is exactly what was needed and was asking for! I hope you won’t abandon the script and will update it as much as possible, thank you!

With hass - v boot, did you have any errors with ha-av?

newest HA & clang

yes | pkg update
pkg install python make cmake ninja patchelf rust libcrypt libffi libjpeg-turbo llvm binutils-is-llvm libsodium ffmpeg  libandroid-execinfo -y

pkg install python-numpy python-bcrypt python-cryptography python-pillow -y

python -m venv --without-pip --system-site-packages hass
source hass/bin/activate

pip install wheel
pip install tzdata
pip install maturin
pip install setuptools
pip install webrtcvad
pip install aiohttp_cors==0.7.0
MATHLIB=m pip install PyTurboJPEG==1.7.1

SODIUM_INSTALL=system pip install pynacl

CARGO_BUILD_TARGET="$(rustc -Vv | grep "host" | awk '{print $2}')" pip install homeassistant

hass -v --skip-pip-packages numpy
#after 2 min kill hass and start again
2 Likes

In order to avoid logspam due to wifi disconnection you can start HA with wifi turned off and then turn it on.

Or just change default network adapter in settings to “lo”

pycares fix

wget https://files.pythonhosted.org/packages/01/50/e3015e6e03a3cf64113f509e8b86b71af37169b59ccedfcb182f3d031329/pycares-4.3.0.tar.gz

tar -xf pycares-4.3.0.tar.gz

sed -i s/'#define HAVE_GETSERVBYPORT_R 1'//g ./pycares-4.3.0/deps/build-config/config_android/ares_config.h

pip install ./pycares-4.3.0
1 Like

Hi Daaflip, I also have the same problem, but I can’t solve it. What do you mean termux pinned?

Can this Home Assistant give any glitches when you use non-original hardware or ops?

Great script, two things though.

Maturin uses rust, so you need the cargo build target variable as well.

There is a problem currently with python 3.11: module ‘urllib3.util’ has no attribute ‘PROTOCOL_TLS’
The fix is currently to run pip install git+https://github.com/boto/botocore

@the.joker many android phones allow you to “pin” an app, this means it will stay active.

no problems for me on the fresh install, only numpy 1.23.2 had dlopen error
dlopen failed: cannot locate symbol “npy_nextafterf” referenc

I was to lazzy to fix it and just installed python-numpy (1.25.2)

pip uninstall numpy

pkg i python-numpy

hass -v --skip-pip-packages numpy
1 Like

Unfortunately I’ve had lot of issues with this recently. I use the tablet to launch another app to monitor cameras, and it looks like a recent update of this app introduced a memory leak.
And if your foreground app requests more and more memory, Android will terminate even the “wake lock” or “pinned” processes, it seems.

At least that’s what has happened to me for about a month, whenever I let this camera app run: Termux gets memory collected.

About fresh install, I’ve actually had a bunch of issues recently.
I’ve had my venv and most packages installed in there for more than 2 years now. Last week I messed up a command and ended up deleting the entire venv folder.

I’ve recreated from scratch, but I’m now experiencing issues I never had before.
First, I can’t start the stream domain because of a missing library, and I’m not sure where is it supposed to take it from:

2023-09-08 11:11:58.865 ERROR (MainThread) [homeassistant.setup] Error during setup of component stream
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/homeassistant/setup.py", line 288, in _async_setup_component
    result = await task
             ^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/homeassistant/components/stream/__init__.py", line 224, in async_setup
    from .recorder import async_setup_recorder
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/homeassistant/components/stream/recorder.py", line 9, in <module>
    import av
  File "/home/.homeassistant/deps/lib/python3.11/site-packages/av/__init__.py", line 20, in <module>
    from av._core import time_base, library_versions
ImportError: dlopen failed: library "libandroidicu.so" not found

Second and more annoying, I’m getting the same error as @djdery and @tzachov. I cannot start hass anymore unless I run termux-chroot before, because I get a “Bad System Call” error, and no detail whatsoever.

It never happened before, only since I reinstalled from scratch.
Not sure how to properly fix this one, or why it was working before that.


Edit: found this topic about the library [Bug]: opencv 4.8.0 program link libandroidicu.so error · Issue #17509 · termux/termux-packages · GitHub
It mentions:

i found, before i try to run the program, i should change my environment, so i run termux-chroot. after this i get the error.

Could be nothing, but could also be a hint that the first issue is caused by the second one :thinking:

system lib, I have it at
/apex/com.android.i18n/lib64/libandroidicu.so

You can rename /data/data/com.termux/files/home and /data/data/com.termux/files/usr and restart termux, after it you will have clean termux whitout erasing old one.

Hi, iam beginer. Homeassistant my phone termux but started many errors.
Use Termux Docker no root phones ???

pkg install root-repo
pkg install docker (version v1:20.10.24-ce)
pkg install docker-compose (version 2.19.1)
apt update
-that seems fine

How to install Docker-Compose other command???

??? what about:
wget https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb
dpkg -i homeassistant-supervised.deb

Hm, I don’t have access, I haven’t rooted the tablet.
That could explain the error, I suppose. But what I don’t understand is that a week ago, everything worked. I cannot figure out what was set on my previous venv that it worked without issues on a non-rooted tablet

I don’t think you can install docker just anywhere, and for sure you can’t without root access. I can find this on the topic: Is it possible to install Docker using Termux? - Android Enthusiasts Stack Exchange

Without docker, well, it will require a whole bunch of operations to deal with dependencies, which is what this entire topic is about, and it’s not recommended for beginners. That said, if your Termux is disposable, feel free to follow the instructions from Home Assistant Core on Android Tablet - #217 by romanovj and see where it takes you.

you don’t need root for it