Smart Home: An Example of Development and Implementation. Part 3

Smart Home: An Example of Development and Implementation. Part 3

Implementation

 

To implement a smart home system, you need to select a hardware solution (which is not covered by this article) and a software platform. Today there are many open-source software solutions in the market. In my opinion, the following projects are worth considering (systems that I have had experience with):

 

  • OpenHAB is a well-known system written in Java. In my opinion, it is difficult to set and provide a logical connection between smart home devices. You can also use Google Blockly as logic programming tools
  • Node-red is a system for implementing simple smart home logic, provided that devices are connected via standard application level protocols (rest, mqtt, etc.). I recommend it for simple solutions, such as a security system, presence imitation system 
  • ioBroker is a system written in JavaScript (Node JS). It has a simple and appropriate architecture which is sufficiently stable and supports a wide range of devices. It utilizes a simple paradigm: devices with sets of state and capability to subscribe to changes of state. For programming the smart home logic, you can use JavaScript, Google Blockly, or Node-red within ioBroker. It is this system that I have used for the second version of my smart home launched in September 2019 

 

The smart home itself is now implemented on the basis of Rapsberry PI 3 and the Rapsberrian operating system. As already mentioned, ioBroker is used as a control system. The lightning and power supply control is based on the Noolite technology. As additional hardware a GSM module is used, which is utilized for emergency alarms in the absence of an Internet connection, and as an additional channel to control the system through SMS from trusted phones.

The logic of communication between devices is implemented on the basis of JavaScript, Google Blockly, and Node-red scripts.

 

A JavaScript script is an ordinary program for NodeJS. For example, this is how a chime of bells is implemented in the author’s smart home:

 

            schedule('0 0,8-23 * * *',() =>

            {

             let currentTime = new Date();

             let hour = currentTime.getHours();

             if(hour > 12)

                        hour -= 12;

             let file = hour.toString() + 'h.mp3';

            playSound('audio/' + file);

           });

 

The ioBroker code every hour within the interval 8:00AM-11:00PM calls a function that forms the name of the file in which the chime is recorded for a relevant time and plays the required audio file on an external device.

 

Google Blockly enables you to write code in a visual programming language, without going into details of JavaScript. For example, this method is used to turn on the light in the hall by motion sensor: after sunset the light is turned on to 100%, at night to 10% of brightness.

Google Blockly smart home.png

 

Here we can see the subscription to the event of the motion sensor’s change state. This code will be called once the state changes and will contain “true.”

And by using Node-red, we can implement simple control scripts. In the bathroom, for example, we can use simple code to control lights with a motion sensor.

 

Once the sensor changes its state, Node-red blocks are executed automatically. When the sensor transmits a “turn off” command, the script provides a 5-minute delay and then turns off the light. If during 5 minutes the sensor sends the “turn on” command, the delay will be canceled and the light will remain on. Detailed discussion of how to implement Node-red block is outside the scope of this article.

Node-red smart home.png

 

Thus, by treating the smart home as a system for increasing the quality of life, I have managed to realize my dream without substantial expenses. By the time of launching the project for a two-room apartment, its cost was around $810.