You are on page 1of 6

Available online at www.sciencedirect.

com

ScienceDirect
IFAC-PapersOnLine 49-25 (2016) 431436

Development of Software Tool for Operational and Technical Functions Control


in the Smart Home with KNX technology
Jan Vanus, Jana Belesova, Radek Martinek, Petr Bilik, Jan Zidek, Ludvik Koval
Faculty of Electrical Engineering and Computer Science,
VSB-Technical University of Ostrava,
17 Listopadu 15, Ostrava 70833 Czech Republic,
(e-mail: jan.vanus@vsb.cz, jana.belesova.st@vsb.cz,
radek.martinek@vsb.cz, petr.bilik@vsb.cz, jan.zidek@vsb.cz, ludvik.koval@vsb.cz)

Abstract: This paper deals with the design and implementation of visualization monitoring application
for controlling operational and technical functions in the Smart Home, equipped with KNX bus system.
The practical part analyzes the implementation of desktop application of Universal Windows Platform
type for Windows 10. It describes communication of the application with the KNX bus system, the use of
MVVM (Model, View a ViewModel) architecture and application customizing for mobile phones.
2016, IFAC (International Federation of Automatic Control) Hosting by Elsevier Ltd. All rights reserved.
Keywords: Smart Home; Control; Visualization; Monitoring; Universal Windows Platform; KNX.

people activities behavior in the Smart Buildings (Vanus,


1. INTRODUCTION
2015a).
Currently, the demand for smart applications to control the
The aim of the work is to create an application to control
operating and technical functions in intelligent buildings is
functions of intelligent buildings equipped with KNX bus
ever-growing. It also represents a part of the market with
system, executable on desktop operating systems. The
great potential for the future. Seo (2016) proposes a hybrid
implementation itself offers a number of options of
reality - based user experience and evaluation of a context-
conceiving the application creation, both in terms of the
aware smart home with the user experiences by the
target operating system and selected development
integration of egocentric virtual reality and exocentric
technology. In the local market for desktop equipment, there
augmented reality. Brumbulli (2016) introduced a model-
are several major operating systems. In the Czech Republic
driven approach for the analysis of IoT applications via
but also worldwide, the most popular platform is Windows.
simulation in an integrated development environment for
A very small percentage of the total share belongs to OS X
rapid and automated analysis in Smart Objects. Synnot
and Linux operating systems. In August 2015, the most
(2015) provides a review of existing approaches for the
widespread system was Windows 7. Windows 10, which was
generation of simulated smart home activity datasets,
officially released in August 2015, had already more than
including model-based approaches and interactive approaches
eight percent share of the market for operating systems (Tab.
which implement virtual sensors, environments and avatars.
1).
Lee (2015) presents Persim 3D-an alternative context-driven
approach to simulating human activities capable of Tab. 1: Market share of operating systems in August 2015
supporting complex activity scenarios for automated
OS Win 7 Win 8.1 Win XP Win 10 OS X other
understanding and recognition of human activities and
behaviors in a smart space (e.g., smart house). Bonino (2014) Representation on 52.57% 15.76% 9.63% 8.31% 3.85% 9.88%
provides an overview of the roles played by semantic the Market
technologies in the domain of smart grids and smart
In February 2016, the second most popular system became
environments, with a particular focus on changes brought by
Windows 10 with nearly twenty percent of the market share
such technologies in the adopted architectures, programming
(Tab. 2).
techniques and tools. Vanus (2014a) describes the analysis,
development and implementation (Vanus, 2014b) of the Tab. 2: Market share of operating systems in August in
software environment used for communication between the February 2016
user and the control center and to processes data during
OS Win7 Win8.1 Win XP Win 10 OS X other
visualization application environment creation to achieve
comfortable control intelligent (smart) buildings with wirelles Representation on 46.19% 19.91% 12.76% 7.38% 4.57% 9.19%
technology with possibility of voice control (Vanus, 2010), the Market
(Vanus, 2011) of operational and technological functions
(Vanus, 2013), (Vanus, 2015b). In this area is possible using Due to its high presence in the market for operating systems,
a new SW tools or using of commercial SW products too, e.g. Windows is also the most attractive system for application
for energy management (Dvorak, 2014) and monitoring of developers. There are a multitude of platforms which can be
2405-8963 2016, IFAC (International Federation of Automatic Control) Hosting by Elsevier Ltd. All rights reserved.
Peer review under responsibility of International Federation of Automatic Control.
10.1016/j.ifacol.2016.12.088
432 Jan Vanus et al. / IFAC-PapersOnLine 49-25 (2016) 431436

