# Context-Aware Wireless Sensor Networks for Smart Building Energy Management System
## 4 Proposed EMS for SEEB
### Context Recognition Using the Context-Based Reasoning Model  
In SEEB, the execution of energy policy rules depends on context recognition. The context is the knowledge about the undergoing situation/scenario of a given location at a specific moment of the building (Figure 10). In this case, we used the Context-Based Reasoning (CBR) model to model the university campus's buildings for better context recognition. The context recognition is based on the declared knowledge about the building using two types of parameters. One type of parameter is dynamic parameters generated by the WSN data acquisition, namely temperature, motion, humidity, and occupancy. The other parameters are static parameters that describe the building type, room type, season, current day, and part of the day. These parameters are fetched from the database of the EMS. The context identification results are input parameters to the appropriate control decision, which is implemented using Fini  
Figure 10: Knowledge types used in enabling and disabling the heating process. Figure 9: RSSI value between sensor nodes and gateway. that basically enables or disables the heater. The control algorithm and its structure are guided by the energy policy set by the building manager. When designing services for a building, the HVAC system, for example, we need to identify the set of contexts, transition rules, dependencies, and the relationship between contexts. We can also describe contexts as adjustable filters that generate different types of knowledge. This concept of context can provide a model to decompose a complex system into interconnected \"scenarios\", where knowledge that can be inferred using static and dynamic parameters is of the following types:  
* **Action knowledge**: This knowledge represents the operational intelligence for a specific situation. It can be coded with logic rules or learned using machine learning, evolutionary algorithms, etc. In our case, the system needs to switch the heaters of the building ON or OFF. * **Transitional knowledge**: It states when a transition to another context is needed. This transition can be expressed as \"IF-Then\" transition rules or any other type of triggering mechanism. * **Declarative knowledge**: This knowledge describes some aspects of the context to include some of the pre-acquired experience for the context--for example, the number of inhabitants, room size, or room usage schedule. The Context-Based Reasoning Model partitions knowledge into a multi-level hierarchy representing a vertical relationship between groups in a set \(G=\{G_{1},\ \ldots,\ G_{n}\}\), where a given group \(G_{i}\in G\) contains a set of mutually exclusive contexts \(C_{i}=\{C_{0^{i}}^{i},\ \ldots,\ \ C_{0}^{n}\}\). An active context \(C_{a}^{i}\) in \(G_{i}\) is active within the context of its parents; which makes it inherently functional, transitional, and declarative knowledge from the hierarchy above \(G_{i-1}\). Based on the CBR model, we developed a set of groups. Each group contains one type of entity, for example, building types, room types, seasons, etc. This information represents the static type of knowledge needed to infer the context. This static knowledge can be drawn by selecting an element from each group following the order from \(G_{1}\) to \(G_{5}\) (Figure 11). The values obtained from both the database and the WSN data acquisition deem as input parameters to the controller to decide whether to enable the heating process. First, the declared knowledge, which can be drawn by selecting an element from each group, is obtained. Hence, the number of contexts varies based on building types, room type, etc. For instance, in the administrative building, there are three active contexts (depending on the room type) at each moment among the 144 possible ones in all-time (\(1\times 3\times 4\times 4\times 3=144\)). In the educational building, there are four possible contexts (depending on the room type) at each moment among the 192 possible scenarios in all-time (\(1\times 4\times 4\times 4\times 3=192\)).