To drive the HAS hardware I needed a system that can evaluate and execute hundreds of rules hundreds of times per second while with plenty of headroom. After evaluating a a couple of standard solutions I decided to develop my own domain domain specific language (DSL) called HASI (home automation system interface). 


HASI is implemented in plain C++ 11 without any external libraries. Hence, compilation is as simple as extracting the source, typing make (or make release) and waiting for a few minutes. This code runs on the ARM SoCs (it has been fully tested on the Raspberry Pi A,B,B+,2, the Banana Pi, and the Odroid X2, X3, C1) and on the Arduino HASI integration is even easier, all it takes there is to place the Arduino library into the Arduino IDE's library folder and then add a few lines of code to you sensor project. For example sending temperature, pressure, brightness from an external sensor, all it takes is:

class MySensorArray: public SensorArray {
  MySensorArray() : SensorArray(30000) {}
  uint32_t luminosity;
  float temperature;
  float relativeHumidity;
  float pressure;


  virtual void sendInit() {
    initItem("Helligkeit", "Lux");
    initItem("Temperatur", "Grad C");
    initItem("Relative Luftfeuchtigkeit", "%");
    initItem("Luftdruck", "hPa");

  virtual void sendData() {
} sa;

In the "Loop"-Method add:



sa.pressure = bmp.readPressure()/100.0f;

sa.luminosity = measureTSL();




The connection to the ARM SoCs is established by adding the following code to a device config file, in the above example the entry would look like this:


NetworkInputServer = AS02 "Outdoor sensor garage" 30000 4


This defines a network sensor server which will be called AS02 in the HASI program below, the human readable name would be "Outdoor sensor garage". 30000 is the TCPI port used for the connection and four are the number of values received, it has to match the number of elements send "sendData"-Method above.


With the sensors connected either to the ARM SoCs directly (via I2C) or via a TCP link (above) the various values need to be connected. This is where HASI comes into play. HASI has an extremely simple syntax:



for example

[AS02.3] > 1 : [RELAY01.4] = 1 

Inputs and outputs are written in squared brackets (i.e. [ ] ) the condition to trigger the actions is written on the left separated by a colon (i.e. : ) reactions. Multiple reactions are separated by commas (i.e. , ). The condition can be a complex expression using the standard c, java, etc. syntax with ( && for logical "and", == for equals, etc.) The following statement for example, switches output 4 off on a device called RELAY02 and sets OUT01's port 1 to the same value as AS02 port 4 (which is sensor reading from the example above). 

[AS02.3]==0 && [AS02.4]<20 : [RELAY02.4] = 0, [OUT01.1] = [AS02.4]

This code is executed when port 3 of sensor AS02 equals zero and port 4 is larger than 20.


This is not all, HASI can do much more. As soon as time permits I will add a description of the many more features of HASI. In the meantime you can find more information in my talk slides I presented at the Pi and More 5 event. 


The Javascript front-end

coming soon, if you need it urgently, send me an email

Compiling HAS yourself

(You can also find german video tutorials here on how to compile HAS.)

Compiling HAS is very simple, it does not rely on any external libraries so all you need is the source code from this page and compile it on your favorite operating system. 

Raspberry Pi etc. and any other Linux Systems

Simply download the source, extract it and run make. More specifically, open a terminal and type:

unzip && rm
make release

Depending on your System configuration you may not have all the linux tools installed to perform the compilation, if you have any issues with command lines above try the following installation command line and repeat the process:

sudo apt-get install unzip build-essential libi2c-dev


Mac OS (tested on 10.8 to 10.11)

First you need to make sure you have installed the free Xcode development program from App. After that simply download the source, extract it and run make. More specifically, open a terminal and type:

curl -o -L
unzip && rm
make releasepc

Windows (tested in Windows 7, 8 & 10)

On Windows you just need to download the free community edition of Visual Studio 2015 from here and download and extract the HAS source from here. Then simply open the Visual Studio in the hasVS subfolder and click on build. Done!


Download and License

You can download the entire HASI code (for Arduino, the ARM SoCs, and Mac & PC) form the download page. The code is licensed under the MIT license, so as I understand it you can essentially use it in any type of project, including commercial projects as long as you don't hold me responsible for any damage. Details can be found here.