Home Assistant on OpenWrt device

Hi,
I am working to integrate the home assistant on a OpwnWrt device,
Currently I could run the home assistant inside Venv on my device,
I have issue with the discovery similar to the issue here
I have no gcc on the platform but I did cross compiled netifaces and netdisco from here
I set include-system-site-packages = true, and if I run Python3 I can import the netifaces/netdisco and use them

But running Hass try to install the netdisco with pip and does not use the installed one

Any suggestions, how can I force hass to use the already installed libraries?

Regards,
Boaz

1 Like

solved:
copied manually the netifaces.cpython-36.so to
homeassistant/lib/python3.6/site-packages/
Also installed the netifaces on Ubuntu and got the netifaces-0.10.4.egg-info directory from there.
Then:
pip install netifaces==0.10.4 returns:
Requirement already satisfied: netifaces==0.10.4 in ./homeassistant/lib/python3.6/site-packages

That is amazing!. I hope you’ll succeed. I’m very interesting in this and I’ll follow you.

Could you give more detail about the installation on Openwrt ?

I am currently stuck at :

Error: Command ‘[’/root/homeassisant/bin/python3’, ‘-Im’, ‘ensurepip’, ‘–upgrade’, ‘–default-pip’]’ returned non-zero exit status 1.

/root/homeassisant/bin/python3 -m ensurepip --upgrade --default-pip
/root/homeassisant/bin/python3: No module named ensurepip

python3 --version
Python 3.6.0

Did you use custom packages ? Are you using a special platform ?

I managed to get the python virtual environment going with

pip3 -v install virtualenv
virtualenv -p python3 .
. bin/activate

As mentioned above some installation fails : netdisco and warrant . The dependent component can be removed from the configuration to avoid delay in startup time.

Hi,
Netdisco can be cross compiled to the platform you are using , then discovery will work,
I could run the home assistant on my platform ,
For any non native python langauge I had to cross compile it and then copy the compiled version into the virtual enviroment folder.

Did you build your own OpenWRT image to install HA and if so, wich components did you select before making?

Hi,

Yes I build my own version with python, and then run HA over it.
I added python from packages/lang/python/ and then I needed to update some libraries like bzip2 and xz before compiling
After that in the menuconfig you should see the python package,

1 Like

Thanks for your reply. I tired it myself today but I got stuck when pip tries to install bcyrpt.
So I’m not quite sure how this works.

I also tried it with DD-WRT wich also uses Opkg. There I can’t even create the virutal env:
" Running virtualenv with interpreter /opt/bin/python3. Please use the system python to run this script"

It seems that Bcyrpt is not a pure python package, so you will need to cross compile it and then manually copy the binary to the venv folder. You can check that pip install is showing that this is already installed.

you can check this topic, managed to install it on my router

I’m now running HA on my Linksys WRT-1200AC with Open-WRT via a Debian LXC container and virtualenv. Works perfectly. :slight_smile:

Can you share the guide how to install LXC and create the debian image?
thanks

Well first of all you have to build an OpenWRT image for your selected hardware.
When building it you have to add every component needed for LXC.

When installed on your device you can just create a container via the terminal with:

lxc-create -n HomeAssistant -t download

(it will bring up a list with every distribution to select from).
When the container is created you can start it via the gui and connect to it with

lxc-console -n HomeAssistant

At this point you are at the standard Debian bash an proceed as usual.

If you want to know exactly with component you have to choose when building your firmware image I can share my config.

can you share config? I find on internet but, not enough info :frowning: . Where i can find in make menuconfig?

Hi @Mike_i386,

Can you please share the config for building LXC ?
Which openWRT version did you use ?

I found those 2 guides :


http://www.gnuton.org/blog/2016/02/lxc-on-openwrt/
But they are seems to be not updated,

Thanks

please share config, i have router x86 with Celeron cpu, Ram 4GB

i have error ERROR: Missing recommended tool: gpg

Hii, were you able to make home automation system with it?
please revert back, I am trying to build one.
Thanks