used in development for this operating system (Java, Python, The controls are depicted based on the configuration (Fig. 2)
C++); however, creation of applications for Windows is which will be described later. In the case of lighting, the
mostly connected with platform .Net and programming lights can be switched on and off. It is also possible to change
language C#. their brightness using buttons for dimming. As for
furnishings of sunblind type, the screen depicts a control
For using the .Net framework, there are several available which may include several functions. Another important
types of applications that can be created in the Windows screen serves for setting the application. Here, the users can
environment. These are Windows Forms, Windows adjust some application parameters in order to adapt it to
Presentation Foundation, Windows Store applications and their individual needs.
Windows Universal Platform. Applications of Windows
Forms and Windows Presentation Foundation type can run on It is possible to set the language (Czech or English).
any of the above versions of Windows system with a Furthermore, the users can choose from two color schemes,
compatible version of .Net Framework. Windows Store light and dark. The last setting allows them to change the font
applications are developed for Windows 8 and 8.1 and cannot size; this facilitates the work with the application mostly for
run on other versions of the system. Windows 10 introduced seniors. There are three font sizes to choose from small,
Universal Windows Platform enabling the creation of medium and large.
applications compatible with all versions of Windows 10.
Applications are executable on desktop devices, mobile
phones, tablets or IoT devices. This type of universal
application cannot run on earlier versions of the system.
Windows 10 should be the final / last version of Windows
system, which should be further only updated. According to
the statistical data above, it is possible to deduce that the
demand for Windows 10 will continue to rise, even on the
grounds that the transition to this system version is offered
for free.

2. PRACTICAL IMPLEMENTATION the solution


The practical implementation is dedicated to developing
application Hestia 9 which allows the control of operating
and technical functions in the Smart Home fitted with KNX
bus system. The application supports voice control and a few
settings of user environment. Universal Windows Platform
technology and C# programming language were selected to
develop the application. The implementation was based on Fig. 2. Configuration preview
the MVVM (Model, View a ViewModel) architectural A prerequisite for the proper functioning of the application is
pattern which is briefly described below. configuration. It runs on a separate screen which can be
accessed from the application settings. For the purpose of
Application description better clarity, a list of rooms in the building is created in the
first instance. A list of devices for each room is created
Application Hestia consists of several screens. For users, the afterwards. When creating devices, it is necessary to select
most important screen is that with controls; this screen the device type and enter at least one group address of some
contains a list of rooms and visualizes individual pre- of the possible functions. Configuration should be performed
configured devices / appliances (Fig. 1). by a person familiar with the KNX bus system and specific
bus programming. It is necessary to know individual group
addresses and device types occurring in the topology.
Without this knowledge, it is not possible to provide control
functionality.
The application consists of several components (Fig. 3); the
basic components are Hestia.View, Hestia.Model and
Hestia.ViewModel, forming the frame of the MVVM
architectural pattern. This is described hereinafter. Another
component is KNXLib.Portable. It is a freely available
library for communication with the KNX bus. Hestia.Speech
provides voice recognition logic and passes the information
further in the application. Hestia. Common is a shared
component that contains global variables and methods used
across the application.
Fig. 1. Control screen preview
Jan Vanus et al. / IFAC-PapersOnLine 49-25 (2016) 431436 433

The View layer represents the user interface. The language


used is XAML. The Model part presents data with which the
application works. The ViewModel connects Model and
View parts, captures the current state of the application and
provides logic of individual Views.

Model

As already mentioned, the Model part represents the


