A Residential House Comparative Case Study Using Market Available Smart Plugs and EnAPlugs with Shared Knowledge

Smart home devices currently available on the market can be used for remote monitoring and control. Energy management systems can take advantage of this and deploy solutions that can be implemented in our homes. One of the big enablers is smart plugs that allow the control of electrical resources while providing a retrofitting solution, hence avoiding the need for replacing the electrical devices. However, current so-called smart plugs lack the ability to understand the environment they are in, or the electrical appliance/resource they are controlling. This paper applies environment awareness smart plugs (EnAPlugs) able to provide enough data for energy management systems or act on its own, via a multi-agent approach. A case study is presented, which shows the application of the proposed approach in a house where 17 EnAPlugs are deployed. Results show the ability to shared knowledge and perform individual resource optimizations. This paper evidences that by integrating artificial intelligence on devices, energy advantages can be observed and used in favor of users, providing comfort and savings.


Introduction
The first mention of the smart plug in the news dates the year of 2008, reporting a solution able to remotely control a plug.Since then, a massive penetration of smart plugs and smart home devices have been introduced on the market.In the United States alone, in 2018, predictions point to 41.2 million smart home devices [1].Moreover, according to Statista, by 2022 there will be 216.9 million homes worldwide with at least one smart home device [2].The use of smart plugs enables retrofitting and the automation of our electrical resources.Therefore, scientific publications report case studies where smart plugs are combined with energy management systems [3][4][5].In these cases, the smart plugs are used as actuators.
Smart plugs enhanced innovation and have opened the door to new possibilities, such as remote-control using energy management systems.Reference [6] explored the possibilities of integrating smart plugs for programmable control using the message queuing telemetry transport (MQTT) with local and remote control.In Reference [7], a smart plug for energy management is proposed where the controllable resource is manually identified.In Reference [8], a centralized energy management system is proposed using smart plugs data.However, they all lack intelligence and awareness.In Reference [9], a smart plug for classification is presented.However, it lacks peer-to-peer collaboration and energy management.
Smart plugs can control an electrical resource, but it knows nothing about it, which poses a problem.This paper will apply environmental awareness smart plug (EnAPlug) [10] that is able

Available Smart Plugs on the Market
There is a vast variety of smart plugs available on the market, which can be aggregated into two groups; with and without monitoring.For the purposes of this paper, only smart plugs with monitoring are considered and analyzed.The smart ability of these smart plugs is the simple capability of providing remote control.Beside their misleading name, they are not very smart.
Table 1 shows a set of relevant smart plugs available on today's market, focusing on the electric specs as well as multiplatform communication and usage functionalities.All information of Table 1 was completed using official manufacturers' websites, manuals, and datasheets, if available.This market smart plugs survey helps to better understand the current market state of the art and provides a better insight into capabilities as well as limitations.
Fifty smart plugs were analyzed; Table 1 shows the six more relevant examples of multiple smart plugs types.From those examples, only D-Link DSP-W215 and iSocket Environment Pro allow type E and type F sockets used in their full range-allowing 16 A loads.The most common communication protocol is IEEE 801.11, taking advantages of Wi-Fi routers.Other examples can be found using Z-Wave, Bluetooth, or the Global System for Mobile (GSM) communication.However, those who do not use IEEE 801.11 usually demand the need for a hub.For solutions using IEEE 801.11, the hub is the building's access point.
iSocket is the only smart plug that enables the direct integration of external sensors (through jack wire).This is because it was built for environmental monitoring, and not with the purpose of controlling equipment in our homes.

Environmental Awareness Smart Plug
Smart plugs available on the market are essential enablers for equipment retrofitting.They enable remote control and can enable monitoring, the definition of rules, and scheduled periods.However, improved smart plugs can benefit users by providing context data and by integrating artificial intelligence.For this reason, this paper uses EnAPlugs that have the ability to understand the resource's context and learn from the data and user interactions.
EnAPlug was introduced, in 2017, in Reference [11].The first proposed EnAPlug version was almost a pure hardware device without the capability of acting by itself.Its architecture was implemented in an Arduíno and an energy analyzer was used for energy metering.However, the principle was the use of external sensors that provide contextual information regarding the resource and its use.Figure 1 shows the 3D rendering, 3D printed prototype, and sensors used inside the refrigerator.The market available smart plugs, as well as other IoT devices, provide a centralized, cloud-based, solution.This requires a large amount of data going from the device to the cloud-away from the home and user location.According to Reference [18], a centralized approach has the advantage to not be limited to the device hardware, thus being able to process heavier energy management and learning algorithms.However, centralized approaches are subjected to lower fault tolerances, where decentralized approaches are a better choice [19].For those reasons, and knowing that EnAPlug uses SBC, each EnAPlug will be able to collaborate with each other in a decentralized solution; increasing fault tolerance and data ownership (i.e., data stays within the device).
Figure 2 shows the internal software layers architecture of EnAPlug.The base layer is the MAS framework.This paper uses the JADE framework, providing foundation for intelligent physical agents (FIPA) compatibility.On top of this is located the persistence and historic layer that is responsible fpr storing all the data regarding EnAPlug's sensors and actions.EnAPlug will learn from historical data that is stored in this layer.
The awareness and knowledge modules work side by side in the same layer; they represent the main abilities and contributions of EnAPlug.The awareness module integrates all the needed hardware used to understand the context of the controllable resourced -the resource controlled by the EnAPlug.This module is responsible to read, write, and control all the hardware resources, from sensors to the actuator(s).The knowledge module integrates all the necessary components that provide knowledge to In the last month of 2018, a new version was proposed in Reference [10] considering the limitations of other proposed smart plugs, such as in References [12,13] where smart plugs were proposed for monitoring, using ZigBee protocol.However, the chosen communication protocol demands a ZigBee hub/gateway to collect the data.In Reference [14], a Bluetooth smart plug is proposed.However, the Bluetooth does not allow remote control without the use of a hub.In Reference [15], a low-cost smart plug using Wi-Fi is presented, but it lacks the awareness capability.In Reference [16], a smart plug that can detect on-and off-peak periods by analyzing the electrical network is proposed.However, resource awareness and control are not well explored.
The new version of EnAPlug was built using a single-board computer (SBC) that held the necessary operation software; instead of using the Arduíno.The use of SBC enables direct access to an operating system, making it possible to process and store all the data and take care of communication to/from EnAPlug.At this moment, there are many small and low-cost SBC that can be used, e.g., Orange Pi Zero, NanoPi NEO, or Raspberry Pi Zero.The base of EnAPlug architecture is a multi-agent system (MAS) [17], where each EnAPlug is an agent that directly communicate with the others.For test and laboratory experimentation, the Java Agent Development (JADE) framework was used.
The current smart plugs enable the remote control of electrical resources, but they are only able to provide limited information regarding resource usage.EnAPlug has the goal to gather and understand the resources' data, with the data being directly or indirectly a consequence, result, or precondition of the resource usage.The more is known about a controllable resource, the better the algorithms for energy management will perform.
The market available smart plugs, as well as other IoT devices, provide a centralized, cloud-based, solution.This requires a large amount of data going from the device to the cloud-away from the home and user location.According to Reference [18], a centralized approach has the advantage to not be limited to the device hardware, thus being able to process heavier energy management and learning algorithms.However, centralized approaches are subjected to lower fault tolerances, where decentralized approaches are a better choice [19].For those reasons, and knowing that EnAPlug uses SBC, each EnAPlug will be able to collaborate with each other in a decentralized solution; increasing fault tolerance and data ownership (i.e., data stays within the device).
Figure 2 shows the internal software layers architecture of EnAPlug.The base layer is the MAS framework.This paper uses the JADE framework, providing foundation for intelligent physical agents (FIPA) compatibility.On top of this is located the persistence and historic layer that is responsible fpr storing all the data regarding EnAPlug's sensors and actions.EnAPlug will learn from historical data that is stored in this layer.
Energies 2019, 12, x FOR PEER REVIEW 5 of 15 have, or could have, a direct impact in the controllable resource usage or electricity consumption.If a sensor does not have any impact and cannot be used for context-awareness nor learning algorithms, then it should not be used.EnAPlug provides two types of actuators: Discrete (i.e., on/off) or variable (i.e., with a working range).These hardware actuators are integrated into the same module of sensors; sensors and actuators module.Below the sensors and actuators module is the resource safety control module, which has simple and critical restrictions that prevent the controllable resource being damaged by the agent or the remote control.For example, if the EnAPlug controls a freezer, the inside temperature should not overpass a certain value.The resource safety control will include a restriction that indicates that if the refrigerator goes over x ˚C, then it should be turned on and the remote control should be temporarily deactivated to prevent malfunctions.The EnAPlug's MAS is a congregation organization system, where congregations are formed by physical locations (i.e., all the living room's EnAPlugs form a congregation) and agents can be part of more than one congregation.The MAS used in EnAPlug uses event-and self-triggering communications between agents.The event-triggering is used by agents to respond to other agents.The self-triggering is used when an agent wants to manage their consumption and requests the knowledge from other agents.
EnAPlug is not a commercial product.The concept is a context-aware smart plug used for data acquisition and shared knowledge.Feel free to build your own EnAPlug version and/or improve our concept.If you need support to build your own EnAPlug, please contact us; we are available to work with you for improvement or simple developments of EnAPlugs.

