## 3 Procedure for the Conversion of a Network Section into a Smart Microgrid
As explained in Section 1, there are different communication technologies to integrate each element of the microgrid into the data network of the control system, such as: ZigBee, Ethernet, Wi-Fi, GRPS, GSM, WLAN. The control system will be developed with Home Assistant, and here lies the main novelty of this work and its main advantage. Typically, it is used for home automation applications, but it is a robust solution, economically affordable, and with great potential for monitoring and managing microgrids in real time. Home Assistant, developed in Python, is open-source software which reduces costs. It allows the user to connect with almost any device regardless of the communication technology used, through a wide range of communication protocols. In addition, it allows developing a SCADA for each dispatchable element and its integration in an interface. Once Home Assistant is installed in a Raspberry Pi, a computer or even a server, and all the elements of the microgrid defined, it can be managed from every device and everywhere due to its web server, including a computer connected or not to the same data network or from a mobile phone due to the Home Assistant app and the web server. To integrate each element of the grid to the data network, it is necessary to know some issues related to communications. First, it is necessary to know if each element has a communication card, which allows access to the data network, either locally or remotely (for many years, all devices have had it). If the element does not allow communication, which is not very common except in loads and in non-dispatchable outdated generation sources, it will be necessary to install a grid analyzer with a communication card (TCP/IP, Wi-Fi, etc.) to measure parameters seen in step 1 (instantaneous power, etc.). In the case of loads, it may be interesting to monitor the most significant, but it would be enough to monitor the total consumption of the microgrid. If the element only allows connection in local mode (usually through RS232 or RS485), it will be necessary to install some intermediate device (Arduino, data acquisition system,Raspberry Pi, etc.) to connect it to the data network or a converter to switch local mode to remote mode (for instance RS232 to TCP/IP). If the element allows remote connection through a network card, it can be connected directly to the data network. **Step 3**. Establish communication between the elements of the grid and the control system: once the components of the grid have been identified and described, and connected to the microgrid control system data network, communication must be established between all of them, so that they do not work independently, but as a whole, and there can be an interaction between them. To connect each device with the Home Assistant's control system, it is also necessary to know their communication protocols. There are multiple communication protocols that allow the transmission of information, provided that all the devices are connected to the same data network or to equipment in local mode connected to the network. All communication protocols are developed under the framework known as OSI Model (Open System Interconnection). Among all the protocols, Modbus (RTU, TCP, or RTU over TCP) stands out, which is widely extended and is the one used by most equipment (Programmable Logic Controllers-PLC, photovoltaic inverters, wind inverters, battery chargers, network analyzers for measuring loads, etc.) since it is robust, easy, open-source, and therefore free and above all reliable. Finally, once all the equipment is connected to the same data network and the protocol used by each one is known (mainly Modbus), communication must be established between them and Home Assistant in the following way:  
1. The element (generation source, storage system, or load) must be in Home Assistant configuration file, in a different way depending on the protocol used, as follows:  
* name: Photovoltaic1 # name assigned to the element.