Active Inference for Energy Control and Planning in Smart Buildings and Communities