Energy Efficiency in Smart Homes and Smart Grids