Home Assistant Core on Android Tablet

Hello,
i just created my account to be able to reply to this.
I highly recommend looking into the app Linux Deploy
I started with the suggested approach here but I struggled a lot with fixing all the compilation errors and it was very slow on my Samsung Galaxy S5. Also I forogt the wake lock and all the time my mobile CPU went to sleep. But in the end it was running. But other issues with the bluetooth and so on made me crazy so I started this evening with Linux Deploy and the Homeassistant Server is already running.
Long story short : Linux Deploy is worth a try.

Iā€™m trying to install Home Assistant on a Samsung S2 tablet running LineageOs.
Iā€™m following the instructions from Home Assistant Core on Android Tablet - #64 by deividAlfa excepted for Python version where I have followed the instructions from Home Assistant Core on Android Tablet - #96 by Gnoupi to run it on the latest version (I have 3.11). Iā€™m getting some errors during ā€œpip install wheel homeassistantā€ (see below). Would you know what could be wrong? The log is long so I have only copied the errors below.
Thank you


/////////////
creating build/temp.linux-armv7l-cpython-311/aiohttp 
arm-linux-androideabi-clang -mfloat-abi=softfp -mfpu=vfpv3-d16 -DNDEBUG -g -fwrapv -O3 -Wall -march=armv7-a -mfpu=neon -mfloat-abi=softfp -mthumb -fstack-protector-strong -O3 -march=armv7-a -mfpu=neon -mfloat-abi=softfp -mthumb -fstack-protector-strong -O3 -fPIC -I/data/data/com.termux/files/home/hass/include -I/data/data/com.termux/files/usr/include/python3.11 -c aiohttp/_websocket.c -o build/temp.linux-armv7l-cpython-311/aiohttp/_websocket.o
aiohttp/_websocket.c:198:12: fatal error: 'longintrepr.h' file not found       #include "longintrepr.h"
 ^~~~~~~~~~~~~~~              1 error generated. 
error: command '/data/data/com.termux/files/usr/bin/arm-linux-androideabi-clang' failed with exit code 1                                                                                                                [end of output]                                                                                                                                                                                                     note: This error originates from a subprocess, and is likely not a problem with pip.                        
ERROR: Failed building wheel for aiohttp     

/////////////
Compiling arrayvec v0.7.2                                                                               
error: could not compile `orjson` due to 2 previous errors  
šŸ’„ maturin failed 
Caused by: Failed to build a native library through cargo    
    
/////////////
  ERROR: Failed building wheel for cryptography    

/////////////
  ERROR: Failed building wheel for orjson     
             
/////////////
Failed to build aiohttp cryptography orjson
ERROR: Could not build wheels for aiohttp, cryptography, orjson, which is required to install pyproject.toml-based projects

For aiohttp, would be good to check which version is required. Looks like there are some issues with python 3.11 (note that I still have 3.10) which should be fixed, though only recently: https://github.com/aio-libs/aiohttp/issues/6600 So we might just have a requirement which is not up to date in HA.

Or you could try downgrading python to 3.10 for the time being, I suppose.

For the rest, itā€™s hard to say as the errors are missing the context and actual causes. For cryptography and orjson, there are several messages earlier about potential solutions. I havenā€™t tried them yet as Iā€™m still running a 2022.8, so I canā€™t tell much more about them.

Thanks for your help. How can I downgrade to 3.10?

This message had decent steps for that, though I cannot find 3.10 in termux-pod, so the file will have to come from somewhere else (like an old version of termux).

After, if youā€™re anyway installing your own OS, you might want to follow the advice from this message Home Assistant Core on Android Tablet - #124 by fran6120 and just make it a docker deployment, which will save you from the hassle of the dependency hell. (not an option for me as Iā€™m using a few android apps on my tablet which I cannot replace)

I had seen the same.
I have also tried to move back to 3.9.7 but Iā€™m getting an SSL error.

I donā€™t want to replace LineageOs by another OS. My kids are using the tablet so I want to keep it an Android tablet.
Is this Docker solution possible with LineageOs?

I have tried to build Python 3.10.4 from source but without success :sleepy:

On termux you can install qemu, run an Alpine Linux image and install docker on it.

There are a few guides on web.
https://www.motoots.com/2021/03/running-docker-using-qemu-on-android.html
https://gist.github.com/oofnikj/e79aef095cd08756f7f26ed244355d62

I tried it on my OnePlus 5 running stock Android 10 and it works, but it takes a long time to boot up and feels slow (both host and guest) which is normal for a different architecture virtualized OS.


Welcome to Termux!

Community forum: https://termux.com/community
Gitter chat:     https://gitter.im/termux/termux
IRC channel:     #termux on libera.chat

Working with packages:

 * Search packages:   pkg search <query>
 * Install a package: pkg install <package>
 * Upgrade packages:  pkg upgrade

Subscribing to additional repositories:

 * Root:     pkg install root-repo
 * X11:      pkg install x11-repo

Report issues at https://termux.com/issues

~ $ cd alpine
qemu-system-x86_64 -machine q35 -m 2048 -smp cpus=4 -cpu qemu64 \
  -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-code.fd \
  -netdev user,id=n1,hostfwd=tcp::8123-:8123,hostfwd=tcp::9000-:9000,hostfwd=tcp::6052-:6052,hostfwd=tcp::49154-:49154,hostfwd=tcp::61208-:61208,hostfwd=tcp::3218-:3218 \
  -device virtio-net,netdev=n1 \
  -nographic alpine_2.qcow2
