A Novel Real-Time Electricity Scheduling for Home Energy Management System Using the Internet of Energy

: This paper presents a novel scheduling scheme for the real-time home energy management systems based on Internet of Energy (IoE). The scheme is a multi-agent method that considers two chief purposes including user satisfaction and energy consumption cost. The scheme is designed under environment of microgrid. The user impact in terms of energy cost savings is generally signiﬁcant in terms of system efﬁciency. That is why domestic users are involved in the management of domestic appliances. The optimization algorithms are based on an improved version of the rainfall algorithm and the salp swarm algorithm. In this paper, the Time of Use (ToU) model is proposed to deﬁne the rates for shoulder-peak and on-peak hours. A two-level communication system connects the microgrid system, implemented in MATLAB, to the cloud server. The local communication level utilizes IP/TCP and MQTT and is used as a protocol for the global communication level. The scheduling controller proposed in this study succeeded the energy saving of 25.3% by using the salp swarm algorithm and saving of 31.335% by using the rainfall algorithm.


Introduction
The intelligent micro grid is an important field for the Internet of Energy that aims to provide reliable information transmission by means of intelligent installations and to re-evaluate, manage accurately and make scientific decisions on the intelligent microgrid via intelligent devices.
The Internet of Energy (IoE) is the next step and advancement of today's internet, where objects and things are embedded with communication and computation capabilities. The Internet of Energy (IoE) appliances can be seamlessly assimilated to the internet at various levels. The IoE provides the foundation for intelligent cities services such as intelligent transportation, intelligent health, intelligent grid, intelligent surveillance, intelligent home, and so forth. One of the biggest systems of the IoE is an intelligent grid, which is nothing but a conventional grid augmented with the integration of renewable energy and communication technologies. The IoE based intelligent devices can be embedded into the intelligent grid via all of its main parts, such as production, supply, communication, and use [1]. Due to the population growth in communities, the energy needs for this century are increasing quite rapidly. Societies depend heavily on the efficient and resilient delivery of electricity for national security, economy, and health care. The normal electric grids are static and unreliable in order to meet consumer demands accordingly. The smart grid is the next generation of grid that is able to transfigure the modes of electricity output, control, and distribution. The microgrid can improve the lives of the next generation of people, as intelligent grid users are very involved and can participate in the system, as they form priorities and demands settings. Therefore, different countries have begun implementing intelligent grid systems for communities. The market of a traditional grid is national and centralized, where an intelligent grid market is decentralized and ignores boundaries [2].
In order to ensure an intelligent grid and to enhance the IoE integration, continuous communication is necessary. In terms of output, market, distribution, transmission, and customer the intelligent grid is more effective than a conventional grid [1,3,4]. The conventional grids have limited power generation, and a large number of small power producers are in the intelligent grid. A conventional grid transmission includes large power lines and pipelines with a smart grid that offers small transmission and compensation for local supply, thereby making the smart grid significantly more efficient than the conventional grid. Consumers of a smart grid are very active and participate in a system in the form of priorities and demands set. The national and centralized market for a conventional grid is fragmented and the borders are ignored. A smart grid consists of billions of intelligent devices, sensors, intelligent meters, and many other communication networks, be they private or public [5,6].
Demand response (DR) strategies provide economic, effective and secure solutions in relation to energy management. EMS on the DR decentralized residential or housing microgrid offers the most cost-effective demand profile, so that load control will help the house owners have less discomfort [7]. However, installing a collocated roof generator and the variability of home appliances in the operation of the storage system can make it difficult to manage the energy of a building process. This is more demanding as it is quite difficult to estimate renewable real-time generation and also since the energy price in the day ahead is different from the real-time energy price. Stochastic optimization may address these uncertainties, but it also requires appropriate random parameter probabilistic estimates. For domestic energy management, the real-time optimization portfolio is therefore required, which can provide an optimal solution in the abrupt change in energy generation and the price of market energy. To fulfil the abovementioned requirement, this paper elucidates a real-time optimization system for synergetic source load storage dispatch in an intelligent home or an intelligent residential microgrid.

