Hi all, I saw that Heyu is supported in HA but in order to get it to work in hassio I need to make an add-on from Kevin Eye’s docker image (https://github.com/kevineye/docker-heyu).
I did read through the tutorial, but had some big picture questions to ask:
- Do I need to convert his shell script (heyu-run.sh) into bash?
- In his installation instructions he wrote the setup part included below. How would I achieve this with hassio?
I first created this file:
config.json
{
"name": "Heyu X-10 Add-on",
"version": "1",
"slug": "heyu",
"description": "Install Kevin Eye Heyu Docker Image",
"startup": "before",
"boot": "auto",
"options": {},
"schema": {}
}
From his documentation and files I see:
Dockerfile
FROM alpine
MAINTAINER Kevin Eye <[email protected]>
RUN apk -U add curl build-base \
&& mkdir /build \
&& cd /build \
&& curl -LsSO http://github.com/msoap/shell2http/releases/download/1.4/shell2http-1.4.amd64.linux.zip \
&& echo 'd0c00a5a0e6ecf664ad865f2e949cf1d8ca2b4b7 *shell2http-1.4.amd64.linux.zip' | sha1sum -c - \
&& unzip shell2http-1.4.amd64.linux.zip shell2http \
&& mv shell2http /usr/local/bin \
&& curl -LsSO http://www.heyu.org/download/heyu-2.11-rc1.tar.gz \
&& echo 'f02fa53b866343f05d57a2ac87c7f7b39c786295 *heyu-2.11-rc1.tar.gz' | sha1sum -c - \
&& tar xzf heyu-2.11-rc1.tar.gz \
&& cd heyu-2.11-rc1 \
&& ./configure --sysconfdir=/etc \
&& make \
&& make install \
&& cd / \
&& apk --purge del curl build-base \
&& rm -rf /build /etc/ssl /var/cache/apk/* /lib/apk/db/*
RUN cp -r /etc/heyu /etc/heyu.default \
&& mkdir -p /usr/local/var/tmp/heyu \
&& mkdir -p /usr/local/var/lock \
&& chmod 777 /usr/local/var/tmp/heyu \
&& chmod 777 /usr/local/var/lock
VOLUME /etc/heyu
EXPOSE 80
COPY heyu-run.sh /usr/local/bin/heyu-run
CMD heyu-run
heyu-run.sh
#!/bin/sh
if [ ! -f /etc/heyu/x10.conf ]; then
cp /etc/heyu.default/* /etc/heyu
echo "x10config.sample and x10.sched.sample have been copied to your config directory." 1>&2
echo "Please use them to create x10.conf and x10.sched and re-run." 1>&2
exit;
fi
heyu engine 1>&2
heyu upload 1>&2
heyu setclock 1>&2
if [ -z "$URL_KEY" ]; then
export prefix="/"
else
export prefix="/$URL_KEY/"
fi
macro=$(cat <<'SCRIPT')
REQUEST_URI=$(expr substr "$REQUEST_URI" $(expr length "$prefix") 200)
echo "Access-Control-Allow-Origin: *"
echo
heyu macro "$(expr substr \"$REQUEST_URI\" 8 100 | tr -cd A-Za-z0-9_-)" 1>&2
SCRIPT
getset=$(cat <<'SCRIPT')
REQUEST_URI=$(expr substr "$REQUEST_URI" $(expr length "$prefix") 200)
echo "Access-Control-Allow-Origin: *"
echo
unit_code=$(expr match "$REQUEST_URI" '/\([A-P][01]\{0,1\}[0-9]\)$')
if [ ! -z "$unit_code" ]; then
if [ "$REQUEST_METHOD" = "GET" ]; then
if [ "$(heyu onstate "$unit_code")" '>' 0 ]; then echo ON; else echo OFF; fi
elif [ "$REQUEST_METHOD" = "POST" ]; then
body=$(cat)
if [ "$body" = "ON" ]; then
heyu on "$unit_code" 1>&2
else
heyu off "$unit_code" 1>&2
fi
fi
elif [ "$REQUEST_METHOD" = "POST" ]; then
house_code=$(expr match "$REQUEST_URI" '/\([A-P]\)$')
if [ ! -z "$house_code" ]; then
body=$(cat)
if [ "$body" = "ON" ]; then
heyu allon "$house_code" 1>&2
else
heyu alloff "$house_code" 1>&2
fi
fi
fi
SCRIPT
shell2http -cgi -no-index -port 80 -export-vars 'prefix' \
"${prefix}macro/" "$macro" \
"$prefix" "$getset" &
heyu monitor
Kevin Eye’s setup instructions:
Setup
Run this to generate some config files:
docker run --rm -v /your/config/dir:/etc/heyu kevineye/heyu
Copy x10config.sample to x10.sched.sample and to x10.conf and x10.sched and edit your configuration.
Run
docker run -d \
-v /your/config/dir:/etc/heyu \
-v /etc/localtime:/etc/localtime \
--device /dev/ttyUSB0 \
-p 8080:80
kevineye/heyu
The device can be configured in the x10.conf file.
I have a load of X-10 gear I bought in the 90’s and would love to be able to get some of it up and running
Thanks for any help!!
Brandon