BdsDxe: failed to load Boot0001 "UEFI QEMU DVD-ROM QM00005 " from PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x2,0xFFFF,0x0): Not Found
BdsDxe: loading Boot0002 "UEFI QEMU HARDDISK QM00001 " from PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x0,0xFFFF,0x0)
BdsDxe: starting Boot0002 "UEFI QEMU HARDDISK QM00001 " from PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x0,0xFFFF,0x0)
Welcome to GRUB!


Welcome to Alpine Linux 3.16
Kernel 5.15.78-0-virt on an x86_64 (/dev/ttyS0)

alpineop5 login: root
Password:
Welcome to Alpine!

The Alpine Wiki contains a large amount of how-to guides and general
information about administrating Alpine systems.
See <http://wiki.alpinelinux.org/>.

You can setup the system with the command: setup-alpine

You may change this message by editing /etc/motd.

alpineop5:~# docker ps
CONTAINER ID   IMAGE                                          COMMAND                  CREATED          STATUS                             PORTS                                                           NAMES
b302dadea6a2   ghcr.io/home-assistant/home-assistant:latest   "/init"                  44 minutes ago   Up 2 minutes                                                                                       homeassistant
e59c38ef7d00   causticlab/hass-configurator-docker:latest     "/app/run.sh"            51 minutes ago   Up 13 seconds                      0.0.0.0:3218->3218/tcp, :::3218->3218/tcp                       configurador-hass-configurator-1
a37544f8da52   esphome/esphome                                "/entrypoint.sh dashā€¦"   5 hours ago      Up 2 minutes                                                                                       esphome
b7ea2ae49547   filebrowser/filebrowser:latest                 "/filebrowser --noauā€¦"   5 hours ago      Up 13 seconds (health: starting)   0.0.0.0:49154->80/tcp, :::49154->80/tcp                         archivos-filebrowser-1
645d8e7d288e   portainer/portainer-ce:latest                  "/portainer"             5 hours ago      Up 58 seconds                      8000/tcp, 9443/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp   portainer
alpineop5:~#

Thank you for your message. Iā€™m not convinced by this solutionā€¦

What didnā€™t work? Were you able to compile Python and set it up correctly?

During make -j 8 Iā€™m getting this error:

if (!_Py_InIntegralTypeRange(_PyTime_t, d)) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./Include/pymath.h:228:82: note: expanded from macro ā€˜_Py_InIntegralTypeRangeā€™ #define _Py_InIntegralTypeRange(type, v) (_Py_IntegralTypeMin(type) <= v && v <= _Py_IntegralTypeMax(type)) ~~ ^~~~~~~~~~~~~~~~~~~~~~~~~ ./Include/pymath.h:221:124: note: expanded from macro ā€˜_Py_IntegralTypeMaxā€™ #define _Py_IntegralTypeMax(type) ((_Py_IntegralTypeSigned(type)) ? (((((type)1 << (sizeof(type)*CHAR_BIT - 2)) - 1) << 1) + 1) : ~(type)0) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ Python/bootstrap_hash.c:141:17: error: call to undeclared function ā€˜getrandomā€™; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] n = getrandom(dest, n, flags); ^ Python/bootstrap_hash.c:145:17: error: call to undeclared function ā€˜getrandomā€™; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] n = getrandom(dest, n, flags); ^ 2 errors generated. make[3]: *** [Makefile:1855: Python/bootstrap_hash.o] Error 1 make[3]: *** Waiting for unfinished jobsā€¦

I have 3 possibilities. None of the following versions of python is working for me but i would like to concentrate my efforts on one of them. Iā€™m wondering which one.
Version 3.9.7: I had SSL error.
Version 3.10.4 build from source : I had an error in ā€˜getrandomā€™
Version 3.11 I had an error due to longintrep.h

Iā€™m tempted to go with 3.11ā€¦

I have chosen to try again the installation with python 3.11. So I had again the error due to ā€œlongintrep.hā€.
I have found an interesting solution here:

I have created the file requirements.txt with:
pip3 freeze > requirements.txt

I have then edited the versions indicated in the requirements.txt file (aiohttp, yarl, frozenlist) and then used:
pip install -r requirements.txt

Finally I used:

pip install wheel -r requirements.txt
pip install homeassistant -r requirements.txt

I donā€™t have anymore the error due to ā€œlongintrep.hā€ but I have stopped the installation because I have a version conflict.
I have described it here: Dependency on AIOHTTP

Here is the content of my requirements.txt file:

(hass) ~ $ cat requirements.txt                                                                             
aiohttp==3.8.2                                                                                              
aiosignal==1.3.1                                                                                          
async-timeout==4.0.2                                                                                        
attrs==21.2.0
certifi==2022.9.24                                                                                 
charset-normalizer==2.1.1                                                                                   
docopt==0.6.2
frozenlist==1.3.1                                                                                           
homeassistant==2022.11.4                                                                                    
idna==3.4                                                                                                   
multidict==5.2.0
numpy==1.23.4                                                                                               
pipreqs==0.4.11
requests==2.28.1
tzdata==2022.6
urllib3==1.26.13                                                                                            
wheel==0.38.4                                                                                               
yarg==0.1.9                                                                                                 
yarl==1.8.1

Hi! Iā€™ve just try for the first time to do this and i have no basic on programming or python & Co. i use a old nexus 7 (2012) tablet for this and i have some issue with Homeassistant. I try all day to install this 2 components make me mad. all other thing is alredy installed ( and also here i have some hard time to resolve the issue)

i read a lot of threads but i canā€™t find the way to go.
i already apologized if there is some errors in my sentences but is not my first language.

Thanks

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