Driver progress and useful tools

In June this year I started with moving all the drivers of my Domotica system to Node.JS on the Raspberry Pi (Rpi). And now, 2 months later, the number of drivers running on the RPi is 15. Wooaahh, that’s fast, faster than I ever imagined! It can’t get any faster than this.. Among those drivers there are really simple ones like the one for the Roomba Robot vacuum cleaner, but also some really critical ones like the for PLCBUS driver which controls the largest number of actors in our house. And all those drivers are working great… sometimes the code is so small that you start to think ‘is this all it takes?‘Apparently it is…

There are still some drivers that need to be moved to the Raspberry though: Zigbee, Visonic Powermax, ELV Max!, Nemef Radaris, Somfy just to name a few. But with what I’ve developed so far I think I’ve got enough experience to finish those quite easily too. In the meantime I’ve also been searching for, testing and implementing some solutions that I need.


Monit on Raspberry PiHow do you keep an eye on a bunch of drivers running on a Raspberry Pi without a screen attached to it? Well, not by logging in, listing the running processes with ‘ps’ and see if they’re all still there. There’s a much better way for that and it’s called Monit. This really cool monitoring tool allows you to monitor a lot and alert you if something is not right. Processes, file attributes, CPU, disk space – everything you’d want to monitor. You can manually start / stop / restart processes (i.e. drivers in this case) and when a drivers fails for some reason, you can have it restarted for you automatically, without having to do anything yourself! Talking about automation… I did have to switch to upstart before I was able to start a Node process as a daemon. It took me quite some time before I figured out it wasn’t me that was doing something wrong, but in the end I found the answer to my problem in this article. After installing upstart and creating the scripts, everything went fine.


Or scenarios, rules… the things that enables you to really do something with all the sensor information; a very important (indispensable!) part of any Home Automation system. Lights going on & off automatically, Roller shutters being used to keep the temperature inside at an acceptable level, all lights going on when a smoke detector is triggered, …

My current system has an event sub-system that can do all that; but it wasn’t flexible enough. if, and, or, >, =, < were the things I could do with it, and scheduling in a crontab-like way. But when it came to executing actions when something had happened in the past, or adding a lot of conditions, defining those rules became a hassle, it looked ugly. So I started searching for a rules engine that could run with Node.JS and had it’s own DSL. Well, I found it and I’m already using it! Nools subscribes to all the information (‘#’) that’s on my MQTT broker, so I can use all the information in the rules I want to have.

Here’s a very simple rule to demonstrate how an action can be triggered by a sensor:

rule garage_door_open {
  when {
    e1: Event.device == 'Garage door' && Event.value == 'open';
  then {
    publish("command/speak", "Attention, garage door open", false);

In this example, a message is being sent to my TTS  (Text To Speech) driver to speak some text when the garage door opens. I could just as easy turn on the lights in the garage…or, (handy during the winter) speak a warning message that the garage door is open for too long. Using the Nools DSL is a very convenient way of defining those rules – in a text file, in a human readable way. And Nools looks like a very powerful and flexible tool to define my rules – I love it!


My current system stores the historic data in a MS SQL Server that’s running in a Hyper-V VM environment. Some information is stored forever (gas, water, power usages) and others for a shorter period like a month, so I can watch trends). The time has come to see if I want and/or really need to keep on doing that in the future – using MS SQL Server, that is. As long as my system is in a ‘dual state’ (i.e. running partly as Delphi application on Windows and partly on Raspberry Pi with Node.JS) I will need that database. And I’m not going to spend time on my Delphi application in terms of new functionality anymore – just those things that are needed to gradually destroy it to null. So until I’ve totally freed myself from the Delphi application running on Windows, I’ll also need to use my MS SQL Server.

This also means that I’ll need a way to use my MS SQL Server from Node.JS, only for retrieving information. Cause this SQL database doesn’t only contain the historic data, but also all the information about where all the devices are in the house (floor, room), what those devices are and what they can do (switch a light or a waterpump on/off, whether it’s a boiler or a media player) and so on. All this metadata is in that database too and I’ll need it in Node.JS, soon..

And again, I found a great Node module for that, named tedious. It uses the TDS protocol and allows you to connect to a MS SQL Server, execute queries and so forth – just what I need. My plan is to use tedious to store historic data in my MS SQL Server for as long as it’s needed.

The bigger picture however, the ultimate goal, is that my Domotica system runs on nothing but Raspberry Pi(s), with maybe a dedicated NAS-like device for historic data storage, web server stuff and to get rid of my 34W Hyper-V server. But there’s still a lot that needs to be done before I can do that, so ..


Bookmark the permalink.

3 Responses to Driver progress and useful tools

  1. Averell says:

    Would it be possible to share some example of how MQTT and nools works together? I’m finding it quite hard to work out exactly how to pass payload from MQTT to nools. Any code example would be much appreciated.


    • Hi Averell,
      Dat kan hoor en als je het eenmaal doorhebt zul je zien dat het eigenlijk niet veel voorstelt 😉
      Ik zal daar binnenkort een post aan wijden want ik kan me zo voorstellen dat dit niet alleen voor jou interessant zal zijn.
      Laten we zeggen in de komende week ergens?

      • Averell says:

        Thx Robert, zou top zijn. Ben via via op jouw site terechtgekomen, juist omdat ik worstel met de complexiteit van alle code die ik inmiddels heb, een rule engine zou t mogelijk maken alles beter te structureren.

        Alvast dank!

Leave a Reply

Your email address will not be published. Required fields are marked *