How to install homeassistant in openwrt?

Here is my openwrt version.

root@OpenWrt:~# uname -a
Linux OpenWrt 4.14.221 #0 SMP Mon Feb 15 15:22:37 2021 x86_64 GNU/Linux

The python version:

root@OpenWrt:~# python3
Python 3.7.10 (default, May 28 2021, 13:26:31) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

Let 's install homeassistant.

root@OpenWrt:~# python3 -m pip install homeassistant
Collecting homeassistant
  Using cached homeassistant-2021.1.5-py3-none-any.whl (10.2 MB)
Collecting voluptuous==0.12.1
  Downloading voluptuous-0.12.1-py3-none-any.whl (29 kB)
Collecting pyyaml==5.3.1
  Using cached PyYAML-5.3.1.tar.gz (269 kB)
Collecting pip<20.3,>=8.0.3
  Using cached pip-20.2.4-py2.py3-none-any.whl (1.5 MB)
Collecting cryptography==3.2
  Using cached cryptography-3.2.tar.gz (540 kB)
  Installing build dependencies ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 /tmp/pip-standalone-pip-l9ejx5j5/__env_pip__.zip/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-9u9mzgse/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.8,!=1.11.3; platform_python_implementation != '"'"'PyPy'"'"''
       cwd: None
  Complete output (110 lines):
  Collecting setuptools>=40.6.0
    Using cached setuptools-57.0.0-py3-none-any.whl (821 kB)
  Collecting wheel
    Using cached wheel-0.36.2-py2.py3-none-any.whl (35 kB)
  Collecting cffi!=1.11.3,>=1.8
    Using cached cffi-1.14.5.tar.gz (475 kB)
  Collecting pycparser
    Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB)
  Building wheels for collected packages: cffi
    Building wheel for cffi (setup.py): started
    Building wheel for cffi (setup.py): finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-mzqd7ikc/cffi_3e5974005d6f4e32a42ba117208ca900/setup.py'"'"'; __file__='"'"'/tmp/pip-install-mzqd7ikc/cffi_3e5974005d6f4e32a42ba117208ca900/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-8opitqj2
         cwd: /tmp/pip-install-mzqd7ikc/cffi_3e5974005d6f4e32a42ba117208ca900/
    Complete output (41 lines):
    running bdist_wheel
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/cffi
    copying cffi/verifier.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/vengine_gen.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/recompiler.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/pkgconfig.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/model.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/lock.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/ffiplatform.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/error.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/cparser.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/commontypes.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/api.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/__init__.py -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/_cffi_include.h -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/parse_c_type.h -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/_embedding.h -> build/lib.linux-x86_64-3.7/cffi
    copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-3.7/cffi
    warning: build_py: byte-compiling is disabled, skipping.
  
    running build_ext
    building '_cffi_backend' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/c
    gcc -Wno-unused-result -Wsign-compare -DNDEBUG -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -iremap/builder/shared-workdir/build/sdk/build_dir/target-x86_64_musl/Python-3.7.10:Python-3.7.10 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -iremap/builder/shared-workdir/build/sdk/build_dir/target-x86_64_musl/Python-3.7.10:Python-3.7.10 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -DNDEBUG -fno-inline -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -iremap/builder/shared-workdir/build/sdk/build_dir/target-x86_64_musl/Python-3.7.10:Python-3.7.10 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -DNDEBUG -fno-inline -I/builder/shared-workdir/build/sdk/staging_dir/target-x86_64_musl/usr/include -I/builder/shared-workdir/build/sdk/staging_dir/target-x86_64_musl/include -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-x86_64_gcc-7.5.0_musl/usr/include -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-x86_64_gcc-7.5.0_musl/include/fortify -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-x86_64_gcc-7.5.0_musl/include -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python3.7 -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.7/c/_cffi_backend.o
    c/_cffi_backend.c: In function 'fb_prepare_cif':
    c/_cffi_backend.c:5887:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (status == -1) {
                    ^~
    gcc -shared -L/builder/shared-workdir/build/sdk/staging_dir/target-x86_64_musl/usr/lib -L/builder/shared-workdir/build/sdk/staging_dir/target-x86_64_musl/lib -L/builder/shared-workdir/build/sdk/staging_dir/toolchain-x86_64_gcc-7.5.0_musl/usr/lib -L/builder/shared-workdir/build/sdk/staging_dir/toolchain-x86_64_gcc-7.5.0_musl/lib -znow -zrelro -L/builder/shared-workdir/build/sdk/build_dir/target-x86_64_musl/Python-3.7.10 -L/builder/shared-workdir/build/sdk/staging_dir/target-x86_64_musl/usr/lib -L/builder/shared-workdir/build/sdk/staging_dir/target-x86_64_musl/lib -L/builder/shared-workdir/build/sdk/staging_dir/toolchain-x86_64_gcc-7.5.0_musl/usr/lib -L/builder/shared-workdir/build/sdk/staging_dir/toolchain-x86_64_gcc-7.5.0_musl/lib -znow -zrelro -L/builder/shared-workdir/build/sdk/build_dir/target-x86_64_musl/Python-3.7.10 build/temp.linux-x86_64-3.7/c/_cffi_backend.o -L/usr/lib -lffi -lpython3.7 -o build/lib.linux-x86_64-3.7/_cffi_backend.cpython-37.so
    /usr/bin/ld: cannot find -lffi
    collect2: error: ld returned 1 exit status
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
    ERROR: Failed building wheel for cffi
    Running setup.py clean for cffi
  Failed to build cffi
  Installing collected packages: pycparser, wheel, setuptools, cffi
      Running setup.py install for cffi: started
      Running setup.py install for cffi: finished with status 'error'
      ERROR: Command errored out with exit status 1:
       command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-mzqd7ikc/cffi_3e5974005d6f4e32a42ba117208ca900/setup.py'"'"'; __file__='"'"'/tmp/pip-install-mzqd7ikc/cffi_3e5974005d6f4e32a42ba117208ca900/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-mp68j1b4/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-9u9mzgse/overlay --compile --install-headers /tmp/pip-build-env-9u9mzgse/overlay/include/python3.7/cffi
           cwd: /tmp/pip-install-mzqd7ikc/cffi_3e5974005d6f4e32a42ba117208ca900/
      Complete output (41 lines):
      running install
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.7
      creating build/lib.linux-x86_64-3.7/cffi
      copying cffi/verifier.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/vengine_gen.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/recompiler.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/pkgconfig.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/model.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/lock.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/ffiplatform.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/error.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/cparser.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/commontypes.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/api.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/__init__.py -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/_cffi_include.h -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/parse_c_type.h -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/_embedding.h -> build/lib.linux-x86_64-3.7/cffi
      copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-3.7/cffi
      warning: build_py: byte-compiling is disabled, skipping.
  
      running build_ext
      building '_cffi_backend' extension
      creating build/temp.linux-x86_64-3.7
      creating build/temp.linux-x86_64-3.7/c
      gcc -Wno-unused-result -Wsign-compare -DNDEBUG -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -iremap/builder/shared-workdir/build/sdk/build_dir/target-x86_64_musl/Python-3.7.10:Python-3.7.10 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -iremap/builder/shared-workdir/build/sdk/build_dir/target-x86_64_musl/Python-3.7.10:Python-3.7.10 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -DNDEBUG -fno-inline -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -iremap/builder/shared-workdir/build/sdk/build_dir/target-x86_64_musl/Python-3.7.10:Python-3.7.10 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -DNDEBUG -fno-inline -I/builder/shared-workdir/build/sdk/staging_dir/target-x86_64_musl/usr/include -I/builder/shared-workdir/build/sdk/staging_dir/target-x86_64_musl/include -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-x86_64_gcc-7.5.0_musl/usr/include -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-x86_64_gcc-7.5.0_musl/include/fortify -I/builder/shared-workdir/build/sdk/staging_dir/toolchain-x86_64_gcc-7.5.0_musl/include -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python3.7 -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.7/c/_cffi_backend.o
      c/_cffi_backend.c: In function 'fb_prepare_cif':
      c/_cffi_backend.c:5887:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
           if (status == -1) {
                      ^~
      gcc -shared -L/builder/shared-workdir/build/sdk/staging_dir/target-x86_64_musl/usr/lib -L/builder/shared-workdir/build/sdk/staging_dir/target-x86_64_musl/lib -L/builder/shared-workdir/build/sdk/staging_dir/toolchain-x86_64_gcc-7.5.0_musl/usr/lib -L/builder/shared-workdir/build/sdk/staging_dir/toolchain-x86_64_gcc-7.5.0_musl/lib -znow -zrelro -L/builder/shared-workdir/build/sdk/build_dir/target-x86_64_musl/Python-3.7.10 -L/builder/shared-workdir/build/sdk/staging_dir/target-x86_64_musl/usr/lib -L/builder/shared-workdir/build/sdk/staging_dir/target-x86_64_musl/lib -L/builder/shared-workdir/build/sdk/staging_dir/toolchain-x86_64_gcc-7.5.0_musl/usr/lib -L/builder/shared-workdir/build/sdk/staging_dir/toolchain-x86_64_gcc-7.5.0_musl/lib -znow -zrelro -L/builder/shared-workdir/build/sdk/build_dir/target-x86_64_musl/Python-3.7.10 build/temp.linux-x86_64-3.7/c/_cffi_backend.o -L/usr/lib -lffi -lpython3.7 -o build/lib.linux-x86_64-3.7/_cffi_backend.cpython-37.so
      /usr/bin/ld: cannot find -lffi
      collect2: error: ld returned 1 exit status
      error: command 'gcc' failed with exit status 1
      ----------------------------------------
  ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-mzqd7ikc/cffi_3e5974005d6f4e32a42ba117208ca900/setup.py'"'"'; __file__='"'"'/tmp/pip-install-mzqd7ikc/cffi_3e5974005d6f4e32a42ba117208ca900/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-mp68j1b4/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-9u9mzgse/overlay --compile --install-headers /tmp/pip-build-env-9u9mzgse/overlay/include/python3.7/cffi Check the logs for full command output.
  ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/1c/15/aceb9a2535c9fa805316b49e42fde0a83d1a0492b4e3608a4a5dc9b04b46/cryptography-3.2.tar.gz#sha256=e4789b84f8dedf190148441f7c5bfe7244782d9cbb194a36e17b91e7d3e1cca9 (from https://pypi.org/simple/cryptography/) (requires-python:>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*). Command errored out with exit status 1: /usr/bin/python3 /tmp/pip-standalone-pip-l9ejx5j5/__env_pip__.zip/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-9u9mzgse/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.8,!=1.11.3; platform_python_implementation != '"'"'PyPy'"'"'' Check the logs for full command output.

How to fix it?

Home Assistant requires Python 3.8 Start there.

The latest version is python3.7 on openwrt 19.07.

root@OpenWrt:~# cat /etc/banner
  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 19.07.7, r11306-c4a6851c72
 -----------------------------------------------------
root@OpenWrt:~# uname -a
Linux OpenWrt 4.14.221 #0 SMP Mon Feb 15 15:22:37 2021 x86_64 GNU/Linux
root@OpenWrt:~# python3
Python 3.7.10 (default, May 28 2021, 13:26:31) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

How to compile python3.8 on my openwrt then?

What hardware is that on?

A Pi3 is the minimum recommended spec for HA. Anything running OpenWRT is likely way under that spec, and the experience is going to suck.

Well, you’d want 3.9, since 3.8 will be deprecated in December (3.9 will be deprecated in December 2022).


Buy a Pi

1 Like

Ask on an appropriate forum??

This forum supports nether Python nor openWRT. As stated by others you may have other resource constraints.

1 Like

Actually, I have the same thought about running Openwrt (router) & HA together, in my case on an x86 box: a
CYBEROAM CR-35wi UTM Appliance. This has plenty of resources, & is relatively cheap on used market.
This would save one computer load (abt 40W) if it can be achieved.
Currently I use an Intel NUC. I have HA with Adguard & the EV charger OCPP running on the NUC.