Is there an addon for Heyu (x10)?

Hi all,

I’m looking for a few weeks now to migrate to Hass.io.
The issue I’ve is that I’m using some X10 devices with a CM11a controller. As far as I know I need the Heyu package to get this working.

I want to know if there is an addon with Heyu for Hass.io? Or another way to get the CM11a working with Hass.io?

Maybe there is someone who can help me to make a start with this addon myself?

Also found this one: https://github.com/kevineye/docker-heyu-mqtt. Is it possible to “simply” implement this in Hass.io?

I found also some other topics here on the community, where I asked for help, but I did not get a reaction. :frowning: Hope I’ve more luck over here :slight_smile:

2 Likes

Time to roll up your sleeves! :wink: https://home-assistant.io/developers/hassio/addon_tutorial/
Definitely looks doable from the github.

1 Like

Home Assistant already uses Heyu internally for X10 support and has done for quite some time.

https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/light/x10.py

I’m hoping in the mean time, you Googled “home assistant x10” or “home assistant heyu” and figured this out :slight_smile:

1 Like

So if I am running Hass.io I can simply add the config lines to my configuration.yaml file?

As follow-up to this, for a hassio installation you do need Heyu which is not available as an add-on. I tried to add the lines to my configuration.yaml but received the error:

2018-02-22 15:33:00 ERROR (MainThread) [homeassistant.components.light] Error while setting up platform x10
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 84, in async_setup
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/light/x10.py", line 45, in setup_platform
    x10_command('info')
  File "/usr/lib/python3.6/site-packages/homeassistant/components/light/x10.py", line 33, in x10_command
    return check_output(['heyu'] + command.split(' '), stderr=STDOUT)
  File "/usr/lib/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 403, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'heyu': 'heyu'

I have a great deal of X10 installed (probably 25 or more modules) and had it working great with google assistant and habridge (which is a phillips hue emulator) until google disabled local network hue access. I started looking for an alternative and came across home assistant. I initially loaded hass.io but could not get heyu installed due to the nature of the hass.io OS. I ended up installing home assistant hassbian. Followed the X10 guide and got it working along with google assistant support. I will tell you beforehand is was a bit of work, I had to register to use sdk with google as well as getting static IPs and https certificates working on Hassbian.

Thanks, I really like hass.io so I’m hoping a Heyu add-on will be made. I posted here about it. I just don’t know enough about converting shell script to bash.

I’m willing to pay for it so maybe I can try that route to see if someone can help us out.

Here is my post:

You don’t need to convert his bash script to bash…it’s already a bash script.

well what am I doing wrong? I have placed the 3 files in the proper directory and loaded it as a local add-on.

His docker container is configured to run an x86 container. A pi is ARM and will never actually run that container. You would need an image built for a pi. Looking at his scripts, he is pointing to x86/64 scripts to pull down. You need something built for ARM

Ahh ok thanks for explaining. I’m going to see if someone wants to help me convert it to ARM then and I’ll offer to pay for it. Then maybe if the author allows it we could put it up for the public to enjoy. I posted a msg in the HA discord channel to see if there is forum category or proper place to post an offer like this. Thanks for your help.

If you take a look at his dockerfile, you will see where he is pulling scripts from.

Check to see if anything for ARM is available for those scripts

EDIT: Looks like there is.

You could try replacing the call in the script with that file instead

Thanks @flamingm0e!

I went to your link and have edited the file and just seeing if I did it correctly.

FROM alpine
MAINTAINER Kevin Eye <[email protected]>

RUN apk -U add curl build-base \
 && mkdir /build \
 && cd /build \
 && curl -LsSO https://github.com/msoap/shell2http/releases/download/1.12/shell2http-1.12.linux.arm.tar.gz \
 && echo '2eed506477de097f1f0f169806bda0fe7f5e3f3e20a3c8c8dd08fbae8dd97b7a *shell2http-1.12.linux.arm.tar.gz' | sha1sum -c - \
 && tar xzf shell2http-1.12.linux.arm.tar.gz 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

My edits are:

  • Line 7: Adding the new Linux ARM download file link in Line 7
  • Line 8: Adding the new Linux ARM file’s SHA256 code at beginning (just assumed this? the new code seems longer than the previous one) and also adding new filename and the end of the line (replacing the previous ZIP file name)
  • Line 9: Removed “unzip” and changed to “tar xzf” and added new Linux ARM filename

