Home Assistant Core on Android Tablet

Hi all, after installing HA it is not possible to start it… I have python 3.11. This is my error massage.
(hass) ~ $ hass -v Traceback (most recent call last): File "/data/data/com.termux/files/home/hass/bin/hass", line 5, in <module> from homeassistant.__main__ import main File "/data/data/com.termux/files/home/hass/lib/python3.11/site-packages/homeassistant/__main__.py", line 19 from homeassistant.util.async import run_callback_threadsafe ^^^^^ SyntaxError: invalid syntax (hass) ~ $ hass -v Traceback (most recent call last): File "/data/data/com.termux/files/home/hass/bin/hass", line 5, in <module> from homeassistant.__main__ import main File "/data/data/com.termux/files/home/hass/lib/python3.11/site-packages/homeassistant/__main__.py", line 19 from homeassistant.util.async import run_callback_threadsafe ^^^^^ SyntaxError: invalid syntax

Hope you can help me.

Hi, how you create the requirements. txt?

it’s just a block note file reneamed and put in the folders of termux or is a sequence of sentences in termux itself?

Hi Fabio,
The answer is in my post 2 messages above your message:

requirements.txt is created with:
pip3 freeze > requirements.txt

for those having issues with installing orjson and maturin, this fix works :

$ pkg install binutils

this passes the error:

  • error occurred: Failed to find tool. Is arm-linux-androideabi-ar installed?

enabling me to install maturin for my Galaxy S5

thanks, now i figure out how to do that. But whith this you have resolve or the problem whith the conflict is a problem?

If you had a working version of Home Assistant on Python 3.10, but it all broke down in Python 3.11, then here are the steps to go back to Python 3.10:

:technologist:How to Downgrade Python from 3.11 to 3.10 in Termux

  1. If you already installed python version 3.11 first uninstall it

pkg uninstall python

  1. Now Give all the command in Termux
apt update

apt upgrade

pkg install binutils

curl https://ai-speaker.com/apt/dists/dom-dev/beta/binary-arm/python_3.10.4_arm.deb --output python.deb

apt install ./python.deb

You will get an error, ignore it. Just give next commands

ls

mkdir build

cd build

ar x ../python.deb

tar Jvxf data.tar.xz