Literature Review of Theoretical Background
In Reference [8], the authors present a system of optimization models for the optimal planning of intelligent house Renewable Energy Resource (RER) and batteries. In the first phase of optimization, which has an objective function of the renewable energy resource and battery life-cycles minimization, the optimal size problem of the renewable energy resource and batteries is suggested. With the help of multi-object domestic energy management, the intelligent home problems of daily energy operation are formulated in the second stage. The authors in Reference [9] present a smart energy management system for intelligent homes with intelligent appliances. The proposed system schedules schedulable loads that take into account the operative complexities of uncontrolled loads and the renewable resource non schedulable conduct. The resources are optimally sized using game theory. In Reference [10] the authors proposed a day-to-day multi-objective optimization model for ToU price based energy management system, integrated with the other generation from built-in photovoltaic systems (BIPV) to maximize the economy and comfort of the occupant by providing a synergetic supply to the source of the storage. In Reference [11], the authors proposed an interdisciplinary approach incorporating machine learning, optimized architecture, and data structure design to create an internal energy management system that can fulfill real-life needs. In Reference [12], the authors suggested a stochastic system for demand response framework, given the uncertainties concerning the availability of electric vehicles and the production of renewable energy (HEM). The simulation results verified, while guaranteeing the satisfaction of the residents with respect to the technological limits of the electrical and household batteries and electric equipment, that the consumer costs can be minimized by taking into account different demand response programs (DRPs). A new strategy is suggested in Reference [13] to resolve an issue of demand optimization of the provided uncertainties of must-run loads and electricity costs. A new, embedded PSO-based approach for resolving stochastic optimization problems was proposed in an embedded system to reduce the calculation burden. This could be used as a stochastic programing model and a two-point estimation method. In Reference [14] the authors suggested a collaborative grid optimization model to plan residential MGs and to deliver demand-side management support. The complex constraints of the various intelligent home devices are applied to the demand-side management load shifting process. Three different cases were analyzed to assess the feasibility of the proposed template for economic and environmental objectives. In Reference [15] the authors developed a risk-based optimization algorithm for the risk assessment of solar energy and the energy price insecurity.
In Reference [16] the authors proposed new and more practical analytic models in four scenarios for assessing peaking demand. The suggested method is based on assumption, in a quasi-random method for arrivals or electricity demands, of a finite amount of equipment in the region under study. In Reference [17] the authors implemented a distributed load shifting algorithm in demand management with an emphasis on the problem of planning for residential intelligent machines. The customer's frustration is minimized by the sparse load shifting approach. The authors proposed in Reference [18] a cloud-based multi-agent (MAS) residential smart grid community network. The suggested multi agent system (MAS) is made up of microgrid agents and intelligent household agents, with the goal of relieving RMG's top load and minimizing smart home energy costs. In Reference [19] the authors proposed architecture for peer-to-peer control of the insular microgrid framework. The multi-cap and multi-agent algorithms and design, where several goals are accomplished, achieve this P2P architecture. The agent with communication and calculation capabilities that adapt to multiplayer monitoring can run these processes simultaneously. The authors investigated effective DSM methods in Reference [20] to minimize the energy consumption from a grid. They analyze the energy use trends, price of electricity, weather and other characteristics of users to determine the best way to monitor charge level. They suggest an energy storage genetic algorithm and game-theory-based energy management methods. In Reference [21], the researchers presented a fog-based internet of things framework for trans active energy management framework. In Reference [22], the authors introduced, developed and implemented an architectural structure for an IoT and cloud EMS producing the user load profile to be accessed from a company or by the consumer on a remote basis. Companies should monitor and disseminate their incentives and allow customers to adjust their energy usage with the user load profiles.
The authors developed and implemented a multi-agent system for active network administration for their distribution network in Reference [23]. The goal is to give the distribution network operator (DNO) transaction in the distribution system operator (DSO) sector a dynamic framework, which is relevant and useful. In Reference [24] the authors proposed a novel agent-based framework for combining residential and industrial flexibility capacity. This approach suggests the alignment of the sensitive strategy for industrial and residential aggregators to include a central demand response provider. In Reference [25], the authors presented a multi-target problem whose resolution occurs with an evolutionary algorithm and task management method. The multi-target problem calls for real-time response to demand (RTP). Two goals existed: daily energy costs and user in satisfaction, decreased by both. In Reference [26] the researchers proposed an adaptive management method of energy for microgrid modes. A hybrid structure that includes an electrical grid, photovoltaics, and batteries is used to satisfy demand as energy sources in the consumer home. The system proposed allows organized operation of distributed energy resources to provide the active and additional power needed whenever necessary.
In Reference [27] the authors proposed an EMS for smart households. Each home computer is connected to the IoT object through a single IP address that results in a wide network of appliances using a mesh wireless system. In Reference [28], a novel binary search algorithm (BBSA) was implemented to control energy management in real time. The BBSA gives the optimum scheduling schedule for home appliances to minimize a demand for total loads, and schedules the running of house equipment at particular times during the day. A novel energy internet system for management of micro grid has been proposed in Reference [29]. The platform proposed is based on a versatile, scalable IoT structure incorporating DERs. In Reference [30], the authors suggested a new approach called demand response as a service, based on an algorithm of Q-learning. In Reference [31] a new energy management framework was introduced by the authors to be introduced as a fog platform. The implementation of the Fog Computing platform achieves flexibility, connectivity, interoperability, real-time, privacy, and EMS criteria. In Reference [32] the researchers presented a Home-Management Self-Learning (SHM) on a MAS platform which used Internet of Things (IoT) principles to implement the communication and interaction between agents. In Reference [33], the authors proposed a new knowledgebased multiphysics energy control strategy for electric hybrid busses, emphasizing thermal security as well as on-board lithium-ion battery degradation. Innovation is used to achieve smart balance over conflicting objectives and almost optimize a power distribution by means of an accelerated iterative concordance, by introducing a soft actor-critical deep reinforcement learning method. In Reference [34] the researchers suggested a novel robust control method for renewable energy sources. However, the energy management for a multi-agent system governed microgrid in the Internet of Energy was not investigated. In Reference [35], the authors proposed a new energy management-based machine learning method for an electric hybrid bus with an emphasis on thermal security and the degradation of the lithium-ion batteries structure. In Reference [36], researchers proposed a novel energy management for a grid connected mode and an island mode using an adaptive neuro fuzzy interface system. However, the energy management for a MAS governed microgrid in an Internet of Energy was not investigated.

