Supervised Home assistant on CoreELEC (We got a live one!)

What is Home Assistant Supervised?

Home Assistant is a full UI managed home automation ecosystem that runs Home Assistant Core, the Home Assistant Supervisor and add-ons. It comes pre-installed on Home Assistant OS, but can be installed on any Linux system. It leverages Docker, which is managed by the Home Assistant Supervisor plus the added benefit of dozens of add-ons (think app store) that work natively inside the Home Assistant environment.

  • Discussion thread

There are a few ways to install Home Assistant. The following has is an adaptation of installing on a debian os, which in turn is an adaptation of the nowdays not supported installer. However, installing homeassistant like this works, it runs and so forth. Alas, I have not been able to get any headway of usb access etc, but one step at the time.

There might be more users out there who wish to utilize their CoreELEC box a bit more and Supervised Home Assistans might be one.

I have adapted this dockerscript into this:

#!/usr/bin/env bash
set -e

function error { echo -e "[Error] $*"; exit 1; }
function warn  { echo -e "[Warning] $*"; }

ARCH=$(uname -m)
DOCKER_BINARY=/usr/bin/docker
DOCKER_REPO=homeassistant
DOCKER_SERVICE=docker.service
URL_VERSION="https://version.home-assistant.io/stable.json"
URL_HA="https://raw.githubusercontent.com/home-assistant/supervised-installer/master/files/ha"
URL_BIN_HASSIO="https://raw.githubusercontent.com/home-assistant/supervised-installer/master/files/hassio-supervisor"
URL_BIN_APPARMOR="https://raw.githubusercontent.com/home-assistant/supervised-installer/master/files/hassio-apparmor"
URL_SERVICE_HASSIO="https://raw.githubusercontent.com/home-assistant/supervised-installer/master/files/hassio-supervisor.service"
URL_SERVICE_APPARMOR="https://raw.githubusercontent.com/home-assistant/supervised-installer/master/files/hassio-apparmor.service"
URL_APPARMOR_PROFILE="https://version.home-assistant.io/apparmor.txt"

# Check env
command -v systemctl > /dev/null 2>&1 || error "Only systemd is supported!"
command -v docker > /dev/null 2>&1 || error "Please install docker first"
command -v jq > /dev/null 2>&1 || error "Please install jq first"
command -v curl > /dev/null 2>&1 || error "Please install curl first"
command -v avahi-daemon > /dev/null 2>&1 || error "Please install avahi first"
command -v dbus-daemon > /dev/null 2>&1 || error "Please install dbus first"
#command -v nmcli > /dev/null 2>&1 || warn "No NetworkManager support on host."
#command -v apparmor_parser > /dev/null 2>&1 || warn "No AppArmor support on host."


# Check if Modem Manager is enabled
if systemctl list-unit-files ModemManager.service | grep enabled; then
    warn "ModemManager service is enabled. This might cause issue when using serial devices."
fi

# Detect if running on snapped docker
#if snap list docker >/dev/null 2>&1; then
 #   DOCKER_BINARY=/snap/bin/docker
 #   DATA_SHARE=/storage/docker/hassio/
 #   CONFIG=$DATA_SHARE/hassio.json
 #   DOCKER_SERVICE="snap.docker.dockerd.service"
#fi

# Parse command line parameters
while [[ $# -gt 0 ]]; do
    arg="$1"

    case $arg in
        -m|--machine)
            MACHINE=$2
            shift
            ;;
        -d|--data-share)
            DATA_SHARE=$2
            shift
            ;;
        -p|--prefix)
            PREFIX=$2
            shift
            ;;
        -s|--sysconfdir)
            SYSCONFDIR=$2
            shift
            ;;
        *)
            error "Unrecognized option $1"
            ;;
    esac
    shift
done

PREFIX=${PREFIX:-/storage/hassio}
SYSCONFDIR=${SYSCONFDIR:-/storage/hassio/etc}
DATA_SHARE=${DATA_SHARE:-$PREFIX/share/hassio}
SBIN=${SBIN:-$PREFIX/sbin}
SERVICE=${SERVICE:-$SYSCONFDIR/systemd/system/}
CONFIG=$SYSCONFDIR/hassio.json

