OrangePi One Home Assistant

Comments Off on OrangePi One Home Assistant

This is my list of things I threw at the wall trying to make it work – and could obviously be rationalized into only the things you actually need to do to make it install. But since I’ve got it to “running” (with a lot of help), then I’m not going to go back and break it for the sake of working out which bits I didn’t need.

While this does ‘work’, in the sense of it runs, it’s unusably slow imho, so probably only useful as a proof of concept.

This based on the OrangePi Debian Buster image, which is more functional than the automated build from armbian (which I did try, but which failed spectacularly).

Important note: on first boot my system will not detect USB WiFi devices and won’t allow you to enable networking using the onboard system even if they’re compatible with Debian. Letting it complete the first boot and rebooting it afterwards worked for me. The filesystem resize also takes approximately my entire lifetime if you’ve used a big SD card.

1. Install the newer python (from https://tecadmin.net/how-to-install-python-3-11-on-debian/) – and install dependencies for both home assistant and for building python, oh, and some extra dependencies that seem to be missing from the HA install but that it rudely asked for during installation for me.

sudo apt-get update

sudo apt-get upgrade -y

sudo apt-get install -y python3 python3-dev python3-venv python3-pip bluez libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libopenjp2-7 libtiff5 libturbojpeg0-dev tzdata ffmpeg liblapack3 liblapack-dev libatlas-base-dev pkg-config wget build-essential libncursesw5-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev libncurses5-dev zlib1g libreadline-dev libsqlite3-dev make gcc python3-setuptools python-pip

wget https://www.python.org/ftp/python/3.11.3/Python-3.11.3.tgz

tar xzf Python-3.11.3.tgz

cd Python-3.11.3

./configure --enable-optimizations (it kept failing with enable optimizations)

sudo make altinstall

2. Based on instructions at: https://www.home-assistant.io/installation/linux, get the home assistant user created…

sudo useradd -rm homeassistant

sudo mkdir /srv/homeassistant

sudo chown homeassistant:homeassistant /srv/homeassistant

3. Remove the old version of rust:

sudo apt remove rustc

I also, at some point, installed cryptography and upgraded pyOpenSSL. No idea if this helped or not:

sudo python3.11 -m pip install wheel

sudo pip3.11 install --upgrade pip

sudo pip install --upgrade setuptools

4. Switch to the home assistant user.

sudo -u homeassistant -H -s

cd /srv/homeassistant

5. Install a new version of rust that meets requirements for home assistant (https://cryptography.io/en/latest/installation/#rust)

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

source $HOME/.cargo/env

export PATH=$PATH:~/.cargo/bin

6. In attempting to fix a later problem, I went back and switched back to my main user and repeated the rust installation. I strongly suspect it isn’t required.

exit

curl --proto '=https' --tlsv1.2 -sSf

https://sh.rustup.rs | sh

source $HOME/.cargo/env

export PATH=$PATH:~/.cargo/bin

7. Then I restarted the shell (logged out and back in).

8. Next I increased the size of the swap file to give hass more room to build. This makes an 8 Gig swap file in 500Meg chunks to avoid exhausting the memory of the OrangePi One (this takes a long time).

sudo swapoff -a

sudo dd if=/dev/zero of=/swapfile bs=500M count=16

sudo mkswap /swapfile

sudo swapon /swapfile

9. Then for the OrangePi user I installed cryptography and updated pyOpenSSL. I don’t think this is actually necessary, but I did it in the process, and this is was now largely me throwing random solutions desperately at the wall.

pip install cryptography

pip3 install pyOpenSSL --upgrade

10. Then changed back to the home assistant user and repeated those steps, and upgraded SQLite (which I discovered that Hass sulks about when it starts). Because this is the only thing on this system, I obnoxiously overwrite the original SQlite with the new one.

sudo -u homeassistant -H -s

cd /srv/homeassistant

pip install cryptography

pip3 install pyOpenSSL --upgrade

wget https://sqlite.org/2023/sqlite-autoconf-3420000.tar.gz
tar -xvf sqlite-autoconf-3420000.tar.gz
cd sqlite-autoconf-3420000
./configure
make
sudo make install

sudo cp /usr/local/lib/sql /usr/lib/arm-linux-gnueabihf/
sudo chmod a+x /usr/lib/arm-linux-gnueabihf/sql

11. And then on with more prep for installation of home assistant.

Not sure these helped, but I did them in the process – pretty sure they’re unnecessary and don’t work with current versions of home assistant builds, but they were suggested fixes:
export CRYPTOGRAPHY_DONT_BUILD_RUST=1
export CARGO_NET_GIT_FETCH_WITH_CLI=true

12. Use the newer version of python to install Home assistant (https://community.home-assistant.io/t/installing-home-assistant-core-in-a-python-venv-when-your-distros-python-version-is-obsolete/217048)… But I did that using the current home assistant version. This got me to building:

python3.11 -m venv .

source bin/activate

python3.11 -m pip install wheel

13. Then I made a new place for the compilation to go, because it turns out /tmp is too small:

export TMPDIR=~/piptmp

mkdir -p $TMPDIR

pip3 install --cache-dir=~/piptmp homeassistant==2023.6.1

In theory, this works, allowing you to start home assistant using

hass

Which should complete the installation – this is a slow process because it downloads and installs more things… In all honesty, I gave up after a few hours sitting at the loading screen. But in *theory* it should work.

KateWE

Kate's a human mostly built out of spite and overcoming transphobia-racism-and-other-bullshit. Although increasingly right-wing bigots would say otherwise. So she's either a human or a lizard in disguise sent to destroy all of humanity. Either way, it's all good.