Is there an addon for Heyu (x10)?

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?

Did anyone get this working?

I got the addon put together and tried to install it from the interface but get the following error:

ERROR (SyncWorker_2) [hassio.docker.addon] Can’t build local/armhf-addon-heyu:1: Please provide a source image with from prior to commit

I am not too familiar with docker but I found this docker-error
and the solution was: ‘‘FROM’’ must be the first instruction into the Docker file.
Does anyone know how to reslove this? Thanks!

Hi all, I just tried this and got it to install but now am at a loss of what to do next.

It built, installed as an add-on, and lets me start it. Doesn’t throw any errors that I can tell in the logs (hassos log).

But I can’t find anything that it should have installed. I can ssh into my hass.io (which is how I made the local add-on) but no “heyu” or config files anywhere in there.

Any thoughts on where the config file would be and how to access it? I’m running a VM (x86) with a Hassos image, Hass.io, and Home Assistant.

I figured out that it would start and exit, but no errors in the error log.

To confirm this, I dropped to a login prompt in Hass.os (“login” from the CLI) and played around with a few Docker commands. I got it to list the active containers and all the add-ons were there except the Heyu one I just installed.

Log file shows the right output on startup (copying config files); but it just doesn’t stay running and I can’t find any of the files it supposedly copied. Still going to play around with it some more. Might try a manual install of heyu on the hass.io container just to make sure I can get it working by hand, then figure out how to containerize it so it survives updates and such.

I’d welcome an addon for x10. Did this get resolved?

1 Like

Rather than messing around with an add-on I just created a new Docker image that includes heyu. Dockerfile is here: https://gist.github.com/swilson/d096a161059a5da0ff7ce4e020c559fd

Note I’m running on x86; don’t know if it will work on ARM.

@swilson, can this method be used with hass.io or just a dockerized home assistant install?

I don’t use hass.io so I’m not sure.

Ok, so first of all big thx to all of you for sharing above information and a VERY big thx to Kevin!
I’ve finally got it working and this is how i did it (in Hasio latest version).

First i installed the portainer and the terminal addon.
Then i got into terminal and run the following commands:

cd \addons
md heyu-addon
cd heyu-addon
nano Dockerfile

(copy and paste the following from here:)

FROM alpine

RUN apk -U add curl build-base \
 && mkdir /build \
 && cd /build \
 && curl -LsSO https://github.com/msoap/shell2http/releases/download/1.12/shell2http1.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

(till here then ctrl + x and anwser with y)
then i made the file config.json:
nano config.json

(copy and paste the following from here:)

{
  "name": "heyu",
  "version": "1",
  "slug": "heyu",
  "description": "heyu addon",
  "arch": ["armhf", "armv7", "aarch64", "amd64", "i386"],
  "startup": "before",
  "boot": "auto",
  "devices": ["/dev/ttyUSB0:/dev/ttyUSB0:rwm"],
  "privileged": ["SYS_ADMIN"],
  "full_access": true,
  "kernel_modules": true,
  "options": {},
  "schema": {}
}

(till here then ctrl + x and anwser with y)
then i made the file heyu-run.sh

nano heyu-run.sh

(copy and paste the following from here:)

#!/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
fi

heyu engine 1>&2
heyu upload 1>&2
heyu setclock 1>&2
heyu on D3

if [ -z "$URL_KEY" ]; then
    export prefix="/"
else
    export prefix="/$URL_KEY/"
fi

macro=$(cat <<'SCRIPT')
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')
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
        elif [ "$body" = "OFF" ]; then
            heyu off "$unit_code" 1>&2
        else 
            heyu xpreset "$unit_code" "$body" 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

(till here the ctrl + x and anwser with y)
then i entered the following command:

docker build --tag heyu:1.0 .

DO NOT FORGET the . at the end of the line, imo copy exactly!!!

then i entered the next command:

docker run --privileged -d -v /mnt/data/supervisor/homeassistant:/etc/heyu -v /etc/localtime:/etc/localtime --device /dev/ttyUSB0 -p 8080:80 heyu:1.0

Now the container is being build and if it is finished you can test it with the following command:

curl -v POST http://localhost:8080/A1 -d "ON"

This should put A1 in the on position, so if this is working you want to go to your configuration.yaml:
cd \config
nano configuration.yaml
and add the following lines:

shell_command:
  cmd_x10_on: "curl POST http://localhost:8080/{{x10code}} -d 'ON'"
  cmd_x10_off: "curl POST http://localhost:8080/{{x10code}} -d 'OFF'"
  cmd_x10_level: "curl POST http://localhost:8080/{{x10code}} -d '{{x10level}}'"

(till here then ctrl + x and anwser with y)
and finally add the x10 switches:

nano light.yaml

     slaapkamerlichtrechts:
      friendly_name: "Slaapkamerlichtrechts"
      turn_on:
        - service: shell_command.cmd_x10_on
          data_template:
            x10code: "D3"
      turn_off:
        - service: shell_command.cmd_x10_off
          data_template:
            x10code: "D3"
      set_level:
        - service: shell_command.cmd_x10_level
          data_template:
            x10code: "D3"
            x10level: "{{(brightness/4)|int}}'"

Now you are able to turn on, off and dim an X10 device from Hassio.

That being said, i havent got a clue of Docker or those other files(i just viewed and adapted), so a real Guru will probably say that all this is a big security risk(running in privileged mode and shit)… But it works, i’ve got a great firewall and i live alone.

Cheers.

3 Likes

I’m trying to add x10 to Raspberry PI 4 using HEYU and a CM11a with Home Assistant build image. Thank you for all the input. I took the romanc content and got it to build / run from the built-in SSH & Web terminal. While I was able to use the command line per romanc’s instructions, I was not able to access the service or x10 devices inside of the Home Assistant UI. I then adapted a few things from romanc’s input to create a true ‘add-on’. It actually starts, runs, and stays running. As an add-on I can go into the HEYU add-on log and see the monitor is running in the background. I can see x10 commands on the power line (triggered by a manual x10 transmitter) come into the CM11a and be logged into the HEYU add-on log in the UI.
However I have not been able to actually turn lights on or see devices show up in Home Assistant.

I’m confused on the instructions documented on the HEYU man pages which say to configure devices in “x10.conf”. The instructions on the web page “https://www.home-assistant.io/integrations/x10” say to add device information to configuration.yaml.

Any advice out there on a) which configuration file/approach is right if I’m trying to run HEYU as an add-on and b) has anyone gotten HEYU to report x10 devices in the devices page of Home Assistant regardless of using add-on versus HEYU build/run instructions illustrated by romanc?

Hi Stephen,

Before I used Hasio, I used Home Assistant without Docker on a raspberry. Then i too, would only have to set the usb port in x10.conf (like in Hasio above) but then I could use the x10 platform. Heyu would communicate with home assistant as a background service (true the x10 platform) and you could see if something is turned on manual(without Home Assistant, a switch for instance). My lights.yaml file would look like this:

  • platform: x10
    devices:
    • id: c16
      name: Livingroomlight

So i did not put all my x10 devices in X10.conf but in lights.yaml (much easier then the docker approach with the command line). I would like to know what things you adapted, maybe i can help.