application data layer. In this case, the Model consists of
classes Room, Device, AdressType and
FunctionType, and classes for their loading from XML
file (Fig. 5). XML serialization is used for the entire structure
storage. Tag [XmlRoot("NazevTridy")] is inserted
before the class names and
Fig. 3. Diagram of components
[XmlElement("NazevProperty")] or
[XmlAtribut("NazevProperty")] before each
Universal Windows Platfom property. After calling the appropriate method for storing, it
is possible to create XML file which contains the individual
Windows 8 contained a new architecture of applications, objects and their property in the form of xml tags as defined
Windows Runtime (WinRT), which is also part of Windows in the classes. Class Room represents rooms in the building
Phone 8.1. It enabled the development of universal and contains the name, Id and list of individual devices. Class
applications for Windows 8 using shared code. Windows 10 Device represents individual devices and contains the Id,
introduced Universal Windows Platform whose kernel is name, device category, list of group addresses for various
based on WinRT and thus provides a common platform functions of devices and id of the room into which the device
available on all devices with Windows 10. The application belongs. AddressType represents a group address of the
can use APIs common to all devices but also APIs that are device and consists of the address and Id of the respective
specific for the device on which the application runs. FunctionType. Class FunctionType distinguishes the
Therefore, it is enough to create just one installation package group address functions and consists of the Id, name, DPT
that can run on any device with Windows 10. A prerequisite and device category. The Id of this object corresponds to
for the development of universal applications is operating
FunctionTypeCategory enumeration.
system Windows 10 and development environment Visual
Studio 2015 with a package for the development of universal
applications Universal Windows App Development Tools.
Furthermore, the system must be switched to the
development mode otherwise the application cannot run on
the device and be tested. When using operating systems
Windows 7 or Windows 8.1, it is not possible to run the
applications locally but only through a remote device with
Windows 10.

MVVM

MVVM is an architectural pattern that is used to separate the Fig. 5. Database model
user interface from the application logic. It consists of three
In addition to the above-mentioned classes, storing and
logically separated parts Model, View and ViewModel
retrieving data from XML file, the Model part includes class
(Fig. 4).
DataContext. This class provides ViewModels with
access to the list of devices and rooms. If some of
ViewModels requests data provided by DataContext,
the data are retrieved from the XML file and any changes are
then made only in DataContext. Permanent storage will
be done only upon the user request.

ViewModel

The ViewModel acts as a link between the View and Model


parts. It cooperates with the Model so that it calls its methods
and provides the data retrieved to the View part in a form that
Obr. 4. MVVM architecture
434 Jan Vanus et al. / IFAC-PapersOnLine 49-25 (2016) 431436

the View can easily process. It also contains commands View


invoked in the View part by the user. For example, if the user
clicks a button in the View, a method is called in the Views are individual screens of the user interface. They
ViewModel. The ViewModel informs the View about represent the presentation layer of the application and are
changes by PropertyChanged event from created using XAML language. All logic is performed in the
INotifyPropertyChanged interface. Implementation of the ViewModel (Listing 3); in each View, the ViewModel is
interface is described in the listing below (Listing 1). In case defined in Page.DataContext element.
of changes in a ViewModel property whose value is
displayed in the View, the ViewModel informs about this
change by invoking a PropertyChanged event and data <Page.DataContext>
displayed in the View are renewed automatically. <ViemModel:ConfigurationViewModel/>
public class </Page.DataContext>
INotifyBase:INotifyPropertyChanged
{ Listing 3: Definition of the ViewModel used
public event PropertyChangedEventHandler To assign the above-described action to a particular button,
PropertyChanged;
the attribute Command="Binding AddRoomCommand"
public void
is added to the Button element. ItemsSource attribute is
RaisePropertyChanged([CallerMemberName]
string propertyName used after loading collections defined in the ViewModel.
= null) Collection from the ViewModel is defined behind the key
{ word Binding and is used to fill the listing. The
if (PropertyChanged != null) SelectedItem attribute must contain the name of property
{ from the ViewModel, representing the actually selected
PropertyChanged(this, new element form the collection (Listing 4). Setting the Mode
PropertyChangedEventArgs(propertyName) attribute to TwoWay value causes changes in the target as
); well as source property.
}
} <ListBox x:Name="listRooms"
} HorizontalAlignment="Left" Height="181"
Margin="
Listing 1: Implementation of the 43,50,0,0" VerticalAlignment="Top"
INotifyPropertyChanged interface. Width="233" ItemsSource="{Binding Rooms}
" SelectedItem="{Binding SelectedRoom,
Class ObservableCollection is used in case of Mode=TwoWay}" DisplayMemberPath="
collections; this class automatically informs about changes. Name"/>
Adding an element to or removing an element from the
collection invokes CollectionChanged event. Elements Listing 4: The use of ItemsSource and SelectedItem
in the collection must implement the attributes.
INotifyPropertyChanged interface. In the
The application includes a total of five main View screens.
ViewModel, it is also possible to react to user actions
MainView screen is the main application template; it
performed in the View, such as push-button operations. This
contains a navigation bar with buttons for switching between
is enabled by using the ICommand interface. To simplify the various application screens. These are displayed in the
work, this interface is implemented in class remaining part of the MainView screen. ControlView
ICommandBase and the use is described below (Listing 2). screen is used to display rooms and the respective assigned
devices, and contains controls for interacting with the
intelligent building. ConfigurationView screen displays
AddRoomCommand = new the interface for entering the configuration of rooms and
ICommandBase(AddRoom); devices. SettingsView screen allows individual
public void AddRoom(object parametr) configuration of the application user environment.
{ HelpView screen provides a quick reference for application
DatabaseContext.Rooms.Add(new Room(true)
control.
{ Name = NewRoom.Name });
}
IValueConvertor
Listing 2: The use of ICommand interface
When designing the application appearance, it may be
necessary to view some parts only under certain conditions.
In case of Hestia application, this situation occurs in the
ConfigurationView screen where fields according to
the device type are displayed in the list of already configured
Jan Vanus et al. / IFAC-PapersOnLine 49-25 (2016) 431436 435