EnAPlug's Shared Knowledge
The ability to share EnAPlugs knowledge is one of the key features of EnAPlug, drastically distancing oneself from current market solution.The ability to share information and knowledge is the basis for the exponential expansion of knowledge in communities.This is possible because each EnAPlugs is an agent in a congregation with the other EnAPlugs of the same room.It is the MAS that provides the connection, communication, and share of knowledge between EnAPlugs.
EnAPlug has knowledge regarding the controllable resource connected to it.This knowledge regards the resource usage and users' interaction with that resource.The knowledge is acquired with deep learning algorithms that will use the contextual data to learn the resources usage profile and the users' interaction profile.With this knowledge, EnAPlug will be able to answer the questions presented in Table 2.The presented EnAPlug will combine learning and contextual data to answer those The awareness and knowledge modules work side by side in the same layer; they represent the main abilities and contributions of EnAPlug.The awareness module integrates all the needed hardware used to understand the context of the controllable resourced-the resource controlled by the EnAPlug.This module is responsible to read, write, and control all the hardware resources, from sensors to the actuator(s).The knowledge module integrates all the necessary components that provide knowledge to EnAPlug's agent.Learning algorithms and optimization algorithms are located in this module.
The Modbus/RTU (Remote Terminal Unit), and Modbus/TCP (Transmission Control Protocol), GPIO (general purpose input/output), RF (radio frequency), and TCP/IP (Transmission Control Protocol/Internet Protocol) modules form the communication layer.These modules are directly used by the awareness and knowledge modules; but not in an equal manner.The awareness module can use the full communication layer-it has access to all the communication modules.However, the knowledge module can only use the TCP/IP module; all the other communication modules are not applied to the requirements of the knowledge module.
The Modbus/RTU and Modbus/TCP module allows the easy integration of energy analyzers and other sensors and actuators; these are vastly used protocols in energy equipment.The GPIO module uses the pins available, if any, in the SBC to directly connect sensors and actuators.The RF module enables the integration of wireless sensors and actuators.When integrating sensors in a smart plug, the location where the smart plug is placed can be an issue if placed in dark locations.Therefore, the integration of wireless sensors is important, enabling the placement of sensors surrounding the controllable resource.
The top-level modules represent interactions with external hardware or software.The energy metering module is responsible for reading data from the energy analyzer using Modbus/RTU or Modbus/TCP.The cloud connection module is responsible to interact with the cloud.The cloud connection is optional and is used to enable the training of deep learning algorithms outside EnAPlug's SBC.This module and the shared knowledge module are only able to use TCP/IP protocols.The shared knowledge module, which will be detailed in Section 4, allows the sharing of EnAPlug's knowledge with other EnAPlugs.
Between energy metering and cloud connection modules, there are two small layers that represent the sensors, actuators, and the safety control.The hardware sensors should measure parameters that have, or could have, a direct impact in the controllable resource usage or electricity consumption.If a sensor does not have any impact and cannot be used for context-awareness nor learning algorithms, then it should not be used.EnAPlug provides two types of actuators: Discrete (i.e., on/off) or variable (i.e., with a working range).These hardware actuators are integrated into the same module of sensors; sensors and actuators module.Below the sensors and actuators module is the resource safety control module, which has simple and critical restrictions that prevent the controllable resource being damaged by the agent or the remote control.For example, if the EnAPlug controls a freezer, the inside temperature should not overpass a certain value.The resource safety control will include a restriction that indicates that if the refrigerator goes over x • C, then it should be turned on and the remote control should be temporarily deactivated to prevent malfunctions.The EnAPlug's MAS is a congregation organization system, where congregations are formed by physical locations (i.e., all the living room's EnAPlugs form a congregation) and agents can be part of more than one congregation.The MAS used in EnAPlug uses event-and self-triggering communications between agents.The event-triggering is used by agents to respond to other agents.The self-triggering is used when an agent wants to manage their consumption and requests the knowledge from other agents.
EnAPlug is not a commercial product.The concept is a context-aware smart plug used for data acquisition and shared knowledge.Feel free to build your own EnAPlug version and/or improve our concept.If you need support to build your own EnAPlug, please contact us; we are available to work with you for improvement or simple developments of EnAPlugs.