Paper Contribution
In this article, a novel real-time electricity scheduling for smart energy management system using the IoE is proposed that employs: scalability, adaptability, interoperability, and connectivity between devices over cloud platforms.
The contributions of this paper are: 1. This research proposed a new rainfall algorithm, and a salp swarm algorithm based real-time optimum schedule controller for home EMS to energy savings and limit home peak-demand in the household.

2.
A further contribution of this study is the proposal of a Multi Agent System for microgrid representation that integrates IoE appliances for energy management inside the smart home. However, the proposed MAS uses the strong Internet penetration of object appliances in households for EMS solutions. This is the most important addition through this article 3.
The two-layer hierarchical communications architecture, based on the MQTT protocol and using a cloud server called ThingSpeak, is applied to realize global and local communication required for neighborhood devices.

Proposed System Description
Here, the researchers considered that the DGs consisted of the communication and control agents in the Internet of Energy realm, as described in Figure 1. The physical components of a general microgrid included the inverter-interfaced distributed generator, dynamic and static loads and the diesel generators. It was noted that the DGs in the microgrid were controlled by a framework, wherein every DG was managed by one MAS agent. The MAS agents communicate by the Local Area Network (LAN) and can access the internet for remotely controlling the microgrid via the cloud servers. In the Internet of Energy, every distributed generator/microgrid was managed by various stakeholders, and their controllers on the MAS/agents differed from MG components. It was expected that the number of distributed generator and MG agents could be changed online, hence, a remote, flexible and distributed control and implementation framework was necessary. Figure 1 presents the suggested structure.
control agents in the Internet of Energy realm, as described in Figure 1. The physical com-ponents of a general microgrid included the inverter-interfaced distributed generator, dynamic and static loads and the diesel generators. It was noted that the DGs in the microgrid were controlled by a framework, wherein every DG was managed by one MAS agent. The MAS agents communicate by the Local Area Network (LAN) and can access the internet for remotely controlling the microgrid via the cloud servers. In the Internet of Energy, every distributed generator/microgrid was managed by various stakeholders, and their controllers on the MAS/agents differed from MG components. It was expected that the number of distributed generator and MG agents could be changed online, hence, a remote, flexible and distributed control and implementation framework was necessary. Figure 1 presents the suggested structure. The smart grid would need an effective measuring and communication system in order to continuously track the power and cost profile and regularly quantify power losses. There are several stages of data processing.
This work contains Measurement Units (MU) for every distribution network bus. MU is MATLAB modeling. The power and cost information is sent to the control center regularly at a fixed time. The control center is designed as a virtual data management and analysis platform. One approach to communication relating to the device topology proposed is considered. The case takes a Cloud approach, which sends its measured data directly to the Cloud by any MU connected to a corresponding feeder bus as illustrated in Figure 1.

