Home Java Software for the smart home

Software for the smart home

by admin

Good afternoon everyone. As a hobby, I wrote a program that can be used as part of a smart home system. To immediately interest the reader, I will demonstrate some small part of the scenarios for using Po :
Software for the smart home

Software for the smart home

Switching ZWavelight bulb on and off via mobile app
Software for the smart home
When the device comes online (when the user comes home), the
ZWave light, ModbusRTU relay module is switched on, computer is started via WakeOnLan and TV is switched on
Software for the smart home
Starts the browser, goes to yandex.radio,
Track flipping (emulation of hotkeys)

Inshort :
1. The bulk of the software is a server that runs on Windows, written in C#;
2. Android client, written in Java;
3. UWP and IOS clients, web client is planned.
Some features of Po :
1. Scenario Builder. Creating complex scripts with loops and conditions;
2. Operation with ZWave and Modbus devices;
3. Script nesting. You can use one script in another as a procedure;
4. Running a remote script. You can run a remote script in the current server script;
5. Ability to add your own functionality to the system by creating modules;
6. Running scripts using a smartphone.

Script Builder

The program allows you to create a complex scenario as well as a single action.
Single Action – is a script that contains only one action. It does not have the ability to create loops and conditions, but can only "mask" a specific action to a button in the client UI.
As an example, I will give my way of using them: I created a category "Outlets", in it I collected all the lamps, household fan, lights, TV and computer. Now, in order to turn on one of these devices, you must open the client on the android, go to the category "Outlets" and select the appropriate menu item.
Usually, single actions are inconvenient to use, because it is convenient to run different devices under some condition, or at least not one at a time. This is what a "complex script" is for, as discussed further below.
Complex Scenario Builder Allows you to create scripts with loops and conditions. It has two modes: view and edit.

Example script in view mode Example scenario in edit mode
Software for the smart home
Software for the smart home

IF and UNA in the constructor In these constructs, you can create chains of conditions with the logical operators NOT, OR, AND. The constructor allows you to create a group of conditions and use operators directly with the group. If a condition is left empty, it is automatically evaluated as false.
There are some checks built in (such as checking for date, time, etc.) and some as plugins.
The BEFORE loop in the constructor The loop consists of a condition and a body. The condition is created similarly to how it is created in the IF construct (groups of conditions, operators NOT, OR, AND).

Operator IF and possible conditions Operator OKAY
Software for the smart home
Software for the smart home

Software for the smart home
The bodies IF, THEN, and SOW need to be filled with something. Actually, this content is the most important thing in the script.

Main window of the Scenario Builder
Software for the smart home

You can also configure the following script parameters :
– Run externally (on/off), allows to forbid or permit the script to be run from another machine or client;
– Starts the script automatically at system startup;
– Script category selection, allows to display a menu item in the client UI for starting a script in a certain category.

Working with ZWave and Modbus devices

Currently the system supports ZWave devices (based on openzwave) and Modbus RTU (based on nmodbus).
ZWave – is a wireless communication protocol used in home automation. Miniature low-power radio frequency modules are used to implement the protocol. Now the ZWave market offers quite an extensive list of devices, such as ZWave light bulbs, sockets, relay modules, switches, locks, temperature sensors (humidity, motion, leakage), temperature controllers, air conditioning control devices, etc. Multi-sensors – devices that combine several sensors (e.g., light sensor, presence sensor, temperature sensor, door sensor, etc.) are also common, which is very attractive in terms of financial costs and location in the room.
In my program, the ZWave module allows all standard operations with devices, such as deleting, adding devices, resetting the controller. It is also possible to use several ZWave controllers, the end user will not see the difference. For example, it is possible to take temperature readings from a sensor, which is connected to controller "A", and start air conditioner with controller "B". There are no restrictions here, any action and check is done in a standard way and added in the scenario builder.

Software for the smart home
The market for ZWave devices is quite broad. There are many actuators such as relay modules, light bulbs, air conditioning units, thermostats, floor heating controllers, sockets, switches. There are also many sensors: door opening sensor, temperature sensor, leakage sensor, presence sensor, etc. You can use a USB stick as a ZWave controller.
Software for the smart home
Main window of ZWave module
Software for the smart home
Window for controller selection and operations with it
Software for the smart home Node selection (sensors, switches, etc.)
Software for the smart home Node parameter selection (enabled/disabled, various numeric parameters such as temperature, humidity, etc.)

Modbus – is a wired protocol used for communication between electronic devices that support it. In the context of our program it can be useful to work with relay modules, which is what I use it for in my home.

Software for the smart home
Modbus relay module. Communicates with the controller via COM port
Software for the smart home Main window Modbus RTU module

Nesting scenarios

Scenario nesting is used to decompose smart home scenarios. Often there are situations where one action is involved in many scenarios (for example, turning off all household devices can be done by clicking on a menu item in the program, by the scenario of all wi-fi devices leaving the network, simply by timer), and therefore each time to create (or edit) the same algorithm in each of the scenarios is not convenient. For this, there is a built-in action that allows you to run an already created script in the current one. It can also be handy when new household devices are frequently added (or other frequent changes in the smart home algorithm), to change the operation of all the scenarios, it will be enough to change only one script that is used in them.

Action "Existing Scenario" in the list Selecting an existing scenario
Software for the smart home
Software for the smart home

Running remote scripts

By running remote scripts, you can run a script from one server to another. As an example, I would like to give you my way of using this functionality : I created a script (on my home server) called "light+multimedia" which turns on the lights in the room, runs my desktop (using WakeOnLan), turns on the TV, to which the desktop is connected and waits until it (the desktop) runs an instance of our program, then runs the "turn on music" and "sound at 20 units" scripts on it by running remote scripts

"Run remote script" in the list Selecting a server and its scenario
Software for the smart home
Software for the smart home

Writing your own modules

In addition to the fact that the user can create complex scenarios with the regular means, the program allows you to "extend" it with custom modules in C#. All elements of actions and checks in the scripts (such as "Check by date", "Show message", "Modbus action", "ZWave action", etc.) are classes inherited from ICustomAction and ICustomChecker. Following certain rules, any user can create his own module, which may be either very simple (e.g., the current temperature outside the window) or complex, behind which an entire framework may be hidden. We only need to inherit from ICustomAction or ICustomChecker interfaces, set some attributes, compile the DLL and add it to the program through the "MODULES" tab ( full instruction for creating modules).

Software for the smart home

Running scripts using a smartphone

*only OS Android for now
Scripts are displayed on the main screen and in categories. A category is a virtual "folder". When you start a script, the status of the corresponding button is updated.

Connection settings screen Screen with running scripts
Software for the smart home
Software for the smart home

In addition, it is possible to run scripts from the quick start menu on the PC.

Quick start menu
Software for the smart home

Future plans include a client for UWP, IOS, web, as well as a voice module for device control (plans for the near future) and scripting with voice (strategic plans).
Video for last :
" Program page
" Download link
" Instructions for use
" Instructions for creating your own modules
P.S.: If you find a bug in the program, please forward it to email

You may also like