devices. In case of lighting devices, the list only shows the It is possible to use two methods of connection to the bus -
fields for editing the addresses of sunblind functions. In case KNX IP tunnelling and KNX IP routing. KNX IP tunnelling
of devices of sunblind type, the list only shows the fields for enables communication between one external device and the
editing the addresses for controlling the blinds. This can be KNX bus (unicast). This is similar to connection via USB or
achieved by implementing the IValueConvertor serial interface. KNX IP routing uses a multicast address to
interface (Listing 5). It contains two methods, Convert and which telegrams are sent. Multicast address 224.0.23.12 is
ConvertBack. The Convert method, based on the input reserved for the KNX association. Various KNX devices
value (i.e. device type), returns the corresponding listen to this address and eventually perform their specified
Visibility enumeration. In this case, the requirements. To communicate with the KNX bus in the .Net
ConvertBack method is meaningless and may not be framework, it is possible to use Falcon SDK which is
implemented. provided directly by the KNX association. However, this
library cannot be used in case of UWP development.
public class Therefore, another solution has been chosen
CategoryToVisibilityLightsConverter : KNXLib.Portable library. This library is designed
IValueConverter specifically for use in the UWP development. The library
allows connection to and disconnection from the bus, as well
{ as sending actions on the bus. Connection to the bus takes
public object Convert(object value, Type
place when switching on the application; on the contrary, it is
targetType, object parameter,
necessary to disconnect the application from the bus when
string language)
closing the application. Telegrams are sent on the bus using
{
the Action method,
return ((int)value ==
(int)DeviceCategory.Lights) ? Visibility. Parameter with the group address and parameter with data to
Visible : Visibility.Collapsed; be sent on the bus are transmitted to the method. For
} example, Boolean value of true is sent to the group address
} for lighting control when switching on the lights (Listing 7).
Listing 5: IValueConvertor implementation GlobalContext.KNX.Action(lDevice.LightsOnOffAddress,
CategoryToVisibilityLightsConverter class true);
can then easily be used directly in the Listing 7: Switching on the lights
ConfigurationView screen. Attribute of the
Visibility element, which is to be displayed according In addition to the Boolean data type, in the parameter for
to the device type, is set using the Converter. It receives data, it is also possible to send byte on the bus or use already
information about the device type from element pre-defined data types (DPTs) in the library, which
cmbSelectedCategory. LightsVisibility is a correspond to the official definition of the KNX association.
static source representing DPTs are used to convert the values from the input interval
CategoryToVisibilityLightsConverter class into data that can be processed by the bus.
(Listing 6).

<Grid x:Name="gridLights" Grid.Column="2"


Visibility="{Binding ElementName=
cmbSelectedCategory, Path=SelectedIndex,
Converter={StaticResource
LightsVisibility}}">

Listing 6: The use of CategoryToVisibilityLightsConverter


class

3. Communication with the KNX bus


To communicate with the KNX bus, it is necessary to connect
KNXnet/IP router to the bus; the router allows sending Fig. 6. Laboratory test site implementation of the designed
information between the device and the bus using the IP SW tool Hestia to control individual KNX modules.
protocol. In the case of wireless communication, the
KNXnet/IP router must be connected to a wireless router and 6. CONCLUSIONS
the device (computer, mobile phone) used for requesting the
communication with the bus must be connected to the same This paper describes the design and development of the
network as the KNXnet/IP router. application for controlling the operation-technical functions
in an intelligent building equipped with the KNX bus system.
436 Jan Vanus et al. / IFAC-PapersOnLine 49-25 (2016) 431436