Classification of Smart Appliances
The tasks for user usability have diversified, as possible clever computer users are in homes such as TVs, washing machines, boilers, cooling and heating equipment, as well as lighting framework. There are two important types of appliances: the shiftable equipment is de-signed and managed by EMS over time (T = 24). Suppose a set of manageable devices is represented as D , and = 1, . . . , D , for ∈ N for every customer [37]: where L , is appliances load and D , is appliances set. Nonshiftable devices cannot be shifted to hours of off-peak for minimize cost, i.e., the consumption of power profiles of devices such as the refrigerator, light, and TV. A nonshiftable device of the customer ∈ N is identified as: Community electricity is produced from RES in the form of community microgrids. The goal of the optimization model is to plan limited energy resource for appliances according to their needs for periods and electricity costs. Electrical appliances work under the electricity tariff 24 h ahead of time of use. Where, L , is a total consumption of power profile of customers ∈ N in ∈ T slot time.
where, L T is a total power of all customers.
Each consumer has a separate power consumption schedule that decreases bills and demand peak in a different time frame every day. The peak-to-average (PAR) ratio is calculated by the combined power profiles [37].

Problem Formulation
To minimize the objective function of cost of devices in individual and community consumer: where, γ , P is the decision flexible, N is the total amount of users, T is the time, Q is the type of load, D is the total number of devices, α , is the decision variable for the appliances, P , E is the electricity, S , is the decision variable for energy, L , L is the electricity storage at time , L , is the power profile of the house devices.

Preference of Operation Period
The binary matrix is utilized for a ready-to-use factor. This requires the ready-to-use slot , to run the devices over time. Home users tend to operate a computer more often throughout the day, and then substitute it with more devices.

Variable Decision
Constraint P 2 is the decision variable of the device ON /OFF. Constraints P 3 is decision variable of user for self generation power. If β , = 1, user is a prosumer and β , = 0 for user is a consumer. Consumers purchase electricity from the neighborhood microgrid or power grid.

Devices Task
For the measurement of energy profiles, it is mandatory to know the working life of intelligent devices.
is the operation time of d th devices in the T slot time in P 5 .
α , is the decision variable to turn ON/OFF the device. The constraints P 5 and P 6 are continuous times to accomplish a task and it has to remain ON at time T , until it has finished a task. For instance, once a washing machine begins to work, it runs continuously until the final time limit is set, P 6 is formulated. is the devices starting time [37].

Devices Priority
When another system completes the service cycle, the appliance will start running. A dryer will not operate until the laundry has completed its operating cycle.
is the group of these kind of loads. The decision variable selects the devices of each group for each time span.

Price
The price signal is received from the group micro grid. A utility grid is optional for our study, the energy volume for export and import from the community. The dynamic-pricing system is used for electronic transactions from the grid. The prices are believed to be accepted and cannot be updated after publication. The pricing system can be freely chosen by the customers. The costs of the same load will differ at different times in one day. The electricity is consistently low and expensive to obtain from the grid at night and vice-versa. The energy price depends on the energy used and the time per day the energy is used. where P , E is the electricity tariff, P and P are electricity prices from the community micro grid and P ℊ is a utility grid purchase.

Proposed Internet of Energy Communication Platform
The decentralized controller of a smart MG helps in managing the system operating conditions if there is some disturbance. Furthermore, the IoT technology can be used for communicating between the appliances present in smart homes, central controller or power management centers. The researchers proposed the IoT platform for collecting the data, monitoring, managing and controlling the microgrid. All appliances and energy resources were integrated and connected in this platform. The proposed Internet of Energy communication platform is presented in Figure 2.
Where ℰ , is the electricity tariff, and are electricity prices from the communit micro grid and ℊ is a utility grid purchase.