cp -R data/data/pl.sviete.dom/files/usr/* $PREFIX/

cd ..

rm -rf data

echo "export LD_LIBRARY_PATH=$PREFIX/lib" > .bashrc

source .bashrc
  1. Check if python is installed or not

python

  1. Press ctrl-d to exit
  2. Install pip
curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py

python get-pip.py
  1. Check python version

python --version

:tada:Successfully Downgraded from Python3.11 to Python3.10 in Termux

1 Like

ahh nice, tried to to downgrade too but couldnt find old python installers for termux.

Nevertheless, I managed to get the @dev of HA 11/29/22 working with Python 3.11 in termux (Galaxy S5). Its accessible on http://192.168.x.x:8123

Steps:

I now downloaded the latest @dev version of HA, as the requirements.txt is updated for aiohttp 3.8.1 (which doesnt work for python 3.11) to 3.8.3. See Update aiohttp to 3.8.3 by frenck · Pull Request #78860 · home-assistant/core · GitHub

Local install with something like pip install -e folder homeassistant
after that, start hass started

during start, it hangs at installing PyTurboJPEG
(fixing ystemError: One of the required function to build numpy is not available (the list is [‘sin’, ‘cos’, ‘tan’, ‘sinh’, ‘cosh’, ‘tanh’, ‘fabs’, ‘floor’, ‘ceil’, ‘sqrt’, ‘log10’, ‘log’, ‘exp’, ‘asin’, ‘acos’, ‘atan’, ‘fmod’, ‘modf’, ‘frexp’, ‘ldexp’])

fix is running: MATHLIB=“m” pip3 install PyTurboJPEG==1.6.7

same for numpy: MATHLIB=“m” pip3 install numpy

BTW. The process of starting hass with more installs during its boot, takes quite some time.

few errors left like CRITICAL : Can’t open /proc/net/dev and Can’t open* /proc/net/route but these see no dealbreakers for running HA clients

1 Like

Hi thanks for the tips. I have downgraded phyton, and have try to install homeassistant but now i have a completely different error during the installation

try apt install libpython3.9-devapt install libpython3.10-dev

I have the same Issue and apt install libpython3.9-devapt install libpython3.10-dev dont work.

Hey guys, new here, sorry if my question was already answered, but i’m having problems trying to install HA on my old Galaxy Tab A 10.1 (2016).
Sorry for my dumb linux-related questions, but is my first time working with it.

When trying to install HA (using this tutorial), i get the following error on the orjson part (i believe it’s a rust compiler error, correct me if i’m wrong)

Log:

~ $ python -m venv hass
~ $ source hass/bin/activate
(hass) ~ $ pip install homeassistant
Collecting homeassistant
  Using cached homeassistant-2022.12.0-py3-none-any.whl (20.6 MB)
Collecting aiohttp==3.8.3
  Using cached aiohttp-3.8.3.tar.gz (7.3 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Collecting astral==2.2
  Using cached astral-2.2-py2.py3-none-any.whl (30 kB)
Collecting async-timeout==4.0.2
  Using cached async_timeout-4.0.2-py3-none-any.whl (5.8 kB)
Collecting attrs==21.2.0
  Using cached attrs-21.2.0-py2.py3-none-any.whl (53 kB)
Collecting atomicwrites-homeassistant==1.4.1
  Using cached atomicwrites_homeassistant-1.4.1-py2.py3-none-any.whl (7.1 kB)
Collecting awesomeversion==22.9.0
  Using cached awesomeversion-22.9.0-py3-none-any.whl (12 kB)
Collecting bcrypt==3.1.7
  Using cached bcrypt-3.1.7.tar.gz (42 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting certifi>=2021.5.30
  Using cached certifi-2022.12.7-py3-none-any.whl (155 kB)
Collecting ciso8601==2.2.0
  Using cached ciso8601-2.2.0.tar.gz (18 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting httpx==0.23.1
  Using cached httpx-0.23.1-py3-none-any.whl (84 kB)
Collecting home-assistant-bluetooth==1.8.1
  Using cached home_assistant_bluetooth-1.8.1.tar.gz (10 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting ifaddr==0.1.7
  Using cached ifaddr-0.1.7-py2.py3-none-any.whl (10 kB)
Collecting jinja2==3.1.2
  Using cached Jinja2-3.1.2-py3-none-any.whl (133 kB)
Collecting lru-dict==1.1.8
  Using cached lru-dict-1.1.8.tar.gz (10 kB)
  Preparing metadata (setup.py) ... done
Collecting PyJWT==2.5.0
  Using cached PyJWT-2.5.0-py3-none-any.whl (20 kB)
Collecting cryptography==38.0.3
  Using cached cryptography-38.0.3.tar.gz (599 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting orjson==3.8.1
  Using cached orjson-3.8.1.tar.gz (860 kB)
  Installing build dependencies ... error
  error: subprocess-exited-with-error

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [56 lines of output]
      Collecting maturin<0.14,>=0.13
        Using cached maturin-0.13.7.tar.gz (154 kB)
        Installing build dependencies: started
        Installing build dependencies: finished with status 'done'
        Getting requirements to build wheel: started
        Getting requirements to build wheel: finished with status 'done'
        Preparing metadata (pyproject.toml): started
        Preparing metadata (pyproject.toml): finished with status 'done'
      Building wheels for collected packages: maturin
        Building wheel for maturin (pyproject.toml): started
        Building wheel for maturin (pyproject.toml): finished with status 'error'
        error: subprocess-exited-with-error

        × Building wheel for maturin (pyproject.toml) did not run successfully.
        │ exit code: 1
        ╰─> [34 lines of output]
            running bdist_wheel
            running build
            running build_py
            creating build
            creating build/lib.linux-aarch64-cpython-311
            creating build/lib.linux-aarch64-cpython-311/maturin
            copying maturin/__init__.py -> build/lib.linux-aarch64-cpython-311/maturin
            copying maturin/import_hook.py -> build/lib.linux-aarch64-cpython-311/maturin
            copying maturin/__main__.py -> build/lib.linux-aarch64-cpython-311/maturin
            running egg_info
            creating maturin.egg-info
            writing maturin.egg-info/PKG-INFO
            writing dependency_links to maturin.egg-info/dependency_links.txt
            writing requirements to maturin.egg-info/requires.txt
            writing top-level names to maturin.egg-info/top_level.txt
            writing manifest file 'maturin.egg-info/SOURCES.txt'
            reading manifest file 'maturin.egg-info/SOURCES.txt'
            reading manifest template 'MANIFEST.in'
            writing manifest file 'maturin.egg-info/SOURCES.txt'
            running build_ext
            running build_rust
            error: rustup could not choose a version of rustc to run, because one wasn't specified explicitly, and no default is configured.
            help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain.
            error: can't find Rust compiler

            If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.

            To update pip, run:

                pip install --upgrade pip

            and then retry package installation.

            If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs) is the recommended way to download and update the Rust compiler toolchain.
            [end of output]

        note: This error originates from a subprocess, and is likely not a problem with pip.
        ERROR: Failed building wheel for maturin
      Failed to build maturin
      ERROR: Could not build wheels for maturin, which is required to install pyproject.toml-based projects
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
(hass) ~ $ 

Tried (no sucess)

What should i do?

try this

pkg upgrade

pkg install python nano make rust libcrypt libffi libjpeg-turbo binutils

python -m venv hass

source hass/bin/activate

pip install --upgrade pip

pip install wheel

pip install tzdata

pip install maturin

MATHLIB=m pip install numpy

MATHLIB=m pip install PyTurboJPEG==1.6.7

export RUSTFLAGS="-C lto=n"

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

export CRYPTOGRAPHY_DONT_BUILD_RUST=1

pip install homeassistant==2022.12.0

hass -v
3 Likes

Hey man, thanks for getting back to me.

I followed your steps and everything was going as per normal. However, upon installing maturin, i got a similar error (can’t find Rust compiler)

~ $ pkg upgrade
No mirror or mirror group selected. You might want to select one by running 'termux-change-repo'
Testing the available mirrors:
[*] (10) https://packages-cf.termux.dev/apt/termux-main: ok
[*] (1) https://mirrors.cbrx.io/apt/termux/termux-main: ok
[*] (1) https://linux.domainesia.com/applications/termux/termux-main: ok
[*] (1) https://mirror.bardia.tech/termux/termux-main: ok
[*] (1) https://mirror.nevacloud.com/applications/termux/termux-main: bad
[*] (1) https://mirror.albony.xyz/termux/termux-main: ok
[*] (1) https://packages.nscdn.top/termux-main: bad
[*] (1) https://mirrors.sdu.edu.cn/termux/termux-main: ok
[*] (1) https://mirrors.sau.edu.cn/termux/apt/termux-main: bad
[*] (1) https://mirrors.ustc.edu.cn/termux/apt/termux-main: ok
[*] (1) https://mirrors.cqupt.edu.cn/termux/apt/termux-main: ok
[*] (1) https://mirrors.nju.edu.cn/termux/apt/termux-main: ok
[*] (1) https://mirrors.pku.edu.cn/termux/termux-main/: bad
[*] (1) https://mirrors.njupt.edu.cn/termux/apt/termux-main: ok
[*] (1) https://mirrors.bfsu.edu.cn/termux/apt/termux-main: ok
[*] (1) https://mirrors.dgut.edu.cn/termux/apt/termux-main: bad
[*] (1) https://mirrors.hit.edu.cn/termux/apt/termux-main: ok
[*] (1) https://mirror.iscas.ac.cn/termux/apt/termux-main: ok
[*] (1) https://mirror.nyist.edu.cn/termux/apt/termux-main: ok
[*] (1) https://mirrors.scau.edu.cn/termux/apt/termux-main: ok
[*] (1) https://mirrors.aliyun.com/termux/termux-packages-24: bad
[*] (1) https://mirrors.sustech.edu.cn/termux/apt/termux-main: ok
[*] (1) https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main: ok
[*] (1) https://termux.3san.dev/termux/termux-main: ok
[*] (1) https://mirrors.sahilister.in/termux/termux-main: ok
[*] (1) https://termux.cdn.lumito.net/termux-main: ok
[*] (1) https://termux.librehat.com/apt/termux-main: ok
[*] (1) https://mirror.accum.se/mirror/termux.dev/termux-main: ok
[*] (1) https://mirror.termux.dev/termux-main: ok
[*] (1) https://termux.astra.in.ua/apt/termux-main: ok
[*] (4) https://grimler.se/termux/termux-main: ok
[*] (1) https://termux.mentality.rip/termux-main: ok
[*] (1) https://mirror.mwt.me/termux/main: ok
[*] (1) https://mirrors.utermux.dev/termux/termux-main: ok
[*] (1) https://plug-mirror.rcac.purdue.edu/termux/termux-main: ok
[*] (1) https://dl.kcubeterm.com/termux-main: ok
[*] (1) https://mirror.fcix.net/termux/termux-main: ok
[*] (1) https://mirror.vern.cc/termux/termux-main: ok
[*] (1) https://mirror.csclub.uwaterloo.ca/termux/termux-main: ok
[*] (1) https://mirror.mwt.me/termux/main: ok
[*] (4) https://packages.termux.dev/apt/termux-main: ok
[*] (1) https://mirror.surf/termux/termux-main/: ok
[*] (1) http://mirror.mephi.ru/termux/termux-main: ok
Picking mirror: (17) /data/data/com.termux/files/usr/etc/termux/mirrors/china/mirrors.nju.edu.cn
Get:1 https://mirrors.nju.edu.cn/termux/apt/termux-main stable InRelease [14.0 kB]
Get:2 https://mirrors.nju.edu.cn/termux/apt/termux-main stable/main aarch64 Packages [435 kB]
Fetched 449 kB in 2min 22s (3154 B/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
~ $ pkg install python nano make rust libcrypt libffi libjpeg-turbo binutils
No mirror or mirror group selected. You might want to select one by running 'termux-change-repo'
Checking availability of current mirror:
[*] https://mirrors.nju.edu.cn/termux/apt/termux-main: ok
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python is already the newest version (3.11.1).
nano is already the newest version (7.0).
make is already the newest version (4.4).
rust is already the newest version (1.65.0).
libcrypt is already the newest version (0.2-5).
libffi is already the newest version (3.4.4).
libffi set to manually installed.
libjpeg-turbo is already the newest version (2.1.4).
binutils is already the newest version (2.39-4).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
~ $ python -m venv hass
~ $ source hass/bin/activate
(hass) ~ $ pip install --upgrade pip
Requirement already satisfied: pip in ./hass/lib/python3.11/site-packages (22.3.1)
(hass) ~ $ pip install wheel
Requirement already satisfied: wheel in ./hass/lib/python3.11/site-packages (0.38.4)
(hass) ~ $ pip install tzdata
Collecting tzdata
  Downloading tzdata-2022.7-py2.py3-none-any.whl (340 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 340.1/340.1 kB 4.5 MB/s eta 0:00:00
Installing collected packages: tzdata
Successfully installed tzdata-2022.7
(hass) ~ $ pip install maturin
Collecting maturin
  Using cached maturin-0.14.5.tar.gz (170 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: maturin
  Building wheel for maturin (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for maturin (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [34 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-aarch64-cpython-311
      creating build/lib.linux-aarch64-cpython-311/maturin
      copying maturin/__init__.py -> build/lib.linux-aarch64-cpython-311/maturin
      copying maturin/import_hook.py -> build/lib.linux-aarch64-cpython-311/maturin
      copying maturin/__main__.py -> build/lib.linux-aarch64-cpython-311/maturin
      running egg_info
      creating maturin.egg-info
      writing maturin.egg-info/PKG-INFO
      writing dependency_links to maturin.egg-info/dependency_links.txt
      writing requirements to maturin.egg-info/requires.txt
      writing top-level names to maturin.egg-info/top_level.txt
      writing manifest file 'maturin.egg-info/SOURCES.txt'
      reading manifest file 'maturin.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      writing manifest file 'maturin.egg-info/SOURCES.txt'
      running build_ext
      running build_rust
      error: rustup could not choose a version of rustc to run, because one wasn't specified explicitly, and no default is configured.
      help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain.
      error: can't find Rust compiler

      If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.

      To update pip, run:

          pip install --upgrade pip

      and then retry package installation.

      If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs) is the recommended way to download and update the Rust compiler toolchain.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for maturin
Failed to build maturin
ERROR: Could not build wheels for maturin, which is required to install pyproject.toml-based projects
(hass) ~ $

Should i continue with the steps?

Thank you bro it worked

try to reinstall termux

also no problems with HA 2022.12.1 instead of 2022.12.0

Able to compile ginko kernel (xiomi note 8) with additional flags. Now I have HA core in docker containers in Termux.

script for checking kernel config

1 Like

Hi!

I managed to install all the necessary things ( in theory)

wen i try HASS - V this fail every time with this line

I’ve try to get root and i have already gave permission to the storage.

have any tips?

Thanks

I’ll refer you to my previous message Home Assistant Core on Android Tablet - #110 by Gnoupi

I don’t see a failure in your log. Well, there is a failure to access some core data that could be used to monitor the system, but I have that as well. Termux just does not allow access to those. It does not prevent HA from functioning, though.

So try to launch it again, give it time to install some sub-dependencies in the back, and monitor CPU activity on side if you have doubts that anything is happening with it.

I was successfully able to install home assistant 2022.12.2 on a Teclast P80X android tablet using these steps, thank you!

I needed two additional steps though.

  1. Cargo kept crashing with a SIGKILL on my tablet due to running out of memory during building (2GB ram). I needed to restrict the number of parallel tasks to 1 by calling:
export CARGO_BUILD_JOBS=1
  1. I forced aiohttp to >3.8.1 by the following two commands:
echo "aiohttp>=3.8.2" > constraints.txt
pip install -c constraints.txt homeassistant

Hi all. Thanks for this great guide. One topic seems to be missing: How to make automations work in time, which are prevented by sleeping of the home assistant server because of energy saving of your android device.
I didn’t find a solution, yet. Maybe one of you has a good idea?
Problem description: If I program an automation, which should be triggered at a certain time, it does not start at this specific time but at least 10 minutes later - sometimes hours later. (the phone time is set correctly, also the command “date” in termux outputs the correct time.) I have the impression that the automation is not running until I use my phone, unlock the screen and it wakes up. Then after several minutes the automation is triggered. The dashboard however, is responsive. I believe this could be related to energy saving mode of my phone. I tried to set in the LineageOS settings the termux app to “do not optimize battery”, but this didn’t make a difference. I’m using LineageOS 17.1 on an old Samsung Galaxy S5 neo.
What can I do?
Edit: I was studying the logs and found following warning entry which has been mentioned above. However, I don’t understand it. Is there a relation to the issue? Maybe it’s not related to the device beeing in energy saving mode. I also found plenty of other forum entries discussing the delay issue, however without solution.

2022-12-26 16:32:27.420 WARNING (SyncWorker_3) [pyroute2.netlink.rtnl.tcmsg.common] tcmsg: [Errno 13] Permission denied: '/proc/net/psched'
2022-12-26 16:32:27.477 WARNING (SyncWorker_3) [pyroute2.netlink.rtnl.tcmsg.common] the tc subsystem functionality is limited

Edit2:
I also created a date & time sensor entity for testing purposes by inserting following in the configuration.yaml:

sensor: 
  - platform: time_date
    display_options: 'date_time'

I placed it on my dashboard and learned that it also updates very irregularly and is always several minutes late:
date_time

I think this might be related to the automations not trigger in time.

Edit3: After reading and investigating a lot, I think there is a general issue running home assistant on android 10 and above with termux, because since android 10, the permission to access /proc/net/ is denied.
This is what I found additionally in my home-assistant.log

2022-12-26 20:47:10.402 CRITICAL (SyncWorker_3) [scapy.loading] Can't open /proc/net/dev !
2022-12-26 20:47:10.709 CRITICAL (SyncWorker_3) [scapy.loading] Can't open /proc/net/route !
2022-12-26 20:47:10.765 CRITICAL (SyncWorker_3) [scapy.loading] Can't open /proc/net/dev !
2022-12-26 20:47:13.463 WARNING (SyncWorker_2) [pyroute2.netlink.rtnl.tcmsg.common] tcmsg: [Errno 13] Permission denied: '/proc/net/psched'
2022-12-26 20:47:13.491 WARNING (SyncWorker_2) [pyroute2.netlink.rtnl.tcmsg.common] the tc subsystem functionality is limited

I don’t see a workaround on non rooted devices.
Edit4: I think I found a solution. All automations work now in time if you follow the steps discussed here:
link to reddit/r/termux
Thanks to u/agnostic-apollo, I found a working solution, I try to summarize here:

  • In LineageOS settings: activate android-debugging, root-debugging and adb over network
  • In termux: pkg install android-tools, and connect it with adb connect, verify with adb devices and test if you can access /proc/net/psched within adb shell
  • edit in file (which belongs to the home assistant’s venv !!!) “lib/python3.11/site-packages/pyroute2/netlink/rtnl/tcmsg/common.py”

replace

with open('/proc/net/psched', 'r') as psched:

[t2us, us2t, clock_res, wee] = [

int(i, 16) for i in psched.read().split()

]

with

psched=os.popen('adb shell cat /proc/net/psched').read().rstrip('\n')

[t2us, us2t, clock_res, wee] = [

int(i, 16) for i in psched.split()

]

  • finally, to prevent your phone from falling into deep sleep, it is necessary to run termux-wake-lock

With these steps home assistants automations should work in time, if you run it on an android phone within termux.

3 Likes