Those were all the changes I made to the dockerfile. I assumed my Pi3 isn’t ARM 64, just ARM.

Give it a shot and see what happens. If you get it working I’m sure others would love it.

What does your question have to do with the thread topic?

Do you have an issue with Google Assistant? If so, you need to make your own thread or ask your question in an existing Google Assistant thread.

Finally found time this morning to try to install the new add-on based on your help and suggestions.

When I try to install, unfortunately it doesn’t work and in the Supervisor log I get the following:

18-03-01 12:45:53 INFO (MainThread) [hassio.addons.addon] Create Home-Assistant addon data folder /data/addons/data/local_heyu
18-03-01 12:45:53 INFO (SyncWorker_0) [hassio.docker.addon] Start build local/armhf-addon-heyu:1
18-03-01 12:46:24 ERROR (SyncWorker_0) [hassio.docker.addon] Can't build local/armhf-addon-heyu:1: The command '/bin/sh -c apk -U add curl build-base  && mkdir /build  && cd /build  && curl -LsSO https://github.com/msoap/shell2http/releases/download/1.12/shell2http-1.12.linux.arm.tar.gz  && echo '2eed506477de097f1f0f169806bda0fe7f5e3f3e20a3c8c8dd08fbae8dd97b7a *shell2http-1.12.linux.arm.tar.gz' | sha1sum -c -  && tar xzf shell2http-1.12.linux.arm.tar.gz 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/*' returned a non-zero code: 1
18-03-01 12:48:28 INFO (SyncWorker_4) [hassio.docker.addon] Start build local/armhf-addon-heyu:1
18-03-01 12:48:56 ERROR (SyncWorker_4) [hassio.docker.addon] Can't build local/armhf-addon-heyu:1: The command '/bin/sh -c apk -U add curl build-base  && mkdir /build  && cd /build  && curl -LsSO https://github.com/msoap/shell2http/releases/download/1.12/shell2http-1.12.linux.arm.tar.gz  && echo '2eed506477de097f1f0f169806bda0fe7f5e3f3e20a3c8c8dd08fbae8dd97b7a *shell2http-1.12.linux.arm.tar.gz' | sha1sum -c -  && tar xzf shell2http-1.12.linux.arm.tar.gz 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/*' returned a non-zero code: 1

Thanks for your work Nitroedge, based on that I took out the problem causing the error and now have an installing heyu docker add-on for hass.io. Next step is testing if it acutally works and maybe add something for the config.

Anyway, here are my instructions to get an local docker add-on for heyu which at least will install.

  1. Create a folder called heyu-addon in the /addons folder of your pi
  2. Create a file called Dockerfile with the following content:
MAINTAINER Kevin Eye <[email protected]>

RUN apk -U add curl build-base \
 && mkdir /build \
 && cd /build \
 && curl -LsSO https://github.com/msoap/shell2http/releases/download/1.12/shell2http-1.12.linux.arm.tar.gz \
 && tar xzf shell2http-1.12.linux.arm.tar.gz shell2http \
 && mv shell2http /usr/local/bin \
 && curl -LsSO http://www.heyu.org/download/heyu-2.11-rc1.tar.gz \
 && 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
  1. Create a file called config.jason withe the following content:
  "name": "heyu",
  "version": "1",
  "slug": "heyu",
  "description": "heyu addon",
  "startup": "before",
  "boot": "auto",
  "options": {},
  "schema": {}
}```
4. Create a file called heyu-run.sh, chmod a+x it and use the following content:
```#!/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
  1. Install your newly created heyu docker-addon.

I am going to perform functional testing now, i’ll update as i get results (might not work at all, who knows …)

I am attemting to implement this and hot having much luck. So far…

SSH into the Pi, create the heyu-addon folder inside of /addons
create the Dockerfile with the content above and fixed using JSONLint.com, breaking the file apart before the line beginning with 4.

Then created the heyu-run.sh file, chmod a+x to make it executable.
No dice executing it, I get:

core-ssh:/addons/heyu-addon# ./heyu-run.sh
: No such file or directoryn/sh
./heyu-run.sh: line 2: $’\r’: command not found
./heyu-run.sh: line 34: syntax error near unexpected token elif' '/heyu-run.sh: line 34: elif [ “$REQUEST_METHOD” = “POST” ]; then

Trying to do some debugging on it now. Anybody got this working?

1 Like

I’m going to try this in the next few days as well. I’m running on an ARM64. Is there an image built for that?