# Generate hardware options
case $ARCH in
    "i386" | "i686")
        MACHINE=${MACHINE:=qemux86}
        HOMEASSISTANT_DOCKER="$DOCKER_REPO/$MACHINE-homeassistant"
        HASSIO_DOCKER="$DOCKER_REPO/i386-hassio-supervisor"
    ;;
    "x86_64")
        MACHINE=${MACHINE:=qemux86-64}
        HOMEASSISTANT_DOCKER="$DOCKER_REPO/$MACHINE-homeassistant"
        HASSIO_DOCKER="$DOCKER_REPO/amd64-hassio-supervisor"
    ;;
    "arm" |"armv6l")
        if [ -z $MACHINE ]; then
            error "Please set machine for $ARCH"
        fi
        HOMEASSISTANT_DOCKER="$DOCKER_REPO/$MACHINE-homeassistant"
        HASSIO_DOCKER="$DOCKER_REPO/armhf-hassio-supervisor"
    ;;
    "armv7l")
        if [ -z $MACHINE ]; then
            error "Please set machine for $ARCH"
        fi
        HOMEASSISTANT_DOCKER="$DOCKER_REPO/$MACHINE-homeassistant"
        HASSIO_DOCKER="$DOCKER_REPO/armv7-hassio-supervisor"
    ;;
    "aarch64")
        if [ -z $MACHINE ]; then
            error "Please set machine for $ARCH"
        fi
        HOMEASSISTANT_DOCKER="$DOCKER_REPO/$MACHINE-homeassistant"
        HASSIO_DOCKER="$DOCKER_REPO/aarch64-hassio-supervisor"
    ;;
    *)
        error "$ARCH unknown!"
    ;;
esac

if [ -z "${HOMEASSISTANT_DOCKER}" ]; then
    error "Found no Home Assistant Docker images for this host!"
fi

if [[ ! "intel-nuc odroid-c2 odroid-n2 odroid-xu qemuarm qemuarm-64 qemux86 qemux86-64 raspberrypi raspberrypi2 raspberrypi3 raspberrypi4 raspberrypi3-64 raspberrypi4-64 tinker" = *"${MACHINE}"* ]]; then
    error "Unknown machine type ${MACHINE}!"
fi

### Main

# Init folders
if [ ! -d "$DATA_SHARE" ]; then
    mkdir -p "$DATA_SHARE"
fi
if [ ! -d "$SYSCONFDIR" ]; then
    mkdir -p "$SYSCONFDIR"
fi
if [ ! -d "$SBIN" ]; then
    mkdir -p "$SBIN"
fi
if [ ! -d "$SERVICE" ]; then
    mkdir -p "$SERVICE"
fi
# Read infos from web
HASSIO_VERSION=$(curl -s $URL_VERSION | jq -e -r '.supervisor')

##
# Write configuration
cat > "$CONFIG" <<- EOF
{
    "supervisor": "${HASSIO_DOCKER}",
    "homeassistant": "${HOMEASSISTANT_DOCKER}",
    "data": "${DATA_SHARE}"
}
EOF

##
# Pull supervisor image
echo "[Info] Install supervisor Docker container"
docker pull "$HASSIO_DOCKER:$HASSIO_VERSION" > /dev/null
docker tag "$HASSIO_DOCKER:$HASSIO_VERSION" "$HASSIO_DOCKER:latest" > /dev/null

##
# Install Hass.io Supervisor
echo "[Info] Install supervisor startup scripts"
curl -sL ${URL_BIN_HASSIO} > "/storage/hassio/sbin/hassio-supervisor"
curl -sL ${URL_SERVICE_HASSIO} > "/storage/.config/system.d/hassio-supervisor.service"

sed -i "s,%%HASSIO_CONFIG%%,${CONFIG},g" "${PREFIX}"/sbin/hassio-supervisor
sed -i -e "s,%%DOCKER_BINARY%%,${DOCKER_BINARY},g" \
       -e "s,%%DOCKER_SERVICE%%,${DOCKER_SERVICE},g" \
       -e "s,%%HASSIO_BINARY%%,${PREFIX}/sbin/hassio-supervisor,g" \
       "${SYSCONFDIR}/systemd/system/hassio-supervisor.service"

chmod a+x "${PREFIX}/sbin/hassio-supervisor"
systemctl enable hassio-supervisor.service

#
# Install Hass.io AppArmor
#if command -v apparmor_parser > /dev/null 2>&1; then
#    echo "[Info] Install AppArmor scripts"
#    mkdir -p "${DATA_SHARE}/apparmor"
#    curl -sL ${URL_BIN_APPARMOR} > "${PREFIX}/sbin/hassio-apparmor"
#    curl -sL ${URL_SERVICE_APPARMOR} > "${SYSCONFDIR}/systemd/system/hassio-apparmor.service"
#    curl -sL ${URL_APPARMOR_PROFILE} > "${DATA_SHARE}/apparmor/hassio-supervisor"
#
#    sed -i "s,%%HASSIO_CONFIG%%,${CONFIG},g" "${PREFIX}/sbin/hassio-apparmor"
#    sed -i -e "s,%%DOCKER_SERVICE%%,${DOCKER_SERVICE},g" \
#	   -e "s,%%HASSIO_APPARMOR_BINARY%%,${PREFIX}/sbin/hassio-apparmor,g" \
#	   "${SYSCONFDIR}/systemd/system/hassio-apparmor.service"
#
 #   chmod a+x "${PREFIX}/sbin/hassio-apparmor"
  #  systemctl enable hassio-apparmor.service
   # systemctl start hassio-apparmor.service
#fi

##
# Init system
echo "[Info] Run Hass.io"
systemctl start hassio-supervisor.service

##
# Setup CLI
echo "[Info] Install cli 'ha'"
curl -sL ${URL_HA} > "${PREFIX}/bin/ha"
chmod a+x "${PREFIX}/bin/ha"

You need to:
chmod +x hassio-install.sh (My config above)
mkdir -p /storage/hassio/etc/
touch /storage/hassio/etc/hassio.json
mkdir -p /storage/hassio/sbin
touch /storage/hassio/sbin/hassio-supervisor
mkdir -p /storage/hassio/etc/systemd/system
touch /storage/hassio/etc/systemd/system/hassio-supervisor.service

Also, you maybe need this fix.

Let ./hassio-install.sh -m odroid-n2 do its thing

(valid -m are: intel-nuc odroid-c2 odroid-n2 odroid-xu qemuarm qemuarm-64 qemux86 qemux86-64 raspberrypi raspberrypi2 raspberrypi3 raspberrypi4 raspberrypi3-64 raspberrypi4-64 tinker. )

Then: /storage/hassio/sbin/hassio-supervisor which should pull what remains and start it up at you corelecIP:8123

check content of above hassio-supervisor & hassio-supervisor.service match.

N.B: The following are historic ramblings:
It pulls and does it’s thing when I:
/storage/hassio/sbin/hassio-supervisor
But, it chokes on:
20-08-06 06:37:34 INFO (MainThread) [supervisor.plugins.dns] No CoreDNS plugin Docker image homeassistant/aarch64-hassio-dns found. 20-08-06 06:37:34 INFO (MainThread) [supervisor.plugins.dns] Setup CoreDNS plugin 20-08-06 06:37:34 INFO (MainThread) [supervisor.updater] Fetch update data from https://version.home-assistant.io/stable.json 20-08-06 06:37:34 WARNING (MainThread) [supervisor.updater] Can't process version data: 'aarch64' 20-08-06 06:37:34 WARNING (MainThread) [supervisor.plugins.dns] Error on install CoreDNS plugin. Retry in 30sec

Which is strange, as it’s there: https://hub.docker.com/r/homeassistant/aarch64-hassio-dns
Suppose it’s iptables related. (edit: it was not, see below)

Nope, its not iptables related, since I can:
docker ps
docker exec -it batsoup32e1 /bin/bash
ping google.com

… ok so instead of aarch64, I started the script with -m odroid-n2
Now I at least got to the preparing phase at coreelegIP:8123

And I’m in.

Several controllers are listed etc, can install apps. Let’s see if I can add lights.

1 Like

Yes! I thwarted the disdain for usb3 that my conbee2 have not been to shy about proclaiming. Just a 10-15 year old really shitty usb2 china hub that I dug up. Real underdog. F

Added a zwave+ (+ device) and RFXtrx433XL.

It works!

It’s a bit of a patchwork getting it going and the supervisor container does not start at boot, even though it’s very easy to start said stuff through portainer, which should be easy to remedy.

Another thing that feels way more off, is that I have not figured out how to ssh into it. Sure your config is here: /storage/hassio/share/hassio/homeassistant and of course it’s “mounted”, but it does not sit right at all.

There seem to be a great ssh addon, I have changed the default ssh port for coreelec so there should be no issues on that part.

And for the love of CoreELEC, don’t forget to open the ports in the firewall if you do that. It’s fixable but a hazzle.

I will get a bit more acquainted and then write a more coherent how to.
But by all means, give it a whirl. It’s not pretty but it’s there step by step.

Note to self: Oh, right. I have to figure out the part about external database.

1 Like

Hi,

first off thanks to @danielpub for taking the time to write this guide.

I am trying to use it on a s905x machine (beelink mxiii ii) running coreelec 9.2.4.1 in internal storage. Docker is installed through the coreelec repository, and the required (but missing) jq using Entware.

However, when I try to run the script, set up either as a odroid-n2 or aarch64 machine, it fails:

Failed to start hassio-supervisor.service: Unit hassio-supervisor.service has a bad unit file setting

The output of the “systemctl status hassio-supervisor.service” command:

CoreELEC systemd[1]: /storage/.config/system.d/hassio-supervisor.service:3: Failed to add dependency on %DOCKER_SERVICE%, ignoring: Invalid argument
CoreELEC systemd[1]: /storage/.config/system.d/hassio-supervisor.service:4: Failed to add dependency on %DOCKER_SERVICE%, ignoring: Invalid argument
CoreELEC systemd[1]: /storage/.config/system.d/hassio-supervisor.service:9: Executable “%DOCKER_BINARY%” not found in path “/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin”, ignoring
CoreELEC systemd[1]: /storage/.config/system.d/hassio-supervisor.service:10: Executable “%HASSIO_BINARY%” not found in path “/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin”

Would anybody know how I can troubleshoot that?

thank you in advance.

@argotera NP!

I would recommend that you check the content in the supervisor service file, the declared path’s in my slap’ed-together-in-the-dark-with-an-unknown-keyboardlayout script and then a /storage/hassio/sbin/hassio-supervisor.

However my Dear All, things seems to have changed in the latest update of HA, as there was some netizens on the homeassistant forums having a bit of a problems as well.

The ‘what’- part I am not sure of, since the ‘time’-factor has not showed up yet for the ‘oh, so that happened’-equation.

Hopefully I get/am able to make time, since this is starting to have real value in everyday life to me, as the N2 with coreelec is such a nice device that I truly own in many aspects, and yet can give away freely by writing stuff like this.

Thank you again,

I spent quite a few houts today trying to learn and google my way to a solution but I am not any closer.
Couldnt understand what was needed in the files you mentioned and where in the paths declaration is the problem. Something with the prefixes maybe?

“%DOCKER_BINARY%” not found in path “/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin”
and
%HASSIO_BINARY%" not found in path "/usr/local/sbin:/usr/local/bin:/usr/s

the file /storage/hassio/etc/systemd/system/hassio-supervisor.service

is empty

Here are some findings in case they help someone else:
The script -as posted here-, fails whatever the -m flag is, including odroid-n2. Machine is set properly in the variable though.

Commenting out the following in order to continue seems to work.

if [[ ! “intel-nuc odroid-c2 odroid-n2 odroid-xu qemuarm qemuarm-64 qemux86 qemux86-64 raspberrypi raspberrypi2 raspberrypi3 raspberrypi4 raspberrypi3-64 raspberrypi4-64 tinker” = “${MACHINE}” ]]; then
error “Unknown machine type ${MACHINE}!”
fi

Furthermore jq package is needed and is not included in a fresh coreelec installation. You can use a package manager called Entware which can be installed by command “installentware” and after reboot use it to install jq by running “opkg install jq”.
Entware installation asks to add some /opt/bin and opt/sbin directories to path
and to add “/opt/etc/init.d/rc.unslung start” to autostart.sh.
I don’t know if the steps are needed in this case

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

About | FAQ | Terms of Service | Privacy Policy | Legal Notice