This paper proposes two bio-inspired heuristic algorithms, the Moth-Flame Optimization (MFO) algorithm and Genetic Algorithm (GA), for an Energy Management System (EMS) in smart homes and buildings. Their performance in terms of energy cost reduction, minimization of the Peak to Average power Ratio (PAR) and end-user discomfort minimization are analysed and discussed. Then, a hybrid version of GA and MFO, named TG-MFO (Time-constrained Genetic-Moth Flame Optimization), is proposed for achieving the aforementioned objectives. TG-MFO not only hybridizes GA and MFO, but also incorporates time constraints for each appliance to achieve maximum end-user comfort. Different algorithms have been proposed in the literature for energy optimization. However, they have increased end-user frustration in terms of increased waiting time for home appliances to be switched ON. The proposed TG-MFO algorithm is specially designed for nearly-zero end-user discomfort due to scheduling of appliances, keeping in view the timespan of individual appliances. Renewable energy sources and battery storage units are also integrated for achieving maximum end-user benefits. For comparison, five bio-inspired heuristic algorithms, i.e., Genetic Algorithm (GA), Ant Colony Optimization (ACO), Cuckoo Search Algorithm (CSA), Firefly Algorithm (FA) and Moth-Flame Optimization (MFO), are used to achieve the aforementioned objectives in the residential sector in comparison with TG-MFO. The simulations through MATLAB show that our proposed algorithm has reduced the energy cost up to 32.25% for a single user and 49.96% for thirty users in a residential sector compared to unscheduled load.