An Intelligent System for Improving Energy Efficiency in Building Using Ontology and Building Automation Systems

Energy efficiency is a keyword that can be found nowadays in all domains in which energy demand exists. The steadily rising energy demand, the consequent energy scarcity and rising prices of energy resources are forcing companies and people to redefine their activities in a more energy efficient way. Besides industry and transportation, the building sector is the most important energy consumer, as a study for European countries showed that up to 40% of the total energy consumption in the EU can be ascribed to this segment. The residential use represents around 3% of the total energy consumption in the building sector (Balaras et al., 2007).


Introduction
Energy efficiency is a keyword that can be found nowadays in all domains in which energy demand exists. The steadily rising energy demand, the consequent energy scarcity and rising prices of energy resources are forcing companies and people to redefine their activities in a more energy efficient way. Besides industry and transportation, the building sector is the most important energy consumer, as a study for European countries showed that up to 40% of the total energy consumption in the EU can be ascribed to this segment. The residential use represents around 3% of the total energy consumption in the building sector (Balaras et al., 2007).
There are many technical possibilities to improve energy usage efficiency. The European Union has issued the Directive 2002/91/EC concerning the overall energy efficiency of buildings. The directive aims to improve energy efficiency by taking into account outdoor climatic and local conditions, as well as indoor climate requirements and cost-effectiveness (Cox & Fischer Boel, 2002). The most widespread energy-saving measures in buildings are conventional and are based on improved thermal insulation, energy-efficient air conditioners and appliances as well as the usage of energy saving light bulbs and smart meters. Yet there is more potential for energy saving in buildings than the abovementioned measures. Based on the directive, a new DIN V 18599 "Energetische Bewertung von Gebäuden" describing an integral calculation method for energy requirements for heating, acclimatisation and lighting has been published. Furthermore, in the future, energy savings in buildings can be increased by utilizing a building automation system. This kind of method is at least as important as the conventional thermal insulation of walls or insulating glazing for improving energy efficiency in buildings (Spelsberg, 2006a(Spelsberg, , 2006b A look at the operation of residential and commercial buildings has also shown that there is a wide range of technical possibilities to reduce energy consumption, as demanded by the European Union through the European Directive 2002/91/EC on the energy efficiency in buildings. An important aspect that can improve the energy efficiency in buildings is the use of building automation systems. However, building automation systems are usually not considered for energy conservation, as they are mostly used for comfort and safety. This often causes great problems due to an inefficient use of these systems and unawareness of energy consumption. It is therefore crucial that the existing system solutions are adapted to focus on energy conservation. This book chapter describes our research approach in developing an intelligent system to improve energy efficiency in buildings, which takes into account the different technical infrastructures of buildings, the occurring events in the buildings and the relevant environmental factors with the help of building automation systems and ontology. By using different building automation technologies, data in a variety of detail and quality could be collected. Thus, it allows the user to have an overall view of the energy consumption inside the entire building. Ontology offers the generic model for different building automation technologies and allows logical inference as well.
Modern building automation solutions for the private or commercial sector offer a great potential for the comprehensive improvement of energy efficiency. Building automation systems that are composed of computer aided networked electronic devices are mostly used for improvement of the individual quality of life, and safety. Building automation technology offers an easy way to control and monitor the building conditions. However, the existence of building automation systems does not imply an optimal usage of energy. They are predominantly applied for comfort and security reasons and do not lead to an improvement in energy consuming behaviour.
Low cost and low energy consuming building automation technologies have already been developed in recent years. Technologies such as digitalSTROM 1 and WPC 2 offer energy measurement and sensors by using small chips that consume less than 10 mW (Watteco, 2009). These chips communicate through power line communication (PLC). Therefore modifications of walls and other building structures as well as extra wiring in the building are not necessary for installation. By using these devices, extra energy consumption can be avoided. Thus, an improvement of energy efficiency can be achieved.
In this paper we proposed a framework of intelligent system for energy management in buildings by utilizing building automation systems. The framework uses a knowledgebased approach to providing an intelligent analysis based on the relations between energy consumption, activities and events in the building, building related information and surrounding factors, such as temperature and weather conditions.

State of the art and related works
The importance of the use of building automation systems in assisting energy saving in buildings, especially households, has been proven in recent years. In 2009 the Electric Power Research Institute USA conducted research about the impact of energy consumption feedback information on energy conservation levels in households. They categorized the feedback mechanism based on information availability into standard billing, enhanced billing, real-time feedback, real-time plus feedback, etc. (Neenan et al., 2009). The research showed that real-time plus feedback leads to the biggest improvement of energy conservation compared to the other feedback mechanisms, despite its higher cost of implementation. Real-time plus feedback allows users to monitor their energy consumption and/or control appliances in their home in real-time by utilizing building automation system (BAS) and home area network (HAN).
In Europe, there are several projects that aim to improve energy efficiency in buildings by using building automation technologies. Most of the projects do not have the functionality to intelligently synchronize the energy consumption with other energy consumption impacting parameters, such as temperature, occupancy or the state of the building. Some of the projecs developed knowledge based approachs to enable the intelligent analysis of the collected data. In the project IntUBE, a knowledge base containing semantic building objects, their properties and their relationships, is developed in their energy management integration platform (Madrazo et al., 2009). The knowledge base to provide an intelligent system is not only developed in energy management system for buildings. The project AmI-MoSeS develops an (ambient) intelligent monitoring system for energy consumption, dedicated to manufacturing SMEs, to provide comprehensive information about the energy efficiency and a knowledge-based decision support system for the optimisation of energy efficiency (ATB Institut für angewandte Systemtechnik Bremen GmbH et al., 2008). In these projects the knowledge bases are mostly generated manually. This prevents the system from being able to react to and solve problems accordingly by a given specific situation, since all the situation-reaction causal relations are given by a human, based only on his knowledge and experience. This might be too general.
Currently there are some research projects that investigate and develop ontology based approaches to the building automation domain. Ontology is used as the generic application model facilitating an integration of heterogeneous building automation networks. The ontology provides a single access point for configuration and maintenance tasks, as well as automatic calculation of gateway configuration data (Reinisch et al., 2008). Ontology is also used to build an expert system to control home automation devices by incorporating SWRL rules that regulate the system behaviour (Valiente-Rocha & Lozano-Tello, 2010). In requirement engineering of building automation systems, ontology provides a semantic representation of the requirements, containing possible and specific requirements and their causal dependencies. By means of the ontology, consistent requirements for an individual building automation system can be achieved (Runde et al., 2009). Ontology that allows a representation of a sophisticated model and an intelligent reasoning is used to support complex interoperation, generalization and validation tasks in the building automation environment (Bonino et al., 2008).
Ontologies represent knowledge in a particular domain. They are commonly created manually by experts in the corresponding domain. For example biology ontologies are created by biologists. However, a manual ontology creation is considered a very timeconsuming task. To overcome this problem, researchers have developed methods to generate ontology components in a semi-automatic way. Researchers from the University of Leipzig, Germany have developed a semi-automatic OWL generation from XML files by converting XSD items to ontology's classes and attributes. To perform this they developed four XSLT instances to transform XML files to OWL without any semantic and structural intervention during the transformation (Bohring & Auer, 2005). Dragan Gasevic et al. have also developed an XSLT based approach to automatically generate OWL ontology from UML. The resulting ontology still needs to be refined using ontology development tools. However, the approach helps software engineers who want to participate in ontology development without having a deep knowledge of ontology development tools. Ontology can be generated semi-automatically from a set of free text documents. It was proven by research conducted by the University of Karlsruhe, Germany in 2001 (Maedche & Staab, 2001). They developed a tool called TextToOnto 3 for semi-automatic ontology construction encompassing ontology import, extraction, pruning, refinement, and evaluation. The framework helps ontology engineers to construct ontologies.

Overview of the approach
In this paper we propose an IT framework for intelligent energy management in a building using building automation technologies. The framework considers different aspects of the building that influence the energy consumption in the building and are to be considered in the analysis of the energy consumption. The framework allows the user to have a holistic and integrated view of the energy consumption in their apartment, office, as well as in entire buildings. The building automation system offers the possibility to perform an energy consumption evaluation in different levels of detail and quality, for instance, energy consumption per appliance, per group of appliances, per zone in the building, or per user event. These evaluations are carried out by considering the relation between building elements, energy consuming appliances, surrounding circumstances such as temperature and weather conditions, as well as user events. The energy consumption can be evaluated based on activities or events that occurred in the building, for example breakfast, cooking, sleeping, work day and holiday. This kind of evaluation offers the occupants the possibility to get a view of their activity-specific energy consumption. Therefore, they can consider, whether their activities are energy-efficient enough and how can they reorganize their activities to improve the energy efficiency. The framework offers the functions for energy monitoring, energy data analysis and manual and automatic controlling of energy consuming appliances using building automation systems. Fig. 1 shows the designed functional architecture of the framework whose main modules are explained briefly in the following sub sections. We named the developed framework "SERUM-iB (Smart Energy and Resource Usage and Management in Building) Framework". The work described in this paper is part of our research project KEHL 4 .

2D-drawing interpretation module
CAD software applications that find application in construction engineering are commonly used to draw building layouts in two dimensional graphics. But unfortunately, the two dimensional drawings only contain geometric information of the objects, for instance lines, points, curves, circles, symbols, etc. They are not able to describe the semantics of the building components contained in the drawings themselves. People could still understand the semantics of the drawing, if they had the knowledge in interpreting the semantics of the symbols, shapes and other geometric information, for example symbols of doors, double lines representing walls, rectangles constructed by four double lines representing rooms, etc. We have developed a method to semi-automatically interpret the semantics of 2D-drawings to support the life-cycle management of building automation systems (Krahtov et al., 2009).
In this module we use configurable JavaScript based rules to semi-automatically interpret 2D-CAD-drawings. These rules define the relation between CAD-symbols and the semantics of building components and energy consuming appliances. The results of the 2D-drawing interpretation are stored as ontology individuals. This is explained further in section 5.
In existing energy analysis systems, users have to manually configure the system in order to perform an energy consumption analysis for each room or appliances. Another configuration mechanism is through automatic discovery of appliances. But it has the drawback that users have to manually relate the appliance to the building environment. The mechanism is dependent on a specific building automation technology as well. The interpretation of 2D-drawings helps users to configure the software framework, so they can have a model that represents their building layout with minimal effort.

Sensor data acquisition module
This module collects data from different building automation systems. Building automation technologies have different bus systems to exchange data. Most of them provide gateways to IP networks. This module contains an interface to communicate with different building automation logic control units or gateways via Simple Object Access Protocol (SOAP), which uses Extensible Markup Language (XML) for its message format and relies on Hypertext Transfer Protocol (HTTP) for message negotiation and transmission. The collected data, for instance energy consumption and the relevant sensor data such as that from the contact sensor, occupancy sensor, and weather station are converted into a uniform format and unit, for example, the energy consumptions are converted into kWh, the values from occupancy sensors are converted to true (room is occupied) and false (room is empty). These data are then aggregated and stored in a relational database.
In order to allow the visual representation of energy consumption data, we perform the necessary data pre-processing such as removing erroneous values, data transformation and data selection. The data are prepared to enable an energy consumption analysis of different criteria based on relation between rooms, appliances, time, and user events as mentioned before. This module provides data in such a form as to enable the execution of a data mining algorithm for finding the energy usage pattern.

Module for energy analysis
The energy consumption and other related data which are collected and stored in the SQL database as mass data are analysed in this module. Through this module, energy consumption can be related to device levels, room and time, which in addition, can be combined with the relation to user events and surrounding conditions. In this module we consider two methods of energy analysis, i.e. data-driven analysis and knowledge-driven analysis. Data-driven analysis means the analysis is conducted directly on the collected data by performing SQL-query, simple calculation, or visualization, for instance, energy consumption per time unit and each appliance. Knowledge-driven analysis is not conducted directly on the data, but by utilizing ontology that represents the knowledge.
The module consists of three sub-modules. They are a learning engine, a knowledge base consisting of ontology and rules and an energy analyser. The learning engine is responsible for extracting the knowledge hidden in the database. The learning engine utilizes data mining algorithms to get the association rules representing causal relations between the data. These rules are used, for example, for detecting energy usage anomalies and energy wasting. Furthermore, the rules are used to detect the activities that occur in the building based on data from different sensors, for instance, occupancy sensors, windows and door contact sensors, pressure sensors, etc. The data mining algorithms are also used for appliance classification based on their energy consumption. They are also used to detect the operation states of appliances. These functions will be explained further in section 6.
The knowledge base is the central component that provides the intelligent mechanism of the system. The knowledge base containing OWL ontology and SWRL rules is initially created by an expert. The knowledge base is then enriched with knowledge components (rules and instances), which are resulted from the 2D-Drawing Interpretation module and data mining algorithm.
The analysis module evaluates energy consumption data that were collected and aggregated by the data acquisition module, which is then presented in the presentation module. Through this module, energy consumptions can be related to device levels, room and time. In addition, they can be combined with the relation to user events and surrounding conditions.
In this module we consider two methods of energy analysis, i.e. data-driven analysis and knowledge-driven analysis. Data-driven analysis means the analysis is conducted directly on the collected data by performing SQL-query, simple calculation, or visualization, for instance energy consumption per time unit and each appliance. Knowledge-driven analysis is not conducted directly on the data, but by utilizing ontology that represents the knowledge. The ontology is created manually by an expert and enriched with ontological elements generated from the data through the ontology generation process. This is explained further in section 5 and 6.

Presentation module
This module gives the users a visual overview of their energy consumption in the building related to the building environment and their behaviour. Within the module, the energy consumption and other relevant information are presented intuitively. The energy consumptions in a building and in single rooms or for appliances are visualized via a terminal or smart client placed in the building. At the same time the configuration and control of the building automation systems can be performed within the developed GUI.

Ontology for knowledge representation
In the SERUM-iB framework we use ontology to build the knowledge base. It contains concepts representing rooms, energy consuming appliances, building automation devices, environment parameters, events and their relations. It is represented in OWL (Web Ontology Language), a W3C 5 specified knowledge representation language (Smith et al., 2004). In our work, we use the knowledge-driven analysis to find energy wasting conditions and to recognize energy usage anomalies in buildings. We also use it for identifying the operational state of an appliance, to identify appliance classes based on their energy consumption and to identify the user event or consumption behaviour based on the sensor data.
Within the SERUM-iB framework, we develop the three following methods to generate the ontology components: 1. manual ontology generation by an expert, 2. semi-automatic through interpretation of 2D-drawings, and 3. semi-automatic by data mining algorithms.
The ontological classes as well as their attributes and relations representing building automation devices, for instance sensor and energy meter, building environments such as door, window, room, are created manually by experts. The ontology containing these handcrafted elements builds the knowledge called building domain knowledge in the knowledge base. It contains only the ontological classes or Tbox components that terminologically describe the knowledge. It provides a common conceptual vocabulary of building domains. It does not contain any ontological individuals or Abox components. The building domain knowledge represents the meta model of buildings, therefore it owns the validity for all buildings. It does not contain any building instance specific information.
As occupants, we usually do not realize that our current energy usage leads to energy wasting. For instance, the light on the balcony is still on, even though the sun has already risen. In our work, we try to resolve this problem by modelling in the ontology the general situations in the building that lead to energy wasting. Thus, a computer supported reaction can be performed.
Energy wasting situations are modelled by experts in the base ontology. These situations are described in a rule representing language called SWRL (Semantic Web Rule Language). SWRL is a language combined by OWL (Web Ontology Language) and RuleML (Rule Markup Language) that enables the integration of rules in OWL ontology (Horrock et al, 2004).
Here we provide examples of modelling energy waste situation with SWRL. We assume that a smart meter attached to an appliance can give information on whether the appliance is currently in use. Rule (1) models the situation that turning the heating appliance on and opening the window located in the same room leads to energy wasting.
The ontology representing the building domain knowledge is enriched with ontological individuals or Abox components from building specific information. The individuals are created by configuring the framework based on building specific information. They are also created automatically by interpreting the 2D construction drawing of the building layout depicting building structures, such as room, floor, door, windows and contained energy consuming appliances, as well as building automation devices, for instance temperature sensors and occupancy sensors. The semantic information of building environments such as rooms, lights, and appliances is obtained from geometric data through the interpretation of 2D-drawings. The concept of 2D-drawing interpretation is further presented in section 5. The building domain knowledge is added with building specific SWRL rules. These SWRL rules are created semi-automatically from the data mining algorithm. The data mining algorithm generates the association and classification rules as the hidden knowledge that is extracted from the collection of sensor data. The rules are converted to SWRL rules and integrated into the building domain knowledge. Both processes create the new version of knowledge called building specific knowledge. Fig. 2 depicts the concept of creating building specific knowledge from building domain knowledge using 2D-drawing interpretation and the data mining algorithm.

Knowledge acquisition through interpretation of 2D construction drawings
For its correct usage, this approach requires geometric and semantic information about building layout and appliances as an initial knowledge base. Geometric information could include the exact shape and measurements of rooms in a building, their topological relations to each other (and/or to the energy appliances) as well as the position of the appliances and their dimensions. Semantic information is identification keys, names, consumption values, etc. Manually inputting this type of data, especially for large buildings or facilities, could be a time-consuming, error-prone and inefficient task. For these reasons we adopted an approach for rule-based, semi-automatic interpretation of 2D construction drawings to create the initial knowledge base.
In order for the intelligent system to improve the energy efficiency in buildings, the following domain elements are considered important: 1. Zones that describe various parts of a building like rooms, corridors, etc. 2. Zones can also be nested (i.e. apartment, floor, building), as they can comprise other zones. They have geometric information about their layout and their size as well as semantic information (names, ids etc.). Zones can be topologically connected to energy consumption devices, furniture, etc. 3. Appliances such as any electrical device or energy consumption device like heaters.

Sensors and smart meters.
A layout of a building is commonly created as a two dimensional drawing or sketch using CAD software applications, such as AutoCAD 6 . Further AutoCAD-based software tools are used to plan and model many domains of a building, such as ventilation, heating, access controls and photovoltaic (Krahtov et al., 2009). The number of elements in a sketch and its complexity may vary (Donath, 2008). Some examples of variations are the degree of the details drawn (information density Fig. 3 a, b) or their representation (representation depth Fig. 3 c, d).
The diversity of the 2D-drawings creates problems in the energy management approach described in this chapter. There are currently two open issues linked to knowledge acquisition from 2D building plans. The first issue is their overall high complexity and the lack of explicit semantics of drawn objects, due to the fact that 2D building plans are mainly used by professional designers and engineers who have the background knowledge to interpret them. The second issue is the difference in the structure of the various CADdrawings and in the representation styles used in it (Kwon et al., 2009). This high variability obstructs any attempts at an automatic interpretation of an arbitrary building plan.
To handle high complexity we need an abstraction from the unimportant elements of a building plan that would allow us to concentrate on the energy consumption-related objects of a building. For the second problem we need a semi-automatic solution that allows us to use our background knowledge about the structure and representation style of a 2D building drawing.

Fig. 3. Variety in the degree of information density and level of representation depth in 2D-CAD-drawings
We developed an approach that deals with the described issues and allows us to semiautomatically interpret 2D drawings with an abstraction level defined by the user. The workflow of the approach consists of the following steps: 1. First step is the identification of relevant entities from a 2D drawing. Those can be building elements as well as building automation devices. 2. The second step is to define a diagram for the relevant elements from step one. 3. The third step is the definition of a mapping between the visual representations in the 2D drawing and the elements of the diagram via pattern based recognition rules. 4. The fourth step is the execution of the defined recognition rules. 5. The last step is the transforming of the recognized elements to knowledge base individuals.
We implemented the approach, creating the software framework presented on Fig. 4. The framework consists of several parts (i.e. AutoCAD export function, diagram editor, interpretation rule engine, transformation utility). These framework parts aim to solve the described issues, at the same time ensuring the modularity of the approach and its extensibility. The AutoCAD export function is the first component of the developed framework. This component was needed to prepare the 2D drawings for the interpretation process. As part of it, an XML-based transfer format was developed that can be used directly in the interpretation process. This is a key feature of the interpretation because it allows the development of a generic recognition engine that works with the neutral format and that can be extended by additionally exporting modules for various CAD applications. For verification an exemplary conversion function was implemented that exports a native AutoCAD-file (.dwg format) into the defined intermediate data format. The function was developed using ObjectARX®, a programming interface provided by Autodesk. The export function allows a variable degree of detail for the exported geometric primitives.
The second part of the developed framework is the diagram editor. It is developed as an Eclipse RCP 7 program and provides an intuitive configuration process for the source domain of the interpretation framework. Via the diagram editor, the user can define all the important building parts and elements from the given 2D drawing, their semantic properties and their topological relations. They all build up a diagram also called a domain model. By the definition the user can configure the abstraction level for the interpretation process, ignoring all irrelevant drawing details. He can also define various semantic properties, which are not drawn on or not directly derivable from the 2D drawing (i.e. names and ids of the appliances, etc.). The most important part of the diagram that is defined through the editor is the interpretation rule base. These rules are defined as JavaScript routines, which can read and manipulate elements from the neutral transfer format, created by the AutoCAD export function. They describe patterns in the XML format that represent elements of the 2D construction drawing. They are based on the layers, attribute information and relations between AutoCAD primitives that build up a construction element. By defining rules and attaching them to the elements of the domain model created by the diagram editor, the user creates a mapping between the drawing elements and the elements of the domain.
The rules are used in the third major component of the interpretation framework -the interpretation rule engine. This is a Java based application that can execute the defined interpretation rules over the extracted intermediate XML data, recognizing the building elements and building automation appliances. For the execution of the rules we use the Rhino 8 framework, which is an open-source implementation of JavaScript for Java and enables the end user to use scripts inside of Java applications.
The last part of the interpretation framework is the transformation service. It is used subsequently after the end of the interpretation process, to transform the recognized elements into ontology individuals, creating the initial state of the knowledge base. The transformation service provides a configurable mapping of recognized building elements, building automation or other electronic elements to zones, appliances or sensors and smart meters.
The following models participate in the interpretation process: 1. The domain model for information about the environment, defined by the knowledge experts familiar with the application domain and the specifics of the given 2D drawing. The domain model is the diagram for the recognition process and is defined through the diagram editor. 2. The logical model is the instance of the domain model, created via the recognition process. It represents an abstraction of the 2D drawing. 3. The knowledge model is generated from the logical model through the transformation service.
The described approach for interpretation of two-dimensional building drawings successfully handles the issues that were presented earlier in this book chapter, providing the following benefits in context of the knowledge acquisition for the creation of an initial knowledge data base: 1. No manual input of geometric and topological information should be done.
The building-related information as well as the appliance positions and their topological relations to the environment or to each other are provided by the interpretation process. 2. User defined level of abstraction is guaranteed. All unnecessary elements of a two dimensional drawing can be ignored. 3. The approach provides flexibility in both dimensions of types and attributes. That means that new energy appliances (new building automation or household devices) that haven't been considered yet can easily be defined and integrated into an existing energy efficiency system.

Knowledge generation through data mining algorithm
In our work, data mining algorithms are used to identify energy consumption patterns and their dependencies. Data mining is defined as the entire method-based computer application process with the purpose to extract hidden knowledge from data (Kantardzic, 2003). In the SERUM-iB framework we used different data mining procedures to generate knowledge for recognition of energy usage anomalies, determining classification of appliances based on their energy consumption, and identifying operation states of an appliance based on energy usage. We illustrate these procedures in the following sub sections.

Recognition of energy usage anomalies
In this work, we relate the energy consumption with the occupant's behavioural pattern in the building. We aim to recognize energy consumptions that do not occur normally in the building. To perform this task, we have to know how energies are consumed normally regarding occupant events and surroundings. For example, normally when an occupant is sleeping and the outside temperature is comfortable, let us say greater than 20 degrees Celsius, total energy consumption in the building is low, for instance lower than 10 kWh. If in the same pre condition total energy consumption in building is more than 10 kWh, then it is considered a usage anomaly.
It is difficult for users if they always have to log their activities. In our work we use simple sensors to automatically recognize user activities. Simple sensors can provide important hints about user activity. For instance, an occupancy sensor in a kitchen can strongly give a clue whether somebody is currently cooking. Of course it should be combined with information of appliance states in the kitchen. The method for automatic recognition of user activity is explained in section 6.2.
The rules representing normal energy consumptions are obtained through a data mining classification rules algorithm. The algorithm is based on a divide-and-conquer approach. The created rule (2) shows the probability of 67% of how often it could happen if the event is sleeping while outside temperature is greater than 20 degree with total energy consumption is lower than 10. This value is called confidence. The rules described in (2) represent a condition that normally occurs. The rule is transformed to (3), in order to represent an anomaly condition, by negating the consequent part of the rule.
The rules created by the data mining algorithm are stored in ontology as SWRL. SWRL rule (4) represents the transformed rule (3), which is stored in ontology.
The rules resulting from the data mining algorithm do not always have 100% confidence. Therefore we represent the rules as SWRL in order to enable verification by using a rule editor provided in the Presentation Module or using a SWRL editor such as Protégé. The editor enables users to add, modify and delete the resulted rules. Fig. 5 illustrates the whole process to enrich the knowledge base with SWRL rules coming from data mining to recognize the energy usage anomalies.

Recognition of user activities in the building
In our work, we use occupancy sensors, window contact sensors, door contact sensors, as well as energy meter to collect the data that will be used to recognize user activities in a building. An energy meter attached to an appliance can give a clue as to the appliance's state. It means we can get the information, for example whether the appliance is on or off. The data from these different sensors are collected and stored in database. Similar to the process for recognizing energy usage anomalies, the data mining algorithm is executed on the data. The algorithm generates rules that it uses to recognize the user activities. Fig. 6 depicts the whole process to generate these rules and store them in a knowledge base. The simplified rule (5) is an example of a rule used to recognize the user activity "Holiday" based on the data depicted in Fig. 5.

Determining classification of appliances
Classification is the process of finding a set of models or functions that describe and distinguish data classes or concepts for the purpose of being able to use the model to predict the class of objects whose attribute is unknown (Han & Kamber, 2001). The model is based on the analysis of a set of training data, i.e. data objects whose attribute is known.
In our work, appliances are classified based on their energy consumption by using classification algorithms, for instance Naive Bayes. Such a grouping determines which devices consume more energy or if a household appliance works properly due to its energy demand. The grouping even allows the occupants to understand which of their activities need more energy. The resulted classes are transformed into ontological individuals of class Energy_Cosumption_Class. A relation is_member_of is added. It relates instances of appliance classes created by the interpretation of 2D-drawings module and corresponding instances of class Energy_Consumption_Class.

Generating knowledge to identify operation states of appliances
In many cases an appliance consumes energy differently depending on its operational states. We are often not able to determine in which state our appliances consume more energy. Therefore we cannot react respectively, for example, to reduce or even to avoid using appliances operating modes that consume more energy.
We use cluster analysis algorithms to recognize operation states of appliances, for instance, a washing machine has the operation states standby, water heating, washing and dryspinning. A clustering algorithm analyses and puts data objects in certain clusters so that objects have high similarity to the others within a cluster but dissimilarity in comparison to objects in other clusters. In our case, we measure the similarity of energy consumption of an appliance. Fig. 7 shows the approach to generate the knowledge to identify operation states of appliances using data mining algorithm.

Intelligent analysis through ontology processing
In the knowledge base represented in ontology, all conditions of energy wasting and anomalies are represented as SWRL. Periodically the data acquisition module requests real-time data from a building automation gateway. These data contain states of all the installed building automation devices. SWRL rules are used to decide whether these incoming data correspond to an energy waste or usage anomaly condition. We develop a rule engine based on SWRLJessBridge to support the execution of SWRL rules combined with Protégé API that provides functionality in managing OWL ontology.
First the attribute values of relevant ontological instance are set to values corresponding to incoming data. For example, if contact sensor attached to window gives a state "Open" then the attribute hasState of the corresponding ontology instance of concept ContactSensor is set to "Open". After that the rule engine executes the SWRL rules and automatically assigns individuals to the ontology classes defined in the rule's consequent. For example for rule (1) the instance of concept Heater is additionally assigned to EnergyWaste class and for rule (4) the instance of class UserActivity to class UsageAnomaly. SPARQL (SPARQL Protocol and RDF Query Language) is used to evaluate whether energy wasting conditions or energy usage anomalies occurs. Which appliances cause the energy wastage can be retrieved as well. It is performed by querying all the individuals of EnergyWaste or UsageAnomaly class. If individuals of these classes are found, a predefined automatic notification to the user such as sending an SMS, email or visually on the GUI can be performed. With this mechanism, the user can react more quickly in order to avoid more energy wasting. SPARQL is also used to get appliances belonging to a certain energy consumption class. The SPARQL processing is implemented in analysis module.

Conclusion
In this paper we have presented a system of comprehensive intelligent energy analysis in buildings. In the developed system, we combined classical data-driven energy analysis with novel knowledge-driven energy analysis that is supported by ontology. The analysis is performed on information collected from building automation devices. The ontology supported analysis approach provides intelligent assistance to improve energy efficiency in households, by intensively considering individual user behaviour and current states in the building. Users do not have to read the whole energy consumption data or energy usage profile curves in order to understand their energy usage pattern. The system will understand the energy usage pattern, and notify user when energy inefficient conditions occur.
We have also presented the methods to semi-automatically generate ontological components i.e. individuals and rules, in building automation domains through the interpretation of 2Ddrawing and data mining approaches. The approaches can reduce the ontology generation process, since the manual ontology components creation process is very time-consuming. However, the base ontology representing terminological knowledge in building automation is created manually.
The approach described in this paper can be adopted in more complex systems such as production systems by integrating the base ontology with other ontologies in production system domains. Additional relative ontological components representing knowledge in production systems, for example product, production tasks, machine related information should be created.