Proposed Internet of Energy Communication Platform
The decentralized controller of a smart MG helps in managing the system operatin conditions if there is some disturbance. Furthermore, the IoT technology can be used fo communicating between the appliances present in smart homes, central controller o power management centers. The researchers proposed the IoT platform for collecting th data, monitoring, managing and controlling the microgrid. All appliances and energy re sources were integrated and connected in this platform. The proposed Internet of Energ communication platform is presented in Figure 2.
It is a demanding job to develop a demand response based IoE base. The role of th platform is to (1) incorporate the micro-grid tools into the communications system and (2 link to the IoE cloud in order to track and manage the devices. The IoE communication network proposed is composed of 4 different layers, as defined in Figure 2. The device or perception layer was referred to as the layer of different component [38]. Various IoT users are included in the device layer, which is comprised of smart elec tric vehicles, smart homes, and transportation systems, along with DGs such as FCs, MT and the WTs. Additionally, this layer supported different kinds of sensors for measurin the real-time environmental and physical state of the components and the actuator It is a demanding job to develop a demand response based IoE base. The role of the platform is to (1) incorporate the micro-grid tools into the communications system and (2) link to the IoE cloud in order to track and manage the devices. The IoE communications network proposed is composed of 4 different layers, as defined in Figure 2.
(a) Agent Layer: The device or perception layer was referred to as the layer of different components [38]. Various IoT users are included in the device layer, which is comprised of smart electric vehicles, smart homes, and transportation systems, along with DGs such as FCs, MTs and the WTs. Additionally, this layer supported different kinds of sensors for measuring the real-time environmental and physical state of the components and the actuators needed for adjusting them. Hence, WSNs and WSANs were seen to be an inseparable component of this layer.
(b) IoT platform layer: The IoT platform layer is the sensors layer. Moreover, this layer funds different kinds of sensors to monitor the physical condition of a connected agent and to adjust to them in real-time. WirelessSensor and Actor-Network (WSAN) and Wireless-Sensor-Networks (WSNs) are the two pieces of the sheet that are inseparable. WSNs can be described as a number of sensors that are used to sense the environmental conditions and transmit them through a wireless network to other appliances.
(c) Network layer: (d) Layer of processing data: A data processing layer is defined as the layer which allows processing a huge volume of data which was assembled from lower-layer with the help of powerful processors [38].
(e) Layer of cloud: The cloud layer stores historical data from distributed energy resources (DERs) for the purpose of global tracking. One of the features required for Internet of Energy applications and services is to store historical data [39]. The IoE cloud layer includes virtualized servers. In addition, an application interface has been introduced with preserved historical data for each DER. A vast volume of data can be saved and maintained in the historical archive, which is supported by the application interface to the cloud infrastructure.

Platform of ThingSpeak
The ThingSpeak is an open-source IoT application (IoT) and an Application Programing Interface (API) that allows the storage and recovery of data through internet or by Local Area Network through the HTTP and MQTT protocol [40].
To operate, ThingSpeak inherits the following elements: • Received Signal Strength Indicator (RSSI) channels: A collection of N RC ThingSpeak channels for the upload of RSSI data by target devices. N RC is a device parameter to be chosen for the platform installation time.
The data submitted to RSSI channel include the IoT appliances ID, number of detected APs N D RSSI . The device ID is compulsory, the other data pieces may be missed if there are no technical capabilities in the IoT device. Each channel is replicated with the ID of the unit.

•
An algorithm-based Thing Speak Analysis, with the execution of data uploaded from devices on RSSI channels.
Three MATLAB variables store RSSI data in the applications [40]: WkNN is an extension of kNN.
p WkNN = ∑ k n=1 w(m n )p n ∑ k n=1 w(m n ) (19) w(.) is usually defined as a special case of WkNN.
There are two choices for similarity tests at the moment for ThingSpeak: • Inverse Minkowski distance as: • Correlation coefficient squared value R(S T − S i ), as:

Procedure of Thing Speak
The process for setting and deploying the ThingSpeak platform provides for three steps, given that WiFi hardware is already mounted within the field of interest: (1) environmental scan, (2) configuration on the server-side, and (3) configuration on the device side.

The MQTT Knowledge
The MQTT is a lightweight protocol. The MQTT is operational in the TCP and ensures that all messages are forwarded from agent to server.
Three major players, i.e., A MQTT protocol includes MQTT Publisher, MQTT Broker, and a MQTT subscriber. MQTT's subscribing and publishing companies have indirect connections and no IP address at the same time. An MQTT broker takes care of the customer authorization and initialization process necessary for communication. To publish the information, the MQTT publishers utilize custom themes for catering to their clients. The MQTT protocol did not use a Metadata marking. Thereafter, the MQTT topic management presents the metadata for a message load. MQTT is known as a string with the hierarchical structure of multi-attributes and multi-levels. Every stage can be separated from the forward slash in a theme tree [41]. For routing data derivation, all subjects can be modified. Following the exchange of control packets among clients and brokers, Figure 3a presents the link initialization. Check packets for CONNAC, Connect, PUBACK, PUBLISH, SUBSCRIBE, SUBACK, etc., were shown to include specific instructions concerning the subject, transmission and payload service quality (QoS). Figure 3b presents all components of the MQTT contact.

Proposed Architecture
The hierarchical system provided for intelligent homes with a control-layer and cyber-layer is presented in Figure 4. Two communication layers were included in the hybrid system. It was seen that in the Layer 1 (local layer), the appliances in the smart building transmitted the MQTT messages to a Building MQTT Client (BMC) and reported the measurement and subscribed to the MQTT message that were published via MQTT Client for protection/control purpose. A connection between the Cloud and BMC using HTTP POST/GET requests was seen in Layer 2 (which is the global layer). Any appliance in this architecture had Wi Fi unit connected to the local gate way. Thus, the values of a committed and pre-defined subject could be published regularly [42,43]. The BMC then subscribes to the various topics and transmits the values obtained to the cloud channel. A MATLAB cloud interface, which implements the built algorithm for allocating appliances, is available to access all cloud data. The algorithm results are then transferred with BMC from a cloud to intelligent devices that control them. The researchers found that when communication in any layer fails, the suggested architecture is robust (either local or global). Hence, the BMC was so designed that during any communication link failure or high latency noted in the network, it could operate as a local controller for all appliances in building. This function of BMC was highlighted in the Section 5.

Proposed Architecture
The hierarchical system provided for intelligent homes with a control-layer and cyberlayer is presented in Figure 4. Two communication layers were included in the hybrid system. It was seen that in the Layer 1 (local layer), the appliances in the smart building transmitted the MQTT messages to a Building MQTT Client (BMC) and reported the measurement and subscribed to the MQTT message that were published via MQTT Client for protection/control purpose. A connection between the Cloud and BMC using HTTP POST/GET requests was seen in Layer 2 (which is the global layer). Any appliance in this architecture had Wi Fi unit connected to the local gate way. Thus, the values of a committed and pre-defined subject could be published regularly [42,43]. The BMC then subscribes to the various topics and transmits the values obtained to the cloud channel. A MATLAB cloud interface, which implements the built algorithm for allocating appliances, is available to access all cloud data. The algorithm results are then transferred with BMC from a cloud to intelligent devices that control them. The researchers found that when communication in any layer fails, the suggested architecture is robust (either local or global). Hence, the BMC was so designed that during any communication link failure or high latency noted in the network, it could operate as a local controller for all appliances in building. This function of BMC was highlighted in the Section 5.

Salp Swarm Algorithm Based Scheduling Model
As shown in Figure 5, the salp swarm home devices planning mechanism is suggested in the work to optimally design home appliances. The action of the salp swarm algorithms is based on the navigation and foraging of the salp swarm in oceans. The key explanation for this optimization technique is its swarming activity in which all salps move and drill food together [44].

Salp Swarm Algorithm Based Scheduling Model
As shown in Figure 5, the salp swarm home devices planning mechanism is suggested in the work to optimally design home appliances. The action of the salp swarm algorithms is based on the navigation and foraging of the salp swarm in oceans. The key explanation for this optimization technique is its swarming activity in which all salps move and drill food together [44]. Each salp is considered as a device in energy management controller. Where the aim is to find a group of devices, namely the best swarm. The swarm of the salps moves together to find the best survival option. In our case, the best optimal point for a group of devices must be found during an interval time. Each salp is considered as a device in energy management controller. Where the aim is to find a group of devices, namely the best swarm. The swarm of the salps moves together to find the best survival option. In our case, the best optimal point for a group of devices must be found during an interval time. A swarm chain is salp. Then the swarm is divided into followers and a leader. It is said that the salp leading the chain is salp, while the others are also salp. The leader of salp leads the follower of salp. Taking the n-dimensional search field into account. N defines the number of optimization problem variables. Z is a double-dimensional matrix used for labeling the salp location. D is a supposed food source in a search room. In a search space, a salp target is D used to update leading position [44].
1 is a balance coefficient of a exploitation and exploration. and ℯ are upper bound and lower bound of search space with dimension .
1 , 2 and 3 are random numbers. is search space dimenson. Z 1 is salp leader. D is considered as a food source.
Newton's motion law will be used to change the follower salps' location.
where Z represents the follower salp position of dimension . represent the iteration,

Rainfall Algorithm Based Scheduling Model
The rainfall algorithm is proposed in this work in order to plan home equipment optimally. The rainfall algorithm imitates rainfall behavior. Any drop of rain in the energy management controller is regarded as a device. In the deepest valley, drops are collected and the global optimal solution is found.
The particles are moving as the gradients descend and ascend in the rainfall algorithm. Figure 6 demonstrates the suggested algorithm. Rainfall optimization begins with parameters and population initialization. The words used in the suggested algorithms are: active drop, point neighbor, raindrop, explosion process, neighborhood, inactive drop, merit order list, and raindrops rank [44].
where n is variables in problem of optimization, Z ,k illustrate k th variable used in problem of optimization. A is th number drop. Subject used is illustrate below in (28) [45].
is used to shows function of uniform distribution. Lower and upper limits are represented as low and up .
The explosion phase is accomplished when this drop is inactive. This approach is used to extract rain drop from the situation. The phase of explosion is Ne times. ℯ used in the explosion method to search neighbors for equation (30) [44].
where explosion counter is given as ℯ , points neighbor are shows as , and explosion base is illustrated as ℯ .
To save the raindrop ranges in an increasing order, a merit list is used. An optimization problem eliminates a raindrop from the merit list. Randomly, the raindrops are formed at first iteration. A neighborhood is allocated to each rainfall after rain drop generation and neighborhood point are also randomly generated according to objective feature restrictions. Below are such restrictions for Equations (31) and (32) to allocate neighboring points [44]: For each rain fall and its neighbors, the cost is measured. All neighborhood values are compared to raindrop values to detect the most dominant neighborhood point.

Communication System Model
The smart grid would need an effective measuring and communication system in order to continuously track the power and cost profile and regularly quantify power losses. There are several stages of data processing.
This work contains measurement units (MU) for every distribution network bus. MU is MATLAB modeling. Power and cost information is sent to the control center regularly at fixed time. The control center is designed as a virtual data management and analysis platform. One approach to communication relating to the device topology proposed is considered. The case takes a Cloud approach, which sends its measured data directly to the Cloud by any MU connected to corresponding feeder bus as illustrate in Figure 1.
The real-time data transfer among the MATLAB software package and the open source IoT framework ThingSpeak are used to model proposed communication architectures. ThingSpeak was chosen for the simulation of real time cloud communication Due to its following benefits [40]:

1.
ThingSpeak Cloud IoT platform data aggregation, tracking and analysis. In the smart grid model, power profile is monitored on multiple ThingSpeak channels in real time and depicted graphically.

2.
Security: The username and passwords allow user authentication while each channel is equipped with its own ID and can be accessible (seen by other users). There are two keys in each channel for the application programing interface. A randomly generated read key and write key of the API. These keys can save or retrieve information from stuff from each channel over the Internet or LAN.

3.
It facilitates the double-way flow of data between the user and virtual device and allows the data and remote control to be exchanged in real time. The MATLAB Desktop Real-time Toolbox offers a communication between the simulated feeding model and the ThingSpeak IoT platform.

4.
Communication network enabling for real-time data transmission over the Internet between MATLAB and ThingSpeak.

5.
Allows importing, exporting, analyzing and viewing data on multiple platforms and their fields simultaneously.

Simulations Results
This part discusses the effect of the microgrid communication system. The microgrid will exchange information in the presence of the communications device, such as load consumption and power generation. To reduce micro grid operating costs, instead of purchasing from grid, the micro grid gets required power from neighboring microgrid instead of purchasing it from the utility grid. That mean, a communication system provides the data needed to transfer power between the microgrids. Utilizing the cost optimization algorithm in Reference [44].
In this simulation test, the outcomes of smart EMS applied with the proposed method over a cloud-platform to control devices in the microgrid are introduced and discussed. In this paper the MATLAB is a chief command and control unit organizing a ThingSpeak platform, developed in a software communication and architecture interface. MQTT functions as a broker between subscribing microgrid devices and main control unit. In this paper, the ThingSpeak platform interface that has been designed is a simple and convenient Graphical User Interface (GUI) that allows a house owner to interact and access with their home energy management as a service over the cloud system. Figure 7a shows the ThingSpeak web page to the enter user name and password of the customer, Figure 7b,c shows the ThingSpeak dash-board illustrate the results of the proposed system For scheduling, where each house has several devices, three intelligent homes are envisaged. We considered the same energy demand for any consumer for a fair comparison of the electricity bill for three households.

Result without Corrective Method
The simulation is performed to verify the impact of the ToU signal on the electricity bill of the user. In ToU, electricity is regarded as a baseline in Reference [44]. The electricity prices are volatile and time dependent on the costs of generation and energy use. However, the costs of production are confidential in several respects. For the analysis, we therefore assume that the generation with high ToU rates will increase.
The home energy management system comprises a GUI and related software to facilitate users power consumption and total cost of the microgrid devices; their power consumption of all homes without the corrective method is implemented as displayed in Figure 8. Figure 9 shows the cost graphical user interface of proposed home energy management system without the corrective method, (a) cost profiles of the first house, (b) cost profiles of the second house, (c) cost profiles of the third house. For scheduling, where each house has several devices, three intelligent homes are envisaged. We considered the same energy demand for any consumer for a fair comparison of the electricity bill for three households.

Result without Corrective Method
The simulation is performed to verify the impact of the ToU signal on the electricity bill of the user. In ToU, electricity is regarded as a baseline in Reference [44]. The electricity prices are volatile and time dependent on the costs of generation and energy use. However, the costs of production are confidential in several respects. For the analysis, we therefore assume that the generation with high ToU rates will increase.
The home energy management system comprises a GUI and related software to facilitate users power consumption and total cost of the microgrid devices; their power consumption of all homes without the corrective method is implemented as displayed in Figure 8. Figure 9 shows the cost graphical user interface of proposed home energy management system without the corrective method, (a) cost profiles of the first house, (b) cost profiles of the second house, (c) cost profiles of the third house.

Result with Corrective Method
After scheduling the electric devices, the energy bill can be decreased. Additional studies are carried out to study a effect of the scheduling utilizing the algorithm of salp swarm and the algorithm of rainfall. After load shifting by scheduling, we also investigated the effect of the proposed pricing technic. Figure 10 shows power GUI of proposed home management system after implementing the SSA method, Figure 11 illustrates the power GUI of the proposed home management system after implementing the RFA algorithm. Figure 12 shows the cost GUI of the suggested home management system after implementing the SSA method, Figure 13 illustrates the cost GUI of the proposed system after implementing the RFA algorithm.

Result with Corrective Method
After scheduling the electric devices, the energy bill can be decreased. Additional studies are carried out to study a effect of the scheduling utilizing the algorithm of salp swarm and the algorithm of rainfall. After load shifting by scheduling, we also investigated the effect of the proposed pricing technic. Figure 10 shows power GUI of proposed home management system after implementing the SSA method, Figure 11 illustrates the power GUI of the proposed home management system after implementing the RFA algorithm. Figure 12 shows the cost GUI of the suggested home management system after implementing the SSA method, Figure 13 illustrates the cost GUI of the proposed system after implementing the RFA algorithm.

Results and Discussion
In the analysis, electricity emission reduction, cost-saving and PAR were used to evaluate the performing analysis of the microgrid. The time slots demanded for unmovable and changing demand are moved into the early morning time after the implementation of the energy management system, as shown in Figures 12 and 13. Thus, the load

Results and Discussion
In the analysis, electricity emission reduction, cost-saving and PAR were used to evaluate the performing analysis of the microgrid. The time slots demanded for unmovable and changing demand are moved into the early morning time after the implementation of the energy management system, as shown in Figures 12 and 13. Thus, the load profile is corrected as the customer can work with low price on time slots as shiftable, unshiftable devices. As a result, consumption energy costs have been reduced, emissions costs decreased, and the PAR upgrade was carried out. Figure 14 shows the comparison between without the suggested system and with the suggested system. After applying the suggested scheme, it is notable that the micro grid energy cost has been reduced from 542.2977 cents (USD) to 432.7899 cents (25.3%) by using the salp swarm algorithm, as depicted in Figure 14b. Additionally, it is notable that the micro grid energy cost has been decreased from 542.2977 cents (USD) to 412.9103 cents (31.335%) by using the rainfall algorithm, as depicted in Figure 14c.

Conclusions
In this research, a novel optimization technique, as well as the cloud device framework has been established for the home management system. This study proposed a new communication system with a two level construction, which is suitable for microgrid management system. The suggested platform uses Transmission Control Protocol/Internet Protocol (TCP/IP) for local microgrid data exchange and as a backup communication technique among microgrid in case of a failure in the communication of cloud level. MQTT subscriber/publisher is adopted for cloud-level messaging and HTTP for interactions between a cloud-server and platform. Using the IoT and salp swarm algorithm and rainfall algorithm optimization technique, and optimal energy management scheme for microgrid is proposed in this paper. This work is the main contribution to the literature on energy management functioning and it proposes Real-Time Electricity Scheduling (RTES) for the home energy management system, which considers the errors of information prediction. Unlike the majority of the earlier home energy management system approaches that revolve around Day Ahead Electricity Scheduling (DAES). In addition, the energy management system was applied to improve the microgrid consumed energy cost, emission price, and PAR. To evaluate the performance of the suggested system models given in this paper, different tests were performed on MATLAB. The cost analysis in the results section shows how efficient the suggested distributed platform is compared to the centralized functionality of microgrid communications. The scheduling controller proposed in this study succeeded the energy saving of 25.3% by using the salp swarm algorithm and saving of 31.335% by using the rainfall algorithm.