The sustainability of the power systems assures consumers to have efficient and cost-effective energy consumption. Consumers' energy management is one of the solutions that in fact boosts the power system stability via efficiently scheduling the appliances. In addition to energy management, consumers fulfill their low-cost energy consumption using decentralized energy generation (such as solar, wind, plugin hybrid electric vehicles, and small diesel generator). This decentralized energy generation and its trading among the prosumers and consumers help in the distribution grid stability and continuous supply. In this paper, the joint energy management and energy trading model is presented, which provides low-cost electricity consumption to the distribution system. The proposed framework is a twofold system. In the first fold, the distribution system is divided into a number of microgrids, where each microgrid electricity demand is managed using a unified energy management approach. While the local energy produced is traded among the microgrids in the second fold, through energy trading concepts that fulfill the consumers' demand without stressing the utility company. The results indicate that the proposed model reduced the electricity cost of the microgrids with maximum share of self-generation. Moreover, the results also indicate that each microgrid either fulfills its electricity demand from self-generation or purchases it from the nearby microgrid. INDEX TERMS Smartgrid, Unified demand side management, Peak to average power ratio, Consumer comfort level.. Nomenclature β 1 , β 2 Set of appliances having various priorities, e.g., β 1 ∈ {Washing machine, dish washer} and β 2 ∈{Dryer, sterilizer}, etc. γ t Peak clipping maximum limit. λ t,n v,a Consumer preference factor A n Set of appliances of consumer's n.