Highlights• Develops a real-time electricity pricing structure in conjunction with TOU electricity tariff. • Develops an adaptive strategy in the framework of the smart grid using MPC design. • Develops a new approach to optimization of the cost of energy in real-time electricity pricing environment. • Designs an optimal strategy for integrating PV with battery storage to the grid in realtime electricity pricing scheme. • Gives the consumer an opportunity to deal with the cost of electricity usage.Abstract-This paper presents an approach to the energy management and control of the effective cost of energy in real-time electricity pricing environment. The strategy aims to optimise the overall energy flow in the electrical system that minimises the cost of power consumption from the grid. To substantiate these claims different cases of time-of-use (TOU) and renewable energy electricity tariff, i.e. in summer and winter seasons, and the robustness of system is analysed. A given energy demand for commercial usage in the city of Tshwane (South Africa) is used to investigate the behaviour of the designed method during low and high demand periods. As grid integrated renewable energy resources, photovoltaic (PV) is an important consideration in assuring excellent power supply and environmental issues in the commercial building. An adaptive optimal approach in the framework of model predictive control (MPC) is designed to coordinate the energy flow on the electrical system. The results show that the proposed adaptive MPC strategy can promote the new approach of an optimal electrical system design, which reduces the energy cost to pay the utility grid by about 46 % or more depending on the set target. Index Terms-Battery bank, Energy management, Model predictive control, Photovoltaic, Smart grid, Time-of-use tariff. NOMENCLATURE state matrix (-) input matrix (-) cost of electricity to pay or output vector (Rand or R) 1 cost of electricity to pay the utility grid (Rand or R) 2 cost of electricity consumption from the renewable energy (Rand or R) 3 cost of electricity consumption by the load (Rand or R) output matrix (-) 1 input vector (kWh) 1 energy flow of the utility grid (kWh) 2 energy flow of the PV (kWh) 3 energy flow of the charging of battery (kWh) 4 energy flow of the discharging of battery (kWh) energy consumption (kWh) charging energy on battery (kWh) discharging energy from battery (kWh) The deployment of buildings' energy management systems started in the 1970s when the development of direct digital control signal from the advent of a microprocessor was introduced.It offers the ability to control and manage the energy system by providing the users with a betterquality environment. Since its inception, it has been observed that the development of energy Page 3 of 38 energy demand (kWh) energy drawn from battery (kWh) energy consumption at sample (kWh) energy supply from grid (kWh) maximum energy from battery (kWh) energy nominal on battery (kWh) energy supply from photovoltaic array (kWh) PV energy consumption at...