This is a web server for setting up and communicating with the smart home system HDL Buspro. It was mainly built for the purpose of integrating with Google Assistant (Google Home and Google Pixel).
Google have added some triggers at IFTTT for Google Assistant (i.e. Google Home and Google Pixel). Combining them with the Maker actions, a web request can be sent to the HDL Buspro server in this project. The server interprets the requests by using the actions you have set up and sends the belonging HDL commands to the IP gateway.
Prerequisites:
To start the server on Linux, Mac and other Unix-like systems:
nohup java -cp hdlserver-LATEST.jar com.roysolberg.java.hdlserver.Application &
The server will start logging to the logs
directory. See that everything is running fine:
tail -f logs/hdl-server.log
To start the server on Windows:
javaw -cp hdlserver-LATEST.jar com.roysolberg.java.hdlserver.Application
Alternatively:
start java -cp hdlserver-LATEST.jar com.roysolberg.java.hdlserver.Application
See that everything is fine by looking in the file logs\hdl-server.log
.
You should now be able to go to the server in a browser from a computer on the local network. The server is running on port 4567, so go to http://<server ip address>:4567
.
Next step is to create some actions.
First SSH into your Raspberry Pi.
Type java -version
to see which Java version you have. If it says something with 1.8
or later you are good to go. Just continue to the next step.
If you don't have Java installed or a Java version before version 1.8, run the following commands and follow the setup:
sudo apt-get update
sudo apt-get upgrade
sudo apt install default-jdk
(old command: ) sudo apt-get install oracle-java8-jdk
If you don't have the version-control system Git installed you can install it like this:
sudo apt-get install git
First check out the code:
cd ~
git clone https://github.com/roys/java-hdl-webserver.git
It can be smart to check that the server is working and getting data:
cd java-hdl-webserver/releases
java -cp hdlserver-LATEST.jar com.roysolberg.java.hdlserver.Application
You should see some output confirming that the server is starting up ok. Please note that it could take a few seconds to start up on hardware like one of the Raspberry Pi models.
Use ctrl + c
to exit the application.
If you want to make the server run on startup then skip to 4b. If you want to just run the server in the background (even after you log out) you can enter the following
command:
nohup java -cp hdlserver-LATEST.jar com.roysolberg.java.hdlserver.Application &
The number that is printed out is the process number. You can use this number to stop the script.
If you don't have the process number you can find it using ps aux | grep hdlserver
.
To kill/stop the script just enter the following command:
kill [process number]
The server can be run as a cron job that starts on reboot of the Raspberry Pi.
To edit the cron jobs:
crontab -e
Add the following line at the end:
@reboot /bin/sh ~/java-hdl-webserver/launcher.sh
Use ctrl + x
to exit, press Y
to save the cron setup and enter
to confirm the filename.
Restart the device using sudo shutdown -r now
and check out if there's stuff going on in releases/logs/hdl-bus.log
. releases/logs/hdl-server.log
and releases/logs/nohup.out
will also contain output and any error messages running the server. Please note that there is a delay of 30 seconds when running the server from the launcher.sh
script (to ensure that network interfaces are up and IP address is assigned, etc).
You can easily tap in to what's going by running tail
:
tail -f hdl-bus.log
tail -f hdl-server.log
This will let you follow the file and the contents that's written to it. To end the session just press ctrl + c
.
To be able to have IFTTT access (described later) the server and run the commands you set up you have to ensure that the server is accessible from the Internet. How to do this depends on your Internet router, but in general it will be like this:
You should now be able to go to the server in a browser from a computer on the local network. The server is running on port 4567, so go to http://<server ip address>:4567
.
Next step is to create some actions.
If you chose to do a git clone
in the first step you can just run git pull
inside the directory at ~/java-hdl-webserver
. If you run the script at boot
time it is easiest to just reboot your Raspberry Pi using sudo shutdown -r now
to ensure the latest version of the script is running.
Prerequisites: An account at https://ifttt.com and a Google account.
Dimmer actions let you say commands like Dim the lights to 20% in the kitchen and are meant for HDL dimmers.
Custom actions let you give custom commands like Open the garage which can trigger some panel button or set a universal switch.
Unlike the dimmer actions you need to add both a new action and a new "applet" if you want to create another one.
I strongly recommend using HTTPS for the server. Setting that up is a bit out of scope for this document, but you should really look into it. If not using HTTPS someone on the Internet might pick up the commands you are sending. The commands can replayed and someone might guess how to use other commands.
The reason there is no login for the frontend of the web server is simple: The moment someone has access to the network where there are HDL Buspro traffic they don't need this server. All communication is done in plain text with no security. Therefore securing the frontend with a login would add a false sense of security. The web server front end (not the API for the commands) requires the user to be in the same local network.
The security for the API and the commands lies in an automatically created random key when starting the server the first time. If the requests for the commands are missing the correct key they will not be executed.
Keep in mind that there could potentially be security holes or weaknesses in the code of this project, the web framework this is built on, the built-in application server this runs on, the server you are running, your router, other network components, IFTTT and Google Assistant. You have no guarantees. If you want to stay safe, you should stay offline.
If you want to learn a little more about security and HDL Buspro you read my Google+ post at https://blog.roysolberg.com/2017/08/my-dumb-smart-home .