EnAPlug's Shared Knowledge
The ability to share EnAPlugs knowledge is one of the key features of EnAPlug, drastically distancing oneself from current market solution.The ability to share information and knowledge is the basis for the exponential expansion of knowledge in communities.This is possible because each EnAPlugs is an agent in a congregation with the other EnAPlugs of the same room.It is the MAS that provides the connection, communication, and share of knowledge between EnAPlugs.
EnAPlug has knowledge regarding the controllable resource connected to it.This knowledge regards the resource usage and users' interaction with that resource.The knowledge is acquired with deep learning algorithms that will use the contextual data to learn the resources usage profile and the users' interaction profile.With this knowledge, EnAPlug will be able to answer the questions presented in Table 2.The presented EnAPlug will combine learning and contextual data to answer those questions, allowing the understanding of the controllable resource regarding usage and consumption in real-time operation/usage and in forecast operation/usage.
Questions i and ii are answered by reading real-time contextual data regarding the controllable resource; electrical consumption and EnAPlug sensors.Questions from iii to vi are answered using learning algorithms trained in the cloud and used locally; in the SBC of EnAPlug.The data sent to the cloud will not be tagged and cannot be traced back to the user/home, guaranteeing data anonymity and preventing privacy issues.As can be seen in Reference [20], artificial neural networks (ANN) can be used to forecast electrical consumption.Therefore, they will be used in EnAPlug as learning algorithms; providing a forecast to answer questions iii and iv.The Deep Learning for Java (DL4J) framework is used in the SBC and in the cloud-side.ANN were configured and trained specifically to answer questions iii and iv of shared knowledge section.For each ANN application, a long short-term memory (LSTM) recurrent neural network (RNN) with early stopping was used, to prevent the underfit and overfit [21].The ANNs used are a backpropagation network.The weights were initialized using the equation proposed in Reference [22].The gradients are updated according to Nesterov momentum and a threshold of 0.5 is applied to truncate values, as was proposed in Reference [23].The learning process of EnAPlugs can be seen in detail in Reference [10], where ANN are analyzed and tested according to different inputs, timesteps, and outputs.In this paper, the use of the shared knowledge mechanism over the EnAPlug's learning will be described and tested.
Figure 3 shows the shared knowledge process.At first (i), EnAPlug trains the ANN outside its local processor to speed up the training time.After this process, EnAPlug is ready to share and request knowledge with/from their peers.EnAPlug then requests, to the yellow pages agent, all the EnAPlugs located in a specific room (ii).At last (iii), EnAPlug directly requests each peer for knowledge.This process increases the individual knowledge using the community's knowledge; provided by other EnAPlugs.
Equation ( 5) calculates the probability of answer  being right, where  ∈ 0,1 -negative/false or positive/true.For this, the answer given by EnAPlug, represented by , and the accuracy of its forecast, represented by , are used.For instance, if we have an EnAPlug with an accuracy of 80% giving a negative answer (i.e.,  = 0), then  = 20% while  = 80%-meaning that there is 20% change that in reality we will have a positive/true answer (i.e.,  = 0 ) and 80% change of having a negative/false answer (i.e.,  = 0 ).Equation ( 5) is only possible because questions have binary answers.
Although there are multiple potential applications for the proposed concept, EnAPlugs and the shared knowledge supported by them and by the proposed distributed optimization approach were idealized for energy management resources' optimization.Energy management is usually based on centralized approaches [25], considering the entire facility (e.g., room, house, building) as a whole and reaching an optimal (or near optimal) energy resource management solution.However, as mentioned before, such approaches are limited and do not consider the different perspectives and contexts of each device.On the other hand, fully distributed energy management systems, by considering the individual perspectives and preferences only, do not guarantee reaching good solutions from an overall perspective (e.g., a decision to turn on all the lights in a living room may be great from the comfort point ANN training can be done locally or remotely.The remote option, represented in Figure 3, is done using a server that receives the ANN configuration, training dataset, and test dataset.Then, the execution of ANN is done locally in the SBC.Using this methodology, each EnAPlug benefits from their peers' knowledge.This is seen in Equation ( 1), where α room represents the room's knowledge that is a combination of the room's EnAPlugs' knowledge; represented by α EnAPlug i .The number of EnAPlugs deployed in the room is represented by n.
Regarding questions iii and iv, where learning algorithms are needed, the room's answer, given by A room , is calculated using Equation (2), where A i is the individual answer of EnAPlug i .In order to consider that a person will be near or will be using the controllable resource, at least one EnAPlug must provide a positive forecast.To consider that not a single person will be near or will be using the controllable resource, all EnAPlugs must provide negative answers (i.e., forecasting that will not have persons near or using the controllable resource).
Since we are dealing with forecasting, Equations ( 3) and ( 4) are needed to calculate the accuracy of the results.Even though one EnAPlug forecast that will be a person near or using the controllable resource, the accuracy of forecast must be taken into account; the individual answers of EnAPlugs cannot be taken as absolute truth.Therefore, the room's answer (A room ) is the combination of all the room's EnAPlugs answers and accuracy.Equation (3) calculates the probability of a negative room answer, where E 0 i is the probability of EnAPlug i to respond negatively (Equation ( 5) for a = 0), while Equation (4) calculates the probability of an affirmative room's answer-an adaptation from the principle of inclusion and exclusion for probability [24].
Equation ( 5) calculates the probability of answer a being right, where a ∈ [0, 1]-negative/false or positive/true.For this, the answer given by EnAPlug, represented by A, and the accuracy of its forecast, represented by γ, are used.For instance, if we have an EnAPlug i with an accuracy of 80% giving a negative answer (i.e., A = 0), then E 1 i = 20% while E 0 i = 80%-meaning that there is 20% change that in reality we will have a positive/true answer (i.e., a = 0) and 80% change of having a negative/false answer (i.e., a = 0).Equation ( 5) is only possible because questions have binary answers.
Although there are multiple potential applications for the proposed concept, EnAPlugs and the shared knowledge supported by them and by the proposed distributed optimization approach were idealized for energy management resources' optimization.Energy management is usually based on centralized approaches [25], considering the entire facility (e.g., room, house, building) as a whole and reaching an optimal (or near optimal) energy resource management solution.However, as mentioned before, such approaches are limited and do not consider the different perspectives and contexts of each device.On the other hand, fully distributed energy management systems, by considering the individual perspectives and preferences only, do not guarantee reaching good solutions from an overall perspective (e.g., a decision to turn on all the lights in a living room may be great from the comfort point of view of that single room; but highly damaging from the overall perspective of the house) [26].Therefore, combining both approaches in a dynamic, intelligent, and context-aware way, as proposed in this work, is a significant advance in the field of energy management.

