Pātuhitia tēnei: Energy Production, Load and Battery Management Framework with Supporting Methods for Smart Microgrids