Originally (and possible it will return there) was hosted by Opus, my server.
It is quite a while now is running over a Raspberry Pi.
This article is about how to control X10 via Heyu from another computer in the network (hint, the network is not exposed to the outside)
There are already some articles about HA-Bridge in my blog :
- Home Automation - fixing Ha-Bridge
- Server chronicles - HA temporary server
- Playing with Alexa and Echo
Now the goal is to be able to send Heyu commands to the HA server from another computer in the network.
Mainly is used to control the server area fans from a script on a computer in the server room.
The alternative would be to reinstall the HA server on the main server so that it can control directly X10 via Heyu or try to use the HA-Bridge REST capability.
Mainly is used to control the server area fans from a script on a computer in the server room.
The alternative would be to reinstall the HA server on the main server so that it can control directly X10 via Heyu or try to use the HA-Bridge REST capability.
ssh
It is actually quite straightforward to control X10 via Heyu from another computer.
Is enough to use ssh to send a single command. For example to tun on a light is possible to open a terminal on the computer who wants to send the command and digit :
ssh <user>@<HA-server-URL> 'heyu on c5'
or also using alias if heyu has defined them and the address c5 is defined as alias-light-test
ssh <user>@<HA-server-URL> 'heyu on alias-light-test'
The problem of course is that the command will stop asking for the HA server password.
So it can not be used "as is" in a script.
So it can not be used "as is" in a script.
Trust the machine
What we need to do is to create a key between the two machines so that will not be need any password.
We have two machines.
Lets define the machine who need to control X10 as machine A and the HA server who actually control the X10 loads, as machine B.
On the machine A we need to generate a key if not present or use one if exists.
So on the machine A :
- open a terminal and log in
- check for existing keys : ls -al ~/.ssh/id_*.pub
- If nothing returns, we need to generate a key with : ssh-keygen -t rsa -b 4096 -C "your_email@domain.com"
- At this point copy the generated key (public key) on the machine B
If exists just use the command ssh-copy-id with the user/IP of the machine B :
ssh-copy-id <user>@<machine B IP>
It will ask the password of the machine of course, but after that it will be possible to ssh from the machine A to the machine B without password asking
Remote Control X10 via Heyu
Now to simply turn on or off a light will be enough to call as before the ssh command but this time no password will be asked since the HA server will trust the control machne.
Notes
It works, however (because the X10 nature) will not be possible to know the status of the operation, i.e. to know the X10 status.
A way to do so would be to use HA-Bridge API.
No comments:
Post a Comment