The result is a universal application for Windows 10, which Vanus, J., Kucera, P. & Koziorek, J. (2014b) Visualization
can run on a desktop version of the Windows 10 operating Software Designed to Control Operational and
system. Technical Functions in Smart Homes, in Silhavy, R.,
Senkerik, R., Oplatkova, Z. K., Silhavy, P. &
The work describes the use of MVVM architectural pattern Prokopova, Z. (eds), Modern Trends and Techniques in
for UWP development (Universal Window Platform). The Computer Science. Advances in Intelligent Systems and
application includes several settings that facilitate the work Computing, 559-569.
with the application not only for seniors but also for other Vanus, J., Koziorek, J. & Hercik, R. (2013) The Design of the
residents of the Smart Home. Application functionality was Voice Communication in Smart Home Care.
verified using a simulation panel with KNX components Fig. Vanus, J., Martinek, R., Bilik, P., Koziorek, J. & Dracka, A.
6), in testing the control of lights and sun blinds. Compared (2015a) Smart Home Remote Monitoring Using PI
to other works dealing with the creation of environment for System Management Tools. Proceedings of the 8th
controlling intelligent buildings, the resulting application is International Scientific Symposium on Electrical Power
configurable and is therefore applicable to any building Engineering (Elektroenergetika 2015), 384-387.
equipped with KNX bus system. The application could be Vanus, J., Smolon, M., Martinek, R., Koziorek, J., Zidek, J.
further extended in order to visualize the status of controlled & Bilik, P. (2015b) Testing of the voice communication
devices. It would also be possible to implement complex in smart home care. Human-Centric Computing and
commands (e.g. to draw the sun blinds and then switch on the Information Sciences, 5.
lights in the room) or scheduled tasks (e.g. to draw all the sun Vanus, J. & Styskala, V. (2010) Application of optimal
blinds for 17 hours). Another extension could be a link with settings of the LMS adaptive filter for speech signal
cloud storage for storing the current configuration and processing, Proceedings of the International
implementation of logging into the application. This would Multiconference on Computer Science and Information
simplify the application configuration which would take Technology, IMCSIT 2010.
place only once and the application could run with the same Vanus, J. & Styskala, V. (2011) Application of variations of
configuration from more devices. the LMS adaptive filter for voice communications with
ACKNOWLEDGMENT control system. Tehnicki Vjesnik, 18(4), 555-580.
Dvorak, J., Berger, O. & Krejcar, O. (2014) Universal
This paper has been elaborated within the framework of the Central Control of Home Appliances as an Expanding
project SP2016/146 of the Student Grant System, VSB-TU Element of the Smart Home Concepts - Case Study on
Ostrava, Czech Republic. Low Cost Smart Solution, in Saeed, K. & Snasel, V.
(eds), Computer Information Systems and Industrial
REFERENCES Management, Cisim 2014. Lecture Notes in Computer
Science. Berlin: Springer-Verlag Berlin, 479-488.
Bonino, D. & Procaccianti, G. (2014) Exploiting semantic
technologies in smart environments and grids: Emerging
roles and case studies. Science of Computer
Programming, 95, 112-134.
Brumbulli, M. & Gaudin, E. (2016) Towards Model-Driven
Simulation of the Internet of Things, in Cardin, M. A.,
Fong, S. H., Krob, D., Lui, P. C. & Tan, Y. H. (eds),
Complex Systems Design & Management Asia: Smart
Nations - Sustaining and Designing, Csd&M Asia 2016.
Advances in Intelligent Systems and Computing, 17-29.
Lee, J. W., Cho, S., Liu, S., Cho, K. & Helal, S. (2015)
Persim 3D: Context-Driven Simulation and Modeling of
Human Activities in Smart Spaces. Ieee Transactions on
Automation Science and Engineering, 12(4), 1243-1256.
Seo, D. W., Kim, H., Kim, J. S. & Lee, J. Y. (2016) Hybrid
reality-based user experience and evaluation of a
context-aware smart home. Computers in Industry, 76,
11-23.
Synnott, J., Nugent, C. & Jeffers, P. (2015) Simulation of
Smart Home Activity Datasets. Sensors, 15(6), 14162-
14179.
Vanus, J., Kucera, P. & Koziorek, J. (2014a) The Software
Analysis Used for Visualization of Technical Functions
Control in Smart Home Care, in Silhavy, R., Senkerik,
R., Oplatkova, Z. K., Silhavy, P. & Prokopova, Z. (eds),
Modern Trends and Techniques in Computer Science.
Advances in Intelligent Systems and Computing, 549-
558.

You might also like