An overview of digitalization for the building-to-grid ecosystem

Digitalization is playing an important role in the emerging practice of Building-to-Grid (B2G). However, the majority of the literature only covers either the grid side, the demand side, or the technical aspect of B2G integration, and an overview of the digitalization in B2G and the involved stakeholders is missing. To fill these gaps, this paper proposes a definition of the B2G ecosystem and provides an overview of the digitalization of the B2G ecosystem with six aspects (B2G goals and themes, B2G technologies, B2G data sources and data management, and B2G related stakeholders). This paper also discusses five emerging technologies (5G, IoT, big data, artificial intelligence, and blockchain) and three main challenges of the applications of the emerging technologies in the B2G ecosystem (Security and privacy, interoperability and scalability, coordination, and dysfunctional emerging behaviors of collective intelligent controls). Lastly, this paper recommends future research directions in the Building-to-Grid ecosystem (especially ecosystem modeling and simulation), B2G’s role in smart cities, sustainability, resilience, and harmonization of the B2G ecosystem, and other emerging technologies in B2G.


Introduction
Digitalization is the new industrial revolution, and it could be the most significant change in the energy sector since the industrial revolution. Digitalization is transforming business in the energy sector along with the need for data interconnectivity and the defense against cybersecurity threats. In the energy sector, digitalization is playing an important role in the smart electric grid. Digitalization creates various opportunities to enable smart energy generation, delivery, and use through a smart grid. Meanwhile, a smart grid is a clear example of digitalization in the energy sector, as it is about information exchange and data availability to interested parties. Smart grid data management offer solutions for the operations and maintenance of the smart grid. The global smart grid data analytics market is expected to reach US$4.6 billion by 2022, and geographically, the CAGR (Compound Annual Growth Rate) of the Asia Pacific market is estimated to reach 14.8% by 2015-2022(Transparency Market Research, 2017. Moreover, digitalization brings unprecedented benefits for energy consumers and drives the digital transformation of buildings (Ma et al., n.d.). Building digitalization and data management improve energy efficiency and reduce the costs of buildings and constructions, especially with the great development of intelligent infrastructure and IoTs based technologies. Moreover, building digitalization and data management enable consumers to provide flexibility to the grid via demand response (DR, which can also be referred to, as energy flexibility), energy storage, microgrid, and electricity markets (Ma et al., 2017a). According to the Buildings Performance Institute Europe (BPIE), flexible energy management has an energy-saving potential of 500 billion euros in Europe (Groote & Rapf, 2015). Furthermore, regional and country-level policy drivers enable the market potentials for the digitalization of energy and buildings (Mlecnik et al., 2019). For example, Europe has set up an ambitious climate and energy plan, e.g. 2020 target of 20% of renewable energy in final energy consumption. There is also financial support for the research and innovation into energy-related digital technologies by the European Commission via the Horizon 2020 program. For instance, around €80 million of the European Union (EU) funding has been invested in projects that focus on combining Information and Communications Technology (ICT) and energy technology development during 2018 and 2019. Meanwhile, there are around €50 billion of public and private investments in support of the digitalization of the industry in the coming 5 years driven by the EU strategy on Digitising European Industry (Ristori, 2017). Therefore, digitalization creates opportunities for the integration of the grid and buildings. With the rising practice of the integration of the grid and buildings, the term, Building-to-grid (B2G), has become an emerging practice that intends to creates an opportunity for buildings to generate new value streams with energy services. B2G aims to help buildings to reduce energy costs through optimized use of resources, and alleviate congestion in the distribution grid through flexible energy operations.
Digitalization enables the realization of the integration between buildings and grids. There are quite a few discussions of B2G and its importance with the political and business statements. However, the majority of the literature has only discussed either the grid side, the demand side, or the technical aspect of the integration. Meanwhile, some literature has investigated the energy services that require B2G, e.g., energy flexibility, distributed energy generation, but not directly link to the digitalization of B2G. Overall, the digitalization aspect of B2G has not been well discussed in the literature.
The digitalization of B2G not only requires the technological readiness (e.g. accuracy for collected data and interface standards), but also strategic and managerial decisions (e.g. value creation from the raw data). Meanwhile, digitalization influences the business models of the involved stakeholders, especially their data-driven decisions (Ma & Jørgensen, 2018). However, the stakeholders and their participation in the digitalization of B2G have not yet been addressed in the literature.
Meanwhile, the emerging technologies in the smart grid, e.g., IoT, artificial intelligence, big data, blockchain, and 5G result in the emergence of new approaches such as distributed resources including demand response, distributed generation, storage, and renewable generation that enable consumers to provide energy flexibility (Sagiroglu et al., 2016;Christensen et al., 2019a). For instance, there will be 50 billion connected devices within the IoTs by 2030, and 52% of the customers see digitalization as a method to optimize their systems (Macht, 2016). However, the impacts of these emerging technologies have not yet been well discussed in the literature.
Therefore, to fill the gaps discussed above, this paper aims to investigate the roles of digitalization in B2G and borrows the concept of the business ecosystem (Moore, 1996;Ma et al., 2017b) to explore the B2G ecosystem with a special focus on data management and involved stakeholders and their participation in the digitalization of the B2G ecosystem. Furthermore, this paper discusses five emerging technologies (5G, IoT, big data, artificial intelligence, and blockchain) that impact the digitalization of the B2G ecosystem.
The rest of the paper is organized as follows: Section 2 discusses the digitalization of the B2G ecosystem with three aspects: the grid side, the building side, and the integration side. Section 3 discusses the six layers in the digitalization of the B2G ecosystem with the five emerging technologies and the corresponding three main challenges in the B2G ecosystem. Finally, the Conclusion section discusses the contributions and makes recommendations for future works.
The scope of digitalization in the building-to-grid ecosystem The digitalization of the B2G ecosystem can be divided into three traditional aspects: the grid side, the building side, and the integration of buildings with the grid. Each aspect contains data sources, related technologies and standards, data, energy or building management, and main stakeholders.

Digitalization of the B2G ecosystem from the grid side
The emergence of new technologies in the smart grid is due to the liberation of the energy market (Schachinger et al., 2015). A smart grid is a modernized, reliable, and integrated power grid infrastructure that uses automated control, artificial intelligence (Bhuiyan et al., 2017), and communications technologies (Islam et al., 2017). Smart grid system provides two-way power distribution and communication, decentralized userinteractive networks, integrated energy resources, user-friendly structure, self-healing system, and integrated security protocols (Sagiroglu et al., 2016;Tanyingyong et al., 2016). Smart grid is composed of an improved version of conventional power systems (e.g. network, user, hardware, software, servers, and data) (Sagiroglu et al., 2016).
The traditional boundary of communication in the distribution power grid is from the substations and the utility Data and Control Centers (DCCs) to feeders, distributed generation, and consumer locations. Nowadays, the smart grid faces the largest increase in data any energy company has ever seen (Rusitschka et al., 2010). The exponential growth of data from many intelligent communicating devices in the broader context of smart grids requires sufficient and efficient data management.

Smart grid data sources
Smart grid relies on data collection, communication, and control systems. Smart grid uses wireless telecommunication systems to transmit data from sensors and communicate with various smart grid devices. Energy flexibility has the potential to reduce carbon emission, stabilize the grid and reduce energy consumption without violating compromising consumers' comfort requirements (Schachinger et al., 2015). Demand response, Distributed Energy Resources (DER), and energy storage are potential sources of energy flexibility in the power system (Connell et al., 2014).
The smart grid data can be divided into the generation data (e.g. traditional power generation and bulk renewable energy resources), transmission data, and distribution data, consumption data (including energy consumption information and schedule data), and market data (e.g. pricing data, market information). Different market players need and can access different data due to their roles and responsibilities in the smart grid.
The data sources for the smart grid data analytics can be meter and control data (e.g. AMI meter, SCADA, and direct Load control), market data, and customer data. Meanwhile, the environment data and demographic data (e.g. climate data) are usually included in the smart grid data analytics for different purposes. The availability of data has provided opportunities for using data analytics to support and enhance the smart grid operations through capacity planning and peak power shaving, and facilitate deployment of new energy services such as energy audits, demand response programs, and electric vehicle (EV) charging (Budka et al., 2014). The smart grid data analytics can be broadly classified into three main categories: (1) utility-centric applications (e.g. asset analytics (Nainar and Iov, 2021), grid topology (Arya et al., 2013), voltage management, and energy services (Huang et al., 2013), (2) consumer-centric applications (e.g. Home Energy Health Management), and (3) market-centric applications (e.g. DR (U. S. Department of Energy, 2006)).

Data management in smart grid
From the technical perspective, data management has impacts on the smart grid functions of distribution automation (DA), synchrophasors, and Advanced Metering Infrastructure (AMI) (Budka et al., 2014). There are various types of devices on the smart grid including the traditional devices, e.g. the SCADA IEDs (Intelligent Electronic Devices), and the smart grid elements, e.g. DG (Distributed Generation) and DA IEDs and PMUs (Phasor Measurement Unit). Due to the need for measuring specific point applications, there is widespread deployment of sensors (such as the IEDs, PMUs, and smart meters) in the smart grid.
A typical smart grid data management system consists of data acquisition, storage systems, data processing, and data-driven decision. The data management architecture must be accessible, reliable, accurate, profitable, and timelines (Howard et al., 2020). The sensitivity of the data decides the security level. It can apply the publishersubscriber communication paradigm for extensibility (Chockler et al., 2007). The requirements for reliability, delay, security, and scale for different communication flows associated with Smart Grid applications have been well defined in the U.S. e.g. (National Institute of Standards and Technology, 2019; National Institute of Standards and Technology, 2014). A new technological trend in IT service-cloud computing offers flexible and scalable computing, storage, and network resources to the smart grid data analytics on demand (Rusitschka et al., 2010).
The market data management is dependent on different markets and their needs. In a liberal electricity market, generation and retail are separated from the natural monopoly functions of transmission and distribution. The market is divided into wholesale and retail electricity markets. In some unbundling electricity market as Nordic electricity market, the wholesale market is divided into the day-ahead market, intra-day market, and regulating the market.
The main market players in the B2G ecosystem from the grid side The Transmission System Operators (TSOs) usually own and run the transmission grids (> 100 kV). The TSOs are responsible for the security of the electricity supply including the physical power balance and formulating market rules (Energinet.dk, 2007). In the Nordic electricity market, the wholesale market (the Nord Pool market) is owned by the TSOs. For instance, the Danish TSO-Energinet collects statistical data for the Danish electricity transmission systems and wholesale market real-time data.
In an unbundling electricity market like Denmark, electricity consumers have two contracts: a distribution contract and a supply contract . The distribution contract essentially concerns all distribution and metering issues. The supply contract essentially concerns the electricity commodity itself. For instance, in Denmark, it is the Distribution System Operators' (DSOs) who are responsible for installing and maintaining the smart meters. Electricity suppliers/retailers buy electricity from the producers in the wholesale market or other suppliers/retailers and resell it to consumers (Energinet.dk, 2011). The electricity suppliers/retailers have access to the metering data collected by the DSOs for billing the consumers. In Denmark, it is the electricity suppliers'/retailers' who are responsible for all customer communication.
Consumers have access to their data consisting of consumption data and billing data through their electricity suppliers/retailers.
There is an increasing demand for data exchange in the liberalized electricity retail market. Previously, individual consumers had only one relationship with one single electricity distribution company who was responsible for both transportation and retail of electricity. After the market liberalization, distribution companies are separated into grid companies (TSOs and DSOs) and electricity suppliers/retailers. The free choices of suppliers/retailers in and outside consumers' local distribution areas increase the complexity of the electricity market . In Denmark, a DataHub is established to simplify the data exchange among the electricity market players. All electricity data exchange takes place through the DataHub. DSOs are responsible for the master data collection from all the metering points, and for reporting the master data to the DataHub (Energinet.dk, 2012). It became an instrument in the liberalized market and is the preparation for the future electricity market (Klima Energi og Bygningsudvalget, 2013).
With the policies and demands for more renewable DERs, and emerging technologies (e.g. demand response, distributed storage), the wholesale electricity market data management is facing many challenges and constraints. For instance, one of the main technological challenges for smart grid data management is the various standards for smart grid communication and data management. The data sources are encoded in different formats according to different specifications. Therefore, the data management systems are required to translate and correct the data (Wu et al., 2011).
Another challenge is the data privacy and protection in the electricity market, especially for consumers. For example, the EU Commission has produced rules on the data processing for the consumer personal data, and guidelines on data protection and privacy for data controllers and investors in smart grids (European Commission, n.d.). The importance of more active engagement by consumers in the smart grid, either directly in the market or through aggregators, has long been recognized. However, some research shows that there is a barrier for consumers to share the data collected by smart meters due to privacy concerns, and it leads to a barrier to dynamic tariffs (Weck et al., 2017;Ma et al., 2016).
Although DERs can create benefits for the grid and consumers, the complexity of handling different types of DERs with various energy capacities presents challenges for many utilities in integration, planning, operation, and maintenance. Meanwhile, the unpredictable number and types of DERs and loads create challenges for the DER management from the grid side. There are various policies and regulations in different countries for avoiding the risk of DERs' integration to the main grid. For instance, electricity produced by DERs is only allowed to self-consume in the Philippines (Zheng Ma & Jørgensen, 2016), and it is not allowed to self-consume but directly supply to the grid in Denmark to reduce the complexity.

Digitalization of the B2G ecosystem from the building side
Modern buildings are equipped with building management systems (BMS) and Energy Management Systems (EMS) which control the indoor environment and the building's energy consumption through the use of sensors and actuators. BMS and EMS collect data from sensors (incl. meters) and control actuators through open standard or proprietary protocols.

Sensors and actuators
Sensors are used to capture the state of a given zone in a building. Here, a zone could be anything from a room to a floor or the entire building depending on layout, and how sensors are mapped into the building. Sensors are used to observe indoor comfort levels by measuring occupancy, CO2-, temperature-and humidity levels. However, sensors can also be employed to detect emergencies, including fire, flooding, or forced entry.
While building operators may react to certain indoor comfort events through manual actions (such as opening a window if the indoor climate is too hot), sensors and actuators are used by BMS to automatic react in these situations. Actuators related to comfort include heat valves, ventilation fans-and dampers, window shades and pistons as well as controllable light modules. Actuators act on an input that could originate either from a local controller, from the manual stimulus (such as changing the state of a light switch.) In its most simple form, building control can be achieved by wiring sensors and actuators directly with controllers. However, more often sensors and actuators are connected to a bus facilitating multiple actuators and sensors, which enables easier configuration-and reconfiguration of the sensor-and actuator mapping. Furthermore, this enables the use of BMSs and EMSs as described later.
While sensors and actuators have traditionally been wired, technologies such as Zigbee and Bluetooth LE have been created to support wireless communication with general peripheral devices including sensors and actuators.

Open standard and proprietary protocols
Protocols for building automation enable sensors, actuators, controllers, BMSs, and EMSs to communicate. For protocols based on open standards, this includes interoperability between peripherals, controllers, and software from different vendors.
Efforts are being made into creating standards for building automation protocols. IEEE standards 802.15.4, 1901, 1905.1, 802.21, 802.11 ac, 802.3at are examples of the results of these efforts. However, standard adoption within the domain of building automation has met some resistance. Some vendors adhere to proprietary protocols, to ensure that interoperability is limited to hardware and software produced by the vendor themselves, thus blocking customers from using 3rd party peripherals and software. This has given rise to a high degree of fragmentation, and the issue is often discussed within the area of the Internet of Things and building automation.
Nonetheless, several open standard protocols, including LonWorks, DeviceNet, Bacnet, C-Bus, m-bus, Modbus, and KNX, have seen widespread adoption. The OPC Foundation (https://opcfoundation.org/) has approached enabling interoperability between major building automation standards. The OPC standard describes the OPC Data Access andmore recently -OPC Unified Architecture standards, which enable communication towards peripherals deployed using any of the major protocol standards.

Building and energy management systems
A BMS imposes strategies for control of building actuators including ventilation, heating, lighting, and other electrical systems. These strategies describe acceptable ranges for temperatures, CO2 limits, and other parameters linked with occupancy comfort and ensure that the state in the building does not violate these ranges and limits by signaling actuators when needed.
An EMS has emerged as an awareness of energy consumption and environmental footprint has spread. While also maintaining building comfort an EMS adds decision support for building operators to enable optimization of building configuration (both physical and virtual) and enable energy-efficient operation of a building. Further, an EMS can offer energy consumption forecasts.
The main market players in the B2G ecosystem from the building side Consumers (e.g. industrial, commercial and residential) are becoming more dependent on automation for integration of buildings' energy flexibility with the fluctuating power supply from DER . The adoption of smart meters enables consumers to generate, store, and share their electricity (Schachinger et al., 2015) and thereby shift from being pure consumers to becoming active prosumers (Ma et al., 2018a). This shift in roles helps consumers to achieve their demand for high power reliability at low cost, whilst facilitating the integration of new types of on-site loads (e.g. EV) (Rui et al., 2011).
Consumers' energy profiles depend on the types of buildings and the related stakeholders, e.g. households, occupants, building managers/asset managers, industrial consumers, and prosumers: Households: A household consists of one or more people who live in the same dwelling. There are different types of residential buildings, e.g. single/multi-family homes, condominiums and, townhouses. Occupants in commercial buildings: Employees, managers, interns, students, spend significant time seated at workspaces and meeting rooms. Occupants consume energy for work-related activities. Energy/building managers: Responsible for supervising the buildings' security, maintenance, and repair performed in accordance with environmental and safety standards. The role of an energy manager (EM) involves facilitating energy conservation by identifying and implementing various options for saving energy, leading awareness programs, and monitoring energy consumption. Asset managers: Real estate asset managers are responsible for the strategic management of entrusted buildings and surroundings from the viewpoint of the total life cycle and value chain. An asset is evaluated as buildings in operation within neighborhoods and energy networks. Industrial consumers: Companies and activities involved in the process of producing goods for sale, especially in a factory or special area. They are the single largest electricity consumers. Industrial consumers have heavy energy use and complexity in smart grid technologies implementation for production purposes (Ma et al., 2018b). Electricity prosumers: Active energy consumers, often called 'prosumers' because they both consume and produce electricity, could dramatically change the electricity system.

Digitalization of the B2G ecosystem from the integration side
Technologies and standards, advanced metering infrastructure, and data management are three important parts of the B2G integration.

Technologies and standards
Efficient and cost-effective B2G integration requires interoperability between consumer-side and grid-side resources. This interoperability ensures that buildings and grids can exchange information without expensive customizations that can demotivate consumers' interest to provide energy flexibility services and B2G integration. The table below shows some of the key information exchanges required between the customerside and the grid-side systems to enable B2G integration services.
The diversity of data sources includes traditional energy management systems, gateways, and routers, energy use devices, appliances for emerging DERs such as behindthe-meter energy generation, energy storage, and EV infrastructure (shown in Table 1). To enable B2G integration services these building-or customer-side data resources must possess two-way communications to send/receive data and/or information with the grid. The data that buildings can send/receive to enable B2G integration services includes DR programs, energy demand, dynamic prices, energy usage, equipment/system monitoring and status, weather, and demand curves and forecasting. All such services intend to provide grid stability, reliability, efficiency, and low-cost operations, which can directly benefit buildings. Such interoperability from a diversity of data sources for B2G integration services can be enabled through standardized information exchanges within a smart grid.
As Smart Grid deployments increase, efforts increasingly enable the interoperability between smart grid and buildings through data standardization. Many global standards organizations have been working toward data standardization to enable efficient management of grid and customer energy resources. For instance, IEEE P2030 (an IEEE project that developed a 'Guide for Smart Grid Interoperability of Energy Technology and Information Technology Operation with the Electric Power System', and 'End-Use Applications and Loads') describes the interoperability between the electric power system (EPS) and customer-side applications (Gungor et al., 2011). IEEE P2030 includes a description of the two-way power flow between the customer-side and the EPS, with a specification of interconnection and interfacing frameworks, as well as strategies and design definitions [IEEE P2030-2011. Other examples, the Organization for the Advancement of Structured Information Standards (OASIS (OASIS, 2021)) and the International Electrotechnical Commission (IEC (International Electrotechnical Commission (IEC), 2018a; International Electrotechnical Commission (IEC), 2018b)) define the data exchange and standardization for smart grid and energy user interfaces for DR programs.
These programs generally referred under DR programs, are facilitated by ESPs to engage the building side in grid management. These programs have also put efforts into establishing standards for programs, deployed with the Internet to animate specific demand-side behavior. Demand response describes changes in planned electricity consumption of a particular building (or other DERs), in response to changes in electricity price overtime or incentive payments (Kathan et al., 2012). For example, IEC 62746-10-1 (previously Open-ADR 2.0b specification) is an approach to standardize communication between ESPs, aggregators, and consumers (Pichler, 2014). Meanwhile, IEC 62939 presents consensus perspectives on Smart Grid Users Interface (SGUI), which essentially encompass the active participation of consumers in the grid. Moreover, IEC 62939 combines DR-and infrastructural aspects, to identify gaps in current standards, with the ultimate goal of supporting the effective integration of buildings' systems and devices in the smart grid.
Aside from the above, several standards, including ANSI C12.22, ANSI C12.18, ANSI C12.19 and M-Bus (Gungor et al., 2011) describe aspects of deployment, data structures, and network communications in an Advanced Metering Infrastructure (AMI) context, which is used by smart meters.
Advanced metering infrastructure AMI describes digital meters, deployed at the building side to gather real-time consumption data, as well as the gathering and collection of this data (Zhou et al., 2012). This enables bilateral communication between buildings and the grid. For example, ESPs can provide variable tariffs to consumers, that could shift consumption in response to market-and grid conditions. AMI enables measurement of the response from buildings to validate efforts through data analysis and provide accurate billing of consumption. It considers both quantitative consumption and the time of use.

Data management
ESPs traditionally consider buildings to be passive, but it has been changed due to the merges of buildings as a resource in grid management (DN-y et al., 2012). This fosters the need for acquiring data regarding planned electricity consumption as well as AMI utilization, to monitor building behaviors. As mentioned, the AMI encompasses both data acquisition as well as data gathering and analysis. Non-electricity and electricity signals are automatically obtained from analog and digital calculated devices, such as sensors and other instruments under measurement, during the data acquisition process (Deshpande et al., 2004). There are two implementation types for data acquisition: active polling and passive polling. The gateway node must actively poll each sensor node to gather data in active mode, while in passive mode, the gateway node must react in time when a particular sensor node event occurs (Xiaoyan et al., 2001). Because of the resource restrictions, such as sensor resources and communication bandwidth, each intermediate node in the data collection process receives several copies of data rather than directly transferring data from other nodes to subsequent nodes (Maraiya et al., 2011). Aggregation processing is used to eliminate duplicate information, resulting in a more reliable and usable device, more fulfilling demand, and lower data volume, efficiently eliminating the original information, minimizing data replication and allowing the sensor network to transmit sensing data consistently.
The security threats in data transmission mainly include stealing confidential data, tampering with confidential data, falsifying the data authorized by authentication, and denial of service (Khan & Salah, 2018). The data transmission security of the B2G network can be started from the following directions. First, encryption algorithms are used to encrypt the data. At present, symmetric encryption algorithms are mainly used, and some research has tried to implement public-key operation on smart sensors (Wang et al., 2006). Secondly, security protocols are used to target security features such as data confidentiality and information authentication.
For example, A. Perriget et al. proposed a security protocol for sensor networks called SPINS. Also, key management is a very important part (Perrig et al., 2002). The implementation method includes sharing a pair of keys between each pair of buildings and a pair of keys between each building and the grid (Chen et al., 2011). Intrusion detection and fault tolerance technologies also effectively reduce the damage caused by common viruses in B2G to data transmission (Elrawy et al., 2018). It monitors the network without disrupting the transmission process and defends against various intrusions from both internal and external sources, thereby ensuring system security. Finally, after implementing secure and reliable key management, B2G network authentication can be performed, which mainly includes authentication between buildings, authentication between the grid and sensors (Liu & Ning, 2004). The above techniques can ensure the security performance of the B2G data transmission process.
Proof of Data Ownership (PDP) and Proof of Data Retrieval (POR) are two commonly used protocols for data integrity verification. PDP is a protocol that supports third parties and is based on public-key technology. This property of PDP is often referred to as public verification (public verifiability). In (Zhang et al., 2019) an AMI data integrity verification scheme is proposed based on the non-dual pair and cloud platform based on the PDP and POR protocol. This scheme adopts homomorphic message authentication code technology, which effectively reduces the computational overhead and communication cost of verifying response certification information.

The main market players in the B2G ecosystem from the integration side
The goals of suppliers/retailers, DSOs, and TSOs are not aligned in the B2G integration context, as suppliers/retailers, DSOs and TSOs may want to utilize the energy flexibility of buildings differently. For instance, suppliers/retailers may want to use buildings to balance trading commitments in the energy market, whereas DSOs may want to use buildings to balance local consumption with distribution grid capacity limits, and TSOs may want to do the same for grid frequency stabilization.
ESPs can act as an integrator between buildings and the grid. ESPs have been concerned with the procurement of resources on energy markets to ensure sustained service towards the building side. In this regard, ESPs place themselves in between DSOs/TSOs and the consumer side, ESPs have to accommodate both grid management concerns presented by the DSOs/TSOs side and service considerations towards the building side.
Regulators have an important role in B2G integration as they supervise the power grid representing the interests of the community. Regulators ensure stable power and clean energy for society (Rui et al., 2011). Additionally, new roles such as aggregators are required in order to coordinate that supply and demand (Schachinger et al., 2015). Aggregators facilitate the participation of DR in the energy market (Connell et al., 2014;Saebi et al., 2016). Furthermore, the emergence of new digital systems creates new roles at utility companies, e.g., the emergence of Chief Digital Officer and Chief Transformation Officer.
Traditionally, buildings-and building equipment (controllable loads and generation facilities) have been integrated directly with transmission-and distribution systems. This approach presents considerable integration costs, and physical equipment was deployed by the grid side on the building side. However, through advances in Information-and Communication Technology (ICT), other models have emerged, to make more demand-side resources available in a grid management context. Here, Virtual Power Plants (VPPs) aggregate several demand-side assets into a single, controllable entity, which is then exposed to grid managers (Pudjianto et al., 2008). VPPs may constitute stakeholders themselves but could be deployed by either grid-or building-side stakeholders as well.
The use of a VPP abstracts the consumer layer away from grid management. Instead, the electricity profile of the VPP is exposed to grid managers, and services in this context are bought from the VPP. This means that the responsibility of coordinating consumption and production in consumer devices is delegated to the VPP. This has enabled more sophisticated utilization of consumer side resources (Clausen et al., 2017).

Discussion
The overview and the six layers in the digitalization of the B2G ecosystem are shown in Fig. 1.

B2G goals and themes
As shown in Fig. 1, the main goals of the digitalization of the B2G ecosystem are the security of supply, renewable energy resources, energy flexibility, and energy efficiency. For the electricity grid, the priority is still the security of supply, at the meantime, increasing the electricity generation from renewable energy resources. Renewable energy resources are on both the generation side and the demand side. On the demand side, energy efficiency is still the main focus, and more opportunities arise due to distributed energy resources. Although much literature has discussed consumers' opportunities to provide energy flexibility by shifting their energy use, distributed energy resources have been proved to have the highest feasibility and provide the most financial benefit for consumers. The interactions between the demand side and the grid side will increase no matter for implicit or explicit demand response.

B2G technologies
To facilitate the B2G integration, data needs to be created, collected, stored, and transferred no matter from the grid side or the demand side. The main data collected at the grid side includes the energy market data and smart meter data. Energy market data usually contains lots of different types of data, e.g., produced electricity, energy sources, biding information, etc., especially for unbundling electricity markets that usually have active wholesale markets, e.g., the Nordic Spot market. The smart meter data is usually generated on the demand side, but collected by the utilities, e.g., DSOs. However, due to more distributed energy resources installed on the demand side, the sub-meters, e.g., Fig. 1 The overview of the Building-to-Grid ecosystem digitalization meters for EV charging, meters for electricity generation by photovoltaic, are usually installed behind the smart meters that are operated and maintained by the DSOs or utilities. Therefore, DSOs or utilities are not easy to get access to.
On the demand side, besides distributed energy resources, many sensors, appliances, buildings, and energy management systems create a large amount of data. So far this kind of data is not so well collected or stored, especially for households. Even for industrial or commercial energy consumers, the benefits of investing in sensors, equipment, or system for data collection and storage are not significant.
Centralized data storage and sharing via data hub can enable B2G, especially for the communication control, and coordination between the grid and demand side. For instance, the DataHub in Denmark collects all the electricity data, but only for billing purposes. Also, there will be more B2G platforms for energy flexibility trading, e.g., participation in ancillary service by vehicle-to-grid, especially for small energy consumers (e.g., households) although they have been developed and implemented at a small scale.

B2G data sources and data management
Data sources in the B2G ecosystem are not only from buildings, the grid, or the communication between buildings and the grid but also other types of non-energy related data, e.g., climate and consumers' data. Climate data is usually used for forecasting the production from photovoltaic and the consumption from demand-side heating and cooling needs, in addition to predicting the capacity of transformers in the grid. Consumers' data might include sensitive data, which is protected by GDPR (Data Protection & Compliance). Therefore, much research and discussion on data aggregation have been in the progress, especially in Europe. However, there are two main challenges: collecting and integrating various data sources collected by different stakeholders (e.g., the electricity consumption by DSOs and heat consumption by district heating suppliers); the non-reversibility of the aggregated data that it is difficult to combine with other data sources once the data is aggregated.
In general, data management in the B2G ecosystem includes acquiring, validating, storing, protecting, and processing data, and forms policies, procedures, and best practices to ensure the accessibility, reliability, and timeliness of the data. However, since data is collected via sensors or devices, and the majority of the energy consumers cannot see the benefits of investing in sensors, equipment, or energy/building management system, the current status of the data management at the demand side is not sufficient to support B2G. Especially implicit demand response requires the demand side's fast reaction which is usually conducted automatically.
Meanwhile, frequent information exchange between the grid and buildings requires effective and efficient data management and interoperability. Although standards and protocols for the communication among the grid, the building, and B2G have been discussed and implemented, the adoption at a large scale and the harmonization between standards and protocols are still challenges.

B2G related stakeholders
The B2G ecosystem consists of actors performing different roles and even some actors who shift to perform new roles. For instance, with the ability to produce their own electricity, consumers shift their role to prosumers (producer-consumer). Meanwhile, new actors have emerged, e.g., aggregators integrating various DERs. Aggregators allow small consumers to participate in the wholesale energy market by aggregating their individual flexibility into bids that comply with energy market regulations.
B2G enables to link different stakeholders in the building and smart grid domains. The increasing number and types of market players for B2G not only create opportunities but also risks, such as security and privacy due to data sharing and control. Furthermore, there are more interactions between the demand side and the grid, and the interaction is related to data, but also information, services, and monetary related.
Although some stakeholders are active in practice and discussed in the literature, the interactions from a B2G ecosystem perspective are rarely discussed, might due to the complexity of the interactions among multiple stakeholders and unclear relationships. Especially B2G is still an unmatured market, the interactions change and are influenced by many factors, especially policies and regulations.

Emerging technologies in B2G ecosystem
The five emerging technologies (5G, IoT, big data, artificial intelligence, and blockchain) have been studied and discussed individually in the literature of the energy and building sectors, especially in recent years. They are expected to enable energy and operational efficiency, reliability and security, alternative energy, and consumers' participation in B2G.
Through IoTs, "smart buildings can automate everything from waste management to energy usage" (Newman, 2016). IoT supports the auto meter reading system to collect and monitor power consumption patterns and enables consumers to provide energy flexibility by adjusting their behavior (Islam et al., 2017). For example, homeowners switch on home appliances (e.g. washing machines and chargers) when the electricity price is relatively lower and can remotely monitor the status of their homes (Chen et al., 2011). Meanwhile, a smart grid framework within the IoT concept of using a unique IP address in each building appliance allows utilities and building owners to have access to building appliances through the internet (Shu-wen, 2011).
Furthermore, EVs integrated with IoT, GPS, and wireless communication technology enables two-way interaction (Chen et al., 2011). Through the EV sensor system, drivers can manage their batteries more efficiently while GPS navigation systems can lead drivers to the most suitable charging station (Islam et al., 2017) and available parking station (Sumi & Ranga, 2016).
The challenges of the current telecommunication (e.g. higher data rates and massive device capacity) (Schachinger et al., 2015;Pacheco et al., 2016) and the issues on the emergence of IoT, call attention to 5G (Miao & Bu, 2010). 5G allows more sensors and devices connected and flexible to serve the digitalization of the smart grid (Sumi & Ranga, 2016). 5G enables monitoring the real-time grid condition, detecting faults, and implementing self-recovery to large-scale power failures (Gidlund et al., 2017). 5G is expected to provide a superior user experience (Alqassem & Svetinovic, 2014) and significantly reducing the costs per bit and the overall system power consumption (Gore & Valsan, 2016).

Big data and artificial intelligence
Smart grid requires a system to manage the massive amounts of data evolving in the smart grid, and a cloud-based big data visual analytics framework is recommended (Munshi & Mohamed, 2016). On the other hand, big data-related challenges in the smart grid include IT infrastructure, data collection and governance, data integration and sharing, data processing and analysis, security, and smart energy management (Sagiroglu et al., 2016).
Artificial Intelligence (AI) is defined as an approach "which can improve the decisionmaking for energy consumption and human well-being" (Nigon et al., 2016). AI can provide the control algorithms that could support the whole smart grid and handle big volumes of data in the cloud (Ferreira et al., 2014). AI techniques can be applied to automate and improve the performance of the smart grid and support various applications, e.g., the integration of renewable energy resources and energy storage systems, demand response, etc., (Ali & Choi, 2020). Three artificial intelligence (AI) techniques are presented to estimate energy consumption: multilayer perceptron; radial basis function and support vector machine (Olanrewaju & Mbohwa, 2016). Because of the increasing computational power, the distributed AI, multi-agent systems, has applied more and more to solve the decentralization challenges in the smart grid (Christensen et al., 2019b).
Blockchain is a decentralized ledger that contains connected blocks of transactions, and supports peer-to-peer transactions, and provides secured distributed data sharing (Chen et al., 2011). Blockchain is being used within IoT to synchronize with other devices, e.g., to manage device configuration, store sensor data, and enable micro-payments. For example, smart vehicles can diagnose problems and monitor maintenance schedules through blockchain (Ahsan & Bais, 2017). Two main benefits of blockchain are the accessibility to the public that records and validates every transaction, which ensures the secure and reliable transaction; to create, store, and transfer digital assets in a distributed and synchronized networks (Ahsan & Bais, 2017;Huh et al., 2017). Moreover, the potential applications of blockchain in the energy system can be peer-to-peer trading, smart contracts, asset management, etc. (Andoni et al., 2019).

Challenges of the applications of the emerging technologies in the B2G ecosystem
Although these five emerging technologies can provide many benefits to the B2G ecosystem, the challenges are still significant, especially for the integration of the grid and buildings. Three main challenges.
Security and privacy B2G ecosystem needs to be secured because it contains sensitive information, data and information need to be shared, and the communication and control are mainly via the applications of IoT and 5G. Huge data created and collected requires space and power resources for storing data. Data collection and usage, e.g., for data analytics and machine learning, have to comply with the data protection regulation, e.g., GDPR. This security and privacy issue can happen everywhere in the B2G ecosystem.
Interoperability and scalability Data and information exchange between systems require interoperability. Although many standards and protocols have been proposed and discussed for B2G, interoperability is still a big challenge due to many reasons. For instance, many installed energy management systems do not allow communication between different systems and require an expensive upgrade to support B2G-related standards and protocols . Regulations do not always support or incentivize the adoption of B2G enabling technologies, the high cost of the investment in and maintenance of B2G technologies, and the low financial benefits from providing energy flexibility prevent the scalability of these emerging technologies in the B2G ecosystem.

Coordination and dysfunctional emerging behaviors of collective intelligent controls
When individually developed digital solutions for B2G integration are deploy together, there is a potential risk of emerging dysfunctional ecosystem behavior. Emerging dysfunctional ecosystem behavior happens because the control logics embedded within individually developed digital solutions cannot take the overall system behavior that emerges from deploying them together with other digital solutions into consideration during their design.
Hence, the unexpected outcome from the digitalization of the B2G ecosystem can be grid overloads and system blackouts due to constructive interference caused by the unintentional superposition of buildings' energy consumption. Constructive interference adds up the individual contributions from simultaneous electricity use and may hereby exceed the capacity of the distribution grids, causing grid overloads and system blackouts.

Conclusion
This paper investigates data management for the Building-to-Grid ecosystem with three aspects (the grid side, the demand side, and the integration side), and for each of the three aspects, this paper introduces the related data sources, data management technologies, stakeholders, and their roles. The data management in the Building-to-Grid ecosystem can be divided into six layers: goals and themes, data sources and technologies, data management, and related stakeholders. Moreover, this paper also discusses the emerging technologies (IoT, artificial intelligence, big data, blockchain, and 5G), and their potential impacts on the Building-to-Grid ecosystem.

Contributions
The digitalization aspect of Building-to-Grid has not been well discussed in the literature. This paper contributes to providing a clear picture of the Building-to-Grid ecosystem and an overview of the current practices of data management (including data sources, technologies, and related stakeholders) for Building-to-Grid.
The stakeholders and their participation in the digitalization of Building-to-Grid have not yet been addressed in the literature. This paper not only discusses related stakeholders in each of the three aspects (the grid, buildings, and the integration of buildings and grid) but also provide an overview of related stakeholders in the Building-to-Grid ecosystem. Meanwhile, the complexity and importance of interactions among related stakeholders are also emphasized.
The impacts of emerging technologies on the Building-to-Grid ecosystem have not yet been well discussed in the literature. This paper discusses five emerging technologies of 5G, IoT, big data, artificial intelligence, and blockchain, and summarizes three main challenges for these emerging technologies applying in the Building-to-Grid ecosystem, especially the integration aspect.
Compared to the energy sector or the building sector, the Building-to-Grid ecosystem is more complex, involving more stakeholders, technologies, and interactions between stakeholders and technologies. Therefore, a clear definition of the Building-to-Grid ecosystem can provide a direction for future research in this field. Based on the definition of targeted ecosystems by (Ma et al., 2021), this paper proposes a definition of the Building-to-Grid ecosystem as 'a Building-to-Grid ecosystem is a chosen geographically-focused business ecosystem within the domains of smart grid, buildings, and the integration of buildings with the grid, with related actors from all three domains, and actors interact for value co-creation'.

Recommendations and future works
Although the main scope of the paper is the Building-to-Grid ecosystem, the future design of the Building-to-Grid ecosystem should consider its role in smart cities. The design of smart cities usually includes the design of smart grid, smart water, smart buildings, smart transportation, smart mobility, and smart health. For instance, smart cities control the energy usage of the entire cities (Eungha, 2017). Therefore, the digitalization of the Building-to-Grid ecosystem should consider connecting to other ecosystems in the smart cities ecosystem, such as smart transportation, and concern the similar challenges as in the smart cities, e.g., sensors integration and abstraction capability, individual intelligence and local reasoning, dynamic human-centric services, learning and adaptation, and user privacy and security control mechanisms (Moreno et al., 2017).
Although this paper aims to provide an overview of the B2G ecosystem with a specific focus on the data sources and data management, the paper does not cover all the digitalization elements of the B2G ecosystem, e.g., the business models and challenges for related stakeholders in detail. These elements are critical for the success of the energy systems' digitalization and are recommended to be investigated in future research.
Meanwhile, although this paper borrows the concept of the business ecosystem, and proposes a definition for the Building-to-Grid ecosystem, the ecosystem research is far more complex and requires a systematic investigation and research design. Especially, ecosystem modeling and simulation have recently arisen attention in the energy sector with the applications of IoT, big data, and artificial intelligence, but is not much researched (Ma, 2019). The corresponding research not only requires participation from the energy or building domains with disciplines of engineering and computer science but also multi-disciplinary research is recommended in the future, especially with business and management perspectives.
Furthermore, the digitalization of the Building-to-Grid ecosystem does not always go as expected. As the challenges discussed in the previous section, many challenges and risks along with the digitalization transition have arisen and will be more significant in the future. Therefore, the consequences of the digital solution adoption in the Building-to-Grid ecosystem, and their impacts on the sustainability, resilience, and harmonization with the whole ecosystem perspective need to be further investigated.
Lastly, this paper discusses five emerging technologies (5G, IoT, big data, artificial intelligence, and blockchain), and other emerging technologies, e.g., quantum computing and edge computing are neglected due to less discussion in the literature. However, these technologies will take an important role in the digitalization of the Building-to-Grid ecosystem. Meanwhile, this paper does not discuss the emerging technologies and their correlations in detail due to large involved literature in each related domain. Therefore, future studies should consider addressing these aspects.