Case Study
The case study considers a Portuguese two-bedroom residential house where a couple lives in. Figure 4 shows the blueprint of the used apartment, where bedroom 1 is used as a work place while bedroom 2 is used as a sleeping room.The case study's residential house is a combination of real resources implemented in our offices and laboratories, and simulated resources, to build a complete case study.The house has a total of four air conditioner (AC) units spread in bedroom 1, bedroom 2, kitchen, and living room.They are independent AC units, and each one of them is controlled by one EnAPlug.
The AC unit of bedroom 2 was not considered in this case study.This unit was excluded because of its particularity operation mode.It is considered that this unit should always be turned on between 18:00 and 08:00; therefore, it will not be considered for distributed optimization.

Distributed Optimization
The distributed optimization uses shared knowledge to improve the forecasting by using the community's knowledge instead of performing a single forecast.The community's knowledge of performed distributed optimization is proposed as a novelty feature of this paper.The use of all EnAPlugs in the same room can improve the forecast's accuracy and enable a distributed system.The distributed optimization is the result of having each EnAPlug controlling its own controllable resource using the information of others.For the distributed optimization, only the forecast results are used; EnAPlugs do not share sensor data.Although the distributed optimization could be used in any controllable resource, this section will only focus on the control of AC units.
The use of community's knowledge enables the build of a social knowledge inside each building's room.The social knowledge will enhance the individual/personal knowledge provided by EnAPlugs, similar to our society that is the combination and aggregation of personal knowledge.This knowledge is merged using Equations ( 3) and ( 4), where all the community's knowledge is merged Table 3 lists the available resources in this case study according to location, consumption, and type.The type indicates if the resource has an EnAPlug controlling it (i.e., real), or if it is a simulated resource (i.e., simulated).The mixed type resource indicates that real consumption and real sensor data are used from our offices and laboratories but there is not an EnAPlug installed.The house has a total of four air conditioner (AC) units spread in bedroom 1, bedroom 2, kitchen, and living room.They are independent AC units, and each one of them is controlled by one EnAPlug.
The AC unit of bedroom 2 was not considered in this case study.This unit was excluded because of its particularity operation mode.It is considered that this unit should always be turned on between 18:00 and 08:00; therefore, it will not be considered for distributed optimization.

Distributed Optimization
The distributed optimization uses shared knowledge to improve the forecasting by using the community's knowledge instead of performing a single forecast.The community's knowledge of performed distributed optimization is proposed as a novelty feature of this paper.The use of all EnAPlugs in the same room can improve the forecast's accuracy and enable a distributed system.The distributed optimization is the result of having each EnAPlug controlling its own controllable resource using the information of others.For the distributed optimization, only the forecast results are Energies 2019, 12, 1647 9 of 15 used; EnAPlugs do not share sensor data.Although the distributed optimization could be used in any controllable resource, this section will only focus on the control of AC units.
The use of community's knowledge enables the build of a social knowledge inside each building's room.The social knowledge will enhance the individual/personal knowledge provided by EnAPlugs, similar to our society that is the combination and aggregation of personal knowledge.This knowledge is merged using Equations ( 3) and ( 4), where all the community's knowledge is merged to provide social knowledge regarding the use of an individual resource.The new approach goes beyond the current state of the art that prioritizes centralized management or fully distributed management in energy management system applications.Centralized management systems, such as in References [27] and in [28] lack the ability to be distributed and therefore scalable and have higher fault tolerance.However, distributed approaches, such as References [29,30], have limited world understanding and count with inside data, lacking general and global information from the other parties.This work uses a distributed decision with a community's knowledge-based approach that can be seen as a hybrid system performing distributed optimizations using globally shared data, similar to a centralized approach.This hybrid distributed optimization prevents the use of a centralizer decision point [31], avoids the commonly use synchronization mechanisms for centralized decision [32], and minimizes performance issues usually associated with the distributed management systems [33].
In this case study, the AC control is done in two moments: 15 min before the forecasted hour starts, and 15 min after the hour started.Figure 5 shows the decision flowcharts of these two control moments.During the first control moment, 15 min before the hour starts, each EnAPlug uses Equation ( 3) to calculate the probability of being someone inside the AC's room (i.e., a = 1), using the knowledge coming from the other EnAPlugs.If the probability of having someone in the room during the next hour is higher than 80%, the AC will be turned on.The second control moment is a corrective control that will check the veracity of the forecast result, and act accordingly-if the forecast indicates no persons and if after 15 min a person is detected, then the AC will be turned on.The temperature of each AC is set by the user; the distributed optimization will optimize the turning on and off of the AC unit power.The room temperature will be then controlled by the internal AC's thermostat.
Energies 2019, 12, x FOR PEER REVIEW 9 of 15 to provide social knowledge regarding the use of an individual resource.The new approach goes beyond the current state of the art that prioritizes centralized management or fully distributed management in energy management system applications.Centralized management systems, such as in References [27] and in [28] lack the ability to be distributed and therefore scalable and have higher fault tolerance.However, distributed approaches, such as References [29] and [30], have a limited world understanding and count with inside data, lacking general and global information from the other parties.This work uses a distributed decision with a community's knowledge-based approach that can be seen as a hybrid system performing distributed optimizations using globally shared data, similar to a centralized approach.This hybrid distributed optimization prevents the use of a centralizer decision point [31], avoids the commonly use synchronization mechanisms for centralized decision [32], and minimizes performance issues usually associated with the distributed management systems [33].
In this case study, the AC control is done in two moments: 15 minutes before the forecasted hour starts, and 15 minutes after the hour started.Figure 5 shows the decision flowcharts of these two control moments.During the first control moment, 15 minutes before the hour starts, each EnAPlug uses Equation (3) to calculate the probability of being someone inside the AC's room (i.e.,  = 1), using the knowledge coming from the other EnAPlugs.If the probability of having someone in the room during the next hour is higher than 80%, the AC will be turned on.The second control moment is a corrective control that will check the veracity of the forecast result, and act accordingly-if the forecast indicates no persons and if after 15 minutes a person is detected, then the AC will be turned on.The temperature of each AC is set by the user; the distributed optimization will optimize the turning on and off of the AC unit power.The room temperature will be then controlled by the internal AC's thermostat.
The hourly (h) control of each AC is done using the timestamps of Table 4.The control process starts half an hour before (ℎ − 30) with EnAPlugs forecasts (answering questions iii and iv).The sharing of knowledge is done 20 minutes before the hour starts (ℎ − 20) and the AC is controller 5 minutes later at ℎ − 15.The AC is controlled at ℎ − 15 giving enough time to have the room's ready to receive the user-having enough time to heat or cool the room to meet the users' desired temperature.At ℎ + 15, each EnAPlug does corrective actions to avoid errors in the forecast.In cases where the current status of EnAPlug differs from the forecasted status, the actions are corrected.

Time (minutes) Action ℎ − 30 mintues
Each EnAPlug forecasts user presence for the period between ℎ to h + 1ℎ The hourly (h) control of each AC is done using the timestamps of Table 4.The control process starts half an hour before (h − 30) with EnAPlugs forecasts (answering questions iii and iv).The sharing of knowledge is done 20 min before the hour starts (h − 20) and the AC is controller 5 min later at h − 15.The AC is controlled at h − 15 giving enough time to have the room's ready to receive the user-having enough time to heat or cool the room to meet the users' desired temperature.At h + 15, each EnAPlug does corrective actions to avoid errors in the forecast.In cases where the current status of EnAPlug differs from the forecasted status, the actions are corrected.

Time (min) Action
h − 30 min Each EnAPlug forecasts user presence for the period between h to h + 1 h h − 20 min AC EnAPlugs requires the answers to question iv to each EnAPlug in their location h − 15 min AC EnAPlugs take on/off control actions h + 15 min AC EnAPlugs take corrective actions where h is the hour to control {h ∈ Z : 0 ≤ h ≤ 23}.
The normal profile consumption of the house can be seen in Section 6.All the AC are turned off during the away time (i.e., from 09:00 to 17:59), but they are immediately turned on when the users return home (at 18:00).The presented profile represents a spring period where AC unit consumption accounts for 72% of total consumption.

Use of Market Available Smart Plugs
Besides the integration of EnAPlugs, this case study also considers the use of market available smart plugs to provide a comparative performance of resource optimization and usage.The scenario considering market available smart plugs use standard monitoring smart plugs without a distributed or centralized optimization.Only available functionalities are considered.Therefore, the used smart plugs use the scheduling functionality and the improved user's interaction; where the user can easily turn on or off a set of smart plugs using voice commands.

Results
To test EnAPlug's shared knowledge capability, the scenario where the AC connected to EnAPlugs optimizes its consumptions using the shared knowledge regarding the user's location was run-question iv of Section 4. The actions are executed applying Table 4 timeframe.The results of EnAPlug's shared knowledge management are compared with two scenarios:

•
Consumption profile scenario-in this scenario, no EnAPlug nor smart plug are used, the consumption is measured having into account the users' management of the AC units; that is, turn on all AC units from 18:00 until 08:00, leaving them off when they are not at home; • Smart plug scenario-where conventional smart plugs are used to control the AC units using scenes.These scenes are configured to describe users' activities: Welcome home-turns on the AC units of bedroom 1 and living room; Meal time-turns on the AC unit of the kitchen; Close the kitchen-turns off the AC of the kitchen; Bed time-turns off the AC units of bedroom 1 and living room.
The application of scenes in conventional smart plugs enables easy control over several smart plugs using a unique control.Scenes can also be applied in voice command through assistant devices, such as Amazon Alexa and Google Assistant.The scenarios' results are measured using the described resources of Table 3, where a combination between real data and simulated data is used.
Figure 6 shows the values resulting from the application of Equation ( 3) for each room at each hour.These results consider an average forecast accuracy of 85%.As can be seen, the kitchen has a minimum 55.63% probability of having a person in during the next hour-even when all EnAPlugs say that no one will be there.This is a consequence of Equation ( 3), which adds each EnAPlug error meaning that more EnAPlugs will result in a higher minimum percentage.
indicate the presence of users inside the room.Kitchen has a total of six EnAPlugs but only three indicate the presence of users.The living room has a total of four EnAPlugs and only one indicates the presence of persons inside.The AC's EnAPlugs will use the shared knowledge of the others.Therefore, they will not be part of the Equation (3) results.Table 5 summarizes the calculation of  1  for bedroom 1, kitchen, and living room, where the forecast of each room's EnAPlug is indicated and the  0  indicates the probability of having persons inside the room during the next hour; a forecast accuracy of 85% is considered.Note that even if an EnAPlug forecasts that will not be any user near the controllable resource, there is still a 15% probability of having a person near the controllable resource, as calculated in Equation (5) (i.e.,  0  ).Because Table 5  1  are bigger than 80%, the AC units of bedroom 1, kitchen, and living room are turned on at 19:45 (ℎ − 15), according to the rules of Table 4.
Figure 7 shows the hourly consumption of the three approaches: Profile, where the normal consumption is presented; smart plugs, where conventional smart plugs are used to promote a better and manual control; and EnAPlugs, where EnAPlugs are used without the need of user interaction.By applying the actions of Table 4 and the control decision of Figure 5 to bedroom 1, kitchen, and living room, the EnAPlug's distributed autonomous energy management is able to decrease the house overall consumption.During the dinner hour, at 20:00, a total of three rooms indicate the presence of persons inside: Bedroom 1 (99.66%),kitchen (99.76%), and living room (89.16%).Bedroom 1 has four EnAPlugs that all indicate the presence of users inside the room.Kitchen has a total of six EnAPlugs but only three indicate the presence of users.The living room has a total of four EnAPlugs and only one indicates the presence of persons inside.The AC's EnAPlugs will use the shared knowledge of the others.Therefore, they will not be part of the Equation (3) results.Table 5 summarizes the calculation of β 1 room for bedroom 1, kitchen, and living room, where the forecast of each room's EnAPlug is indicated and the E 0 i indicates the probability of having persons inside the room during the next hour; a forecast accuracy of 85% is considered.Note that even if an EnAPlug forecasts that will not be any user near the controllable resource, there is still a 15% probability of having a person near the controllable resource, as calculated in Equation (5) (i.e., E 0 i ).Because Table 5 β 1 room are bigger than 80%, the AC units of bedroom 1, kitchen, and living room are turned on at 19:45 (h − 15), according to the rules of Table 4. Living room 0, 0, 1 15%, 15%, 85% 89.16% 1 0: will not be users near the controllable resource; 1: will be users near the controllable resource.
Figure 7 shows the hourly consumption of the three approaches: Profile, where the normal consumption is presented; smart plugs, where conventional smart plugs are used to promote a better and manual control; and EnAPlugs, where EnAPlugs are used without the need of user interaction.By applying the actions of Table 4 and the control decision of Figure 5 to bedroom 1, kitchen, and living room, the EnAPlug's distributed autonomous energy management is able to decrease the house overall consumption.  1 0: will not be users near the controllable resource; 1: will be users near the controllable resource.In Figure 7, an increase in consumption during lunch time, from 00:00 to 13:00, having the profile as a base is also visible-where the AC was not turned on.The use of smart plugs enables an easier interaction with AC units, and therefore, the users are able to easily turn on the kitchen's AC.Because EnAPlug takes actions at h − 15, the EnAPlug consumption starts earlier to have the desired temperature in the kitchen at the time of its usage.EnAPlug consumption at lunch is also lower because the start peak of AC runs before lunch and the AC turns off near 00:45.
Having a closer look at 18:00, all three scenarios present unique consumption values.The profile scenario considers that all the AC units are turned on from 18:00 until 08:00.Therefore, at 18:00, the starting of all AC units inside the house is visible: Bedroom 1, bedroom 2, kitchen, and living room.In the smart plug scenario, the 'welcome home' scene turns on the AC units of bedroom 1 and living room.Therefore, at 18:00-when users arrive home (according to users' routine of Section 5.2)-the AC units turned on are: Bedroom 1, bedroom 2, and living room.Bedroom 2 is on at 18:00 because it is not considered for this case study.In the EnAPlug scenario, only bedroom 1 has a β 1 room above 80%-with an exact value of 98.09%.This means that only the AC of bedroom 1 will be turned on.Therefore, at 18:00, the EnAPlug scenario will have the following AC units turned on: Bedroom 1 and bedroom 2. Resuming, at 18:00, the EnAPlug has one less AC unit comparatively to the smart plug scenario and two less AC units for the profile scenario.However, the EnAPlug consumption has a higher decrease, from the smart plug scenario (where one less AC is used), than the decrease of the smart plug scenario from the profile scenario (where one less AC is used).This is because the EnAPlug has the AC unit starting at 17:45-when the consumption is a little bit higher because of the unit start.
The use of smart plugs, using scenes to update more than one smart plug at a time, gives more freedom to the users update the AC status in each room.Table 6 shows that with smart plugs, the users save up to 25.5%.But, by deploying EnAPlugs, the users save more 13.6%.Using the 2017 average price per kWh in the European Union as reference price (i.e., 0.20 EUR [34]), the EnAPlug AC optimization represents savings in a total of 31.02EUR/month.

Discussion and Conclusion
This paper presents the first case study for a residential house using the deployment of EnAPlugs.The results are compared with two other scenarios where no smart plugs are used and where market available smart plugs are used.The application of EnAPlugs provides context-awareness capabilities and resource's knowledge.By using a distributed control with shared knowledge, no central hub nor a central point for optimization are needed.This is possible because EnAPlug has a single-board computer, providing higher-end hardware when compared to conventional smart plugs.This enables EnAPlug to work as a sensor hub-collecting all the sensor data-and an energy management system-processing the data and managing the controllable resource.By bringing the computational power to smart plugs level, distributed optimization using knowledge from multiple EnAPlugs becomes possible, as seen in the promising results presented in this paper.
The use of multi-agent systems to create congregations of agents enables the collaboration with multiple EnAPlugs sharing the same room.The agents are running inside the single-board computers of EnAPlugs and deal with peer-to-peer communication.The integration of artificial intelligence, such as the use of multi-agent systems and learning algorithms, boost the knowledge of EnAPlugs regarding the controllable resource as well the room and resource context, thus contributing to the advance in the field of power and energy management.
The vast dissemination and use of EnAPlugs are not yet perfect, and the forecast used entails errors that can become problems, especially for Equation (3), where errors are somehow aggregated.Therefore, if we increase the number of EnAPlugs inside the same room, the results become worse than if we use a small number of EnAPlugs.For example, if we have three EnAPlugs with forecast accuracy of 90%, and all of them forecast that no user will be at the room, Equation (3) still gives a probability of 27% of having at least one user in the room.But if we increase to six EnAPlugs, the probability of having a user in the room raises to 47%, even with all of the six EnAPlugs forecasting that no user will be in the room.Therefore, the trigger value of β 1 room -which will indicate when the controllable resource will be turned on-should be correlated with the number of deployed EnAPlugs in the same room; a higher trigger for a higher density of deployments.Future developments should take this into consideration when using the shared knowledge mechanism.
The paper shows the benefits that the integration of artificial intelligence can have if it is used in our daily devices.The case study has shown that the proposed approach was able to decrease energy costs.Also, the decisions and actions are taken away from the user to the system, saving the users' time and providing him with intelligent load control.