Skip to content

Instantly share code, notes, and snippets.

@fredrike
Last active September 22, 2021 14:16
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fredrike/c3e26ad704a3670c919cd12155f7dc9b to your computer and use it in GitHub Desktop.
Save fredrike/c3e26ad704a3670c919cd12155f7dc9b to your computer and use it in GitHub Desktop.
hass.io on Synology

Example on getting hass.io to run on an Synology NAS (with arch x86_64)

All commands are run in and sudo environment (sudo su -).

# CHANGE THIS ACCORDINGLY
DATA="/usr/local/share/hassio"

URL_VERSION="https://s3.amazonaws.com/hassio-version/stable.json"

HOMEASSISTANT_DOCKER="homeassistant/qemux86-64-homeassistant"
HASSIO_DOCKER="homeassistant/amd64-hassio-supervisor"

# Read infos from web
HASSIO_VERSION=$(curl -s $URL_VERSION | jq -e -r '.supervisor')

# Pull supervisor image
docker pull "$HASSIO_DOCKER:$HASSIO_VERSION" > /dev/null
docker tag "$HASSIO_DOCKER:$HASSIO_VERSION" "$HASSIO_DOCKER:latest" > /dev/null

# Write config
mkdir -p $DATA/etc
cat > $DATA/etc/hassio.json <<- EOF
{
    "supervisor": "${HASSIO_DOCKER}",
    "homeassistant": "${HOMEASSISTANT_DOCKER}",
    "data": "${DATA}"
}
EOF

The startup script below should be added as an User defined script under Task Scheduler and started at startup.

#!/bin/sh
# CHANGE THIS ACCORDINGLY
DATA="/usr/local/share/hassio"
# Load configs
CONFIG_FILE=$DATA/etc/hassio.json
runSupervisor() {
HOMEASSISTANT="$(jq --raw-output '.homeassistant' ${CONFIG_FILE})"
HASSIO_DATA="$(jq --raw-output '.data // "/usr/share/hassio"' ${CONFIG_FILE})"
APPARMOR="--security-opt apparmor=unconfined"
/usr/local/bin/docker rm --force hassio_supervisor > /dev/null || true
/usr/local/bin/docker run --name hassio_supervisor \
--privileged \
$APPARMOR \
--security-opt seccomp=unconfined \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /var/run/dbus:/var/run/dbus \
-v ${HASSIO_DATA}:/data \
-e SUPERVISOR_SHARE=${HASSIO_DATA} \
-e SUPERVISOR_NAME=hassio_supervisor \
-e HOMEASSISTANT_REPOSITORY=${HOMEASSISTANT} \
${SUPERVISOR}
}
start_hassio () {
SUPERVISOR="$(jq --raw-output '.supervisor' ${CONFIG_FILE})"
HASSIO_IMAGE_ID=$(/usr/local/bin/docker inspect --format='{{.Id}}' ${SUPERVISOR})
HASSIO_CONTAINER_ID=$(/usr/local/bin/docker inspect --format='{{.Image}}' hassio_supervisor || echo "--")
# Fix routing
route -vn |grep 172.30.32.0 >/dev/null || \
route add -net 172.30.32.0/23 gw 172.30.32.1
# Run supervisor
([ "${HASSIO_IMAGE_ID}" = "${HASSIO_CONTAINER_ID}" ] && /usr/local/bin/docker start --attach hassio_supervisor) || runSupervisor
}
while true; do
start_hassio
sleep 1
done
@kevin816
Copy link

Hi. I had followed your code then a supervisor container and a homeassistant container were created on synology successfully.
But it is failed to load the "Hass.io" page on HomeAssistant and return following warning:

Unable to load the panel source: /api/hassio/app/entrypoint.js.

Also a error was found from the log of homeassistant:

ERROR (MainThread) [homeassistant.components.hassio.http] Client error on api app/entrypoint.js request Cannot connect to host 172.30.32.2:80 ssl:None [Operation timed out]  

Then I remove the homeassistant container and manually deploy again with hassio and bridge network (original one only connect host network). The "Hass.io" page work again. But I find some add-on may be not work (e.g. Log Viewer, Configurator).

@mprajsler
Copy link

Hi Kevin, can you describe how you run this on synology? I mean the _intro.md part... I would like to try this as well.
How about adding --net=host \ under or before --privileged \ command in startup_script.sh?

@fredrike
Copy link
Author

Then I remove the homeassistant container and manually deploy again with hassio and bridge network (original one only connect host network). The "Hass.io" page work again. But I find some add-on may be not work (e.g. Log Viewer, Configurator).

The issue was with local routing on the Synology NAS (I've updated the script now).

@mprajsler
Copy link

Hi Fredrik, so you got it running?

Still not sure how should I start. What should I do with _intro.md and what if I would like to get same IP range as my NAS...

@fredrike
Copy link
Author

You can get it running by pasting the grey parts of _intro.md to a user defined script and run it as root.

Then you should be able to start the other script.

I'll try to wrap together a package tomorrow.

@mprajsler
Copy link

mprajsler commented Jun 26, 2019

Thank you, got it up and running.

However I do not seem to have /dev/ttyUSB0 (Conbee stick) in the list of serial devices

Edit: my mistake it was used by hassio on virtualbox

@gwystyl
Copy link

gwystyl commented Jul 19, 2019

The spk installed perfectly on my DS218+. Starting up worked also. I created a user with my name and then I get stuck.
When I click on Hass.io in the menu on the left, nothing happens. Also "unused entities" stays blank, so I can't add my entities using the Lovelace UI.
Any idea why this happens? Please let me know if there's anything I can do to provide you with usefull feedback.

I have a standard Home Assistant instance running in docker, but I stopped it before trying to install the spk from Hass.io.

@fredrike
Copy link
Author

@gwystyl

The spk installed perfectly on my DS218+. Starting up worked also. I created a user with my name and then I get stuck.
When I click on Hass.io in the menu on the left, nothing happens. Also "unused entities" stays blank, so I can't add my entities using the Lovelace UI.
Any idea why this happens? Please let me know if there's anything I can do to provide you with usefull feedback.

I have a standard Home Assistant instance running in docker, but I stopped it before trying to install the spk from Hass.io.

Check in with the support thread at https://community.home-assistant.io/t/hass-io-on-synology-dsm-native-package/125559 and update to the latest version (hassio_x64-6.1_20190709-1.spk).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment