With the advent of smart grids, advanced information infrastructures, advanced metering facilities, bidirectional exchange of information, and battery storage home area networks have all transformed the electricity consumption and energy efficiency. There is a significant shift in the energy management structure from the traditional centralized infrastructure to the flexible demand side driven cyber-physical power systems with clean energy and energy storage system. These changes have significantly evolved the home energy management (HEM) space. Consequently, stakeholders must define their responsibilities, create efficient regulatory frameworks, and test out novel commercial strategies. P2P energy trading appears to be a feasible solution in these circumstances, allowing users to trade electricity with one another before becoming completely reliant on the utility. P2P energy trading offers a more stable platform for energy trade by facilitating the exchange of energy between prosumers and consumers. This research proposes a novel demand and generation prediction techniques of P2P HEMS for optimal energy using the Multi-Objective Optimization model. An enhanced Wild Horse Optimization technique was first used to summarize historical records' qualities. Then, the Bi-LSTM is used to predict the demand and generation values. Furthermore, a Grasshopper optimization (GHO) approach is employed to fine-tune the model's hyperparameters. The P2P HEMS demand and generation prediction framework is offered with a probabilistic and fault evaluation that upholds load flow balance between need and supply for continuous operations. It results in an intelligent community transforming cities into smart ones, opening new avenues for scientific research in terms of technological developments.