Introduction

The adoption of the Movement Control Order (MCO) during the COVID-19 pandemic has impacted global residential energy consumption patterns. A statistical study conducted on residential electric appliance utilization online indicates occupants’ poor integration in appliance control. Consequently, the hourly usage of residential appliances increased significantly during the MCO period and after the MCO from March to June 2020, especially an air conditioner that doubled during MCO and increased by 5 hours after the first MCO (F. Shahzad et al. 2020a, b; K. Shahzad et al. 2020a, b; Shahzad et al. 2021; Shakoor et al. 2020) (see Fig. 1), while utilization of the majority of the appliances considered decreased significantly after the MCO period (Fareed et al. 2020; Iqbal et al. 2020). This indicates that the pandemic opens on to a surge in the continued use of the air conditioner despite a partial resumption of office activities.

Fig. 1
figure 1

Home appliance energy consumption before, during, and after MCO

Integration of occupancy information in HVAC system control must be optimized to fully exercise energy consumption control on the HVAC system to eliminate energy waste (Aliero et al. 2021). Recently, researchers have applied direct sensing technologies such as cameras, wearables, and environmental sensing alongside machine learning techniques to enable occupancy-based control on existing and new HVAC system infrastructure to reduce energy consumption waste (Ahmad et al. 2021) . Many of the camera-based (Abade et al. 2018; Cao et al. 2018; Ahmad et al. 2021) and wearable (Castro et al. 2017) solutions so far proposed can obtain training datasets without user interaction with solid performance. Although direct sensing methods have proven reliable performance for occupancy estimation problems, they still present serious issues, including privacy challenges, complex processing, expensive hardware, and installation feasibility (Cao et al. 2018). Environmental sensing is considered as a viable alternative to overcome the issues and limitations of direct sensing by measuring the effects of occupant presence in the building, such as changes in temperature, humidity, CO2 concentration, among others.

Despite many existing occupancy estimation solutions in environmental sensing methods, there is still a lack of attention paid to generating a publicly accessible robust dataset that can be easily used to compare different machine learning algorithms. The existing solutions (Brennan et al. 2015; Schwee et al. 2019; Szczurek et al. 2017) have made their datasets publicly accessible. Still, most of the datasets are poorly documented with occupant ground truth such as occupant number range, which is considered key attributes to estimate the building occupation. This study proposed a novel multi-wireless device data model that incorporates environmental sensing to obtain indoor condition data and camera sensing to obtain occupant’s numbers for training purposes. The primary objectives of this research are to collect quality datasets that can be used to compare different machine learning algorithms for occupancy estimation problems to reduce air condition unnecessary energy consumption. The key contributions in this study include:

  1. i.

    collection and quality verification of indoor environmental conditions and occupant datasets

  2. ii.

    evaluating machine learning algorithm on the proposed framework in living room

  3. iii.

    modeling single room with two zones to monitor and improve air condition energy efficiency

To achieve this task, only a random forest regressor algorithm is used to verify dataset quality during data collection and occupancy detection and estimation tasks, although different machine learning algorithms could be integrated easily into the proposed approach. The performance evaluation measures show a high F-score value and minimum mean square error compared to the existing single environmental sensing baseline design (Candanedo and Feldheim 2016). Furthermore, air condition energy usage was monitored for 24 hours using a programmable thermostat, which reveals the excess usage of air condition by an average of 5 hours. To improve the current state, a one-room with two zones is modeled using DesignBuilder. The first zone depicts the HVAC programmable thermostat (Meana-Llorián et al. 2017). While in the second zone, occupants number variables are added in addition to variables proposed in (Meana-Llorián et al. 2017) to illustrate the random nature of the building occupants in a typical living room. The results analysis shows that the occupancy-based adaptive control can optimize energy usage by an average of 50% if the occupant participates in a demand response program and 25% without significantly compromising the comfort level (keeping the room temperature within the range of 19–21 °C).

It is essential to note that this study primarily focuses on estimating occupancy in enclosed rooms based on indoor environmental factors. The outdoor environmental factors are beyond the scope of this study. In addition, because temporal dependency in the data is not considered, the indoor environment is regarded as static. Furthermore, while the proposed solution design considered integrating into other building management services (such as intrusion detection, emergency system, and energy management), the actual integration with such systems is also beyond the scope of this study.

The rest of the study is organized as follows. “Literature review” section presents the related work on indoor occupancy detection and estimation. “Proposed framework” section presents the proposed framework. “Model training and testing” section provides results on occupancy detection and estimation experiment. Subsequently, “Occupancy and air condition usage monitoring” section provides results on energy-saving potential simulations. “Conclusion” section presents research conclusions and future work.

Literature review

Integration of occupancy detection and estimation application in a control system is essential to support demand control ventilation. The integration has been achieved through various forms, including occupancy detection, occupancy estimation, occupancy recognition, and occupancy activity monitoring (Ahmad et al. 2021). Table 1 summarizes the existing studies on occupancy-based demand control ventilation.

Table 1 Occupancy-based demand control ventilation

The environmental sensing approach predicts room occupation by measuring indoor conditions. The sensor modality can be modified in many indoor sensing applications, including multi-sensing technology to observe concentrations of volatile organic compounds in the air. Cameras (infrared and optical cameras) are used alongside machine learning to carefully analyze and capture image frames for occupancy detection and estimation in commercial and residential buildings. The fusion modalities are considered to differentiate human occupancy and other object emitting thermal heat in the environment and support night vision prediction. The camera-based approach can accurately handle binary and multi-class occupancy predictions, up to 96% and 26% energy-saving potential.

Wearables and acoustic approaches use a product of tasks completed by other systems, which can track the occupancy location. ML model can obtain signal intensity from statically positioned beacons in a target space to obtain a fine-grained occupant location and achieve the location accuracy of five meters. Activation of specific sensors with established positions has previously been used in passive infrared and acoustic sensors to obtain occupancy and location details using a heterogeneous sensing network. In these studies, a multimodal data fusion and deep learning method were employed to estimate occupancy.

Proposed framework

Dataset quality is a key factor for most real-time applications to drive effective modeling. A collaborative intelligence between environmental sensing and camera can support a collection of high-quality datasets. Datasets used are collected in residential building settings in a living room in a house consisting of five different rooms located at the Taman Teratai, Johor, Malaysia, with a tropical climate year-round with average temperatures starting from 25 to 30 °C throughout the year. The living room is being designed for occupant’s gatherings activities such as resting, eatery, watching TV, and other social gatherings. The indoor condition data is collected using sensors installed in the area of interest (see Table 2) to monitor indoor environmental conditions such as temperature, light illuminance, relative humidity, and CO2 concentration.

Table 2 The various sensor data sources

A high-level overview of the overall framework proposed in Fig. 2, consisting of the room occupancy measurement (camera and environmental sensing approaches), quality assessment of candidate record, recorded training dataset, and random forest model, performs prediction and sends the output value to the fuzzy system. These outputs are used to drive or generate the appropriate setpoint temperature for the HVAC system using a fuzzy inference engine depending on the occupant’s choice or behavior. Each variable in the dataset record stream (carbon dioxide, temperature, humidity, light intensity, humidity ratio, and occupant) essentially contains feature correlated to the occupant. Each time the sensors measure the readings of the occupant surrounding, the corresponding occupant number is capture by a camera and recorded in a dataset sheet. But the quality of these record streams can be influence by a specific event, such as a door open during entrance or exit from the building. Each time such an event happens, it takes time for the record stream to rebuild the actual level that tallies with the occupants in the building.

Fig. 2
figure 2

Proposed occupancy detection and estimation framework

The study adopted Candanedo and Feldheim (2016) for environmental sensing and Cao et al. (2018) for the camera. To ensure the quality dataset is recorded, 30-min interval is set between the previously registered record stream and candidate record.

Let donate dataset stream captured by sensors at a point in time to be \(record(t)\) with a list of features \({f}_{1}\dots {f}_{n}=record(t)\). Therefore, \({f}_{1}\left(record\left(t\right)\right)\dots {f}_{n}(record\left(t\right))\) is related to the occupant’s presence in the building at a point in time \(t\), where \(fi\left(t\right)\in \left(\check{{f}_{i}}\hat{{f}_{i}}\right)\). Let donate occupant number with label \(l\left(t\right)\) captured by the camera corresponding with the dataset stream obtained by environmental sensors. Therefore, the complete dataset stream record collected for training at a time can be donated as \(r\left(t\right)=\left(record\left(t\right)\right), l\left(t\right)\). At this point, dataset stream with no corresponding label \(l\left(t\right)\) assigned is known as candidate record and a dataset stream with the corresponding label \(l\left(t\right)\) assigned is known as a recorded record. Let a dataset of recorded records represent \(p\). The objective is to verify the quality of record before been record in \(p\) to avoid a poor \(p\) by ensuring sensors data stream match corresponding occupant label \(l\left(t\right)\) that was assigned by the camera using the rule-based classifier. In this study, a decision trees’ algorithm proposed in (Chen and Zhou 2020) is deployed to simplify and optimize the analysis of the (if-then) rules.

Data collection and processing

The dataset collection starts on April 1st, 2021, to April 28th, 2021, using continuous readings. The only dataset with full-day readings and more than three streams’ columns in a raw is considered. Additionally, records are swapped to avoid revealing occupancy schedules when datasets are published, as reported in Schwee et al. (2019) that CO2 concentration can be deanonymized for susceptible privacy attacks. For odd days (Sunday, Tuesday, and Thursday), the two consecutive rows’ streams are randomly swapped, while for the even days (Saturday, Monday, and Wednesday), the first two rows’ streams are swapped sequentially. Even though it is not considered in a recent study (Schwee et al. 2019), the study decided to introduce and compute the humidity ratio from the original dataset stream to improve occupancy estimation accuracy.

Although the graphical representation for assessing normality requires a great deal of expertise to prevent incorrect interpretations, the data for graphic interpretation is usually presented in histograms or Y and X vectors. According to Gregorutti et al. (2016), suppose \(Y\) is the variable that depends on the regression matrix of variables \(X\). If \(X\left({x}_{1},{x}_{2},{x}_{3},\dots {x}_{n}\right)\) are jointly normal, then \(Y\) is said to be conditionally on \(X\) and \(\mu =f\left(X\right)\) is normally distributed vector. Therefore \(Y\) and \(\mu\) can be expressed as:

$$\begin{array}{c}Y\vert X\sim N\left(\mu=f\left(X\right),\sigma^2\right)\\\mu=f\left(X\right)={(\beta}_0+\beta_1\ast x_1+\beta_2\ast x_2+\dots\beta_n\ast x_n)\end{array}$$
(1)

The graphical presentation of the normality distribution of the sample dataset is conducted using the Q-Q plot (see Figs. 3 and 4).

Fig. 3
figure 3

Temperature, humidity, and light dataset normality check

Fig. 4
figure 4

Occupancy, CO2, and humidity ratio dataset normality check

The analysis indicates that the dataset points do not fully follow standard distribution consist of slight variance, requiring data analysis at this stage to achieve a Gaussian distribution. After manual inspection of the unfitted points, it was concluded that the skew is not caused by inaccurate sensor readings or recordings but is spontaneously created and is not inherently a concern and cannot affect the model prediction results. The distributions of unfitted points appear in all variables, with more extreme values in the CO2 and occupancy variables. According to several experiments, about 1 in 340 observations in a regular distribution would be at least three standard deviations apart from the mean (Zittis 2017). However, in smaller datasets, random chance can contain extreme values. In other words, producing odd values naturally is routine, and there is nothing wrong with these data points. Thus, even though they are rare, they are a natural part of the data distribution.

This study uses Pearson’s product-moment coefficient (PPMC) metric for generating a correlation coefficient value. PPMC measures the strength of dependency between the variables x and y when given a set of paired (x,y) values between −1 and +1 (Candanedo and Feldheim 2016). Fig. 5 present the computed PPMC values using six variable parameters with values vary from −1 to 1. 1 indicating a heavy positive correlation label shaded with white background color, followed by 0.9 shaded with red background color and so forth to 0.00 and −0.00 shaded with a green background color indicating a weak correlation between the variables. Predictors that are not correlated with predicting variables at all variables or with weak correlation values are most likely candidates to remove from the model using variable permutation importance measure known as feature selection. Furthermore, it is recommended that if two variables are highly correlated, only one of them should be considered to simplified models, and simpler models are easier to understand.

Fig. 5
figure 5

Measured correlation values of the variables

Variable feature selection

Feature engineering is essential in developing ML models, which requires removing features with weak correlation before deploying the dataset sample into the model for evaluation. A variable importance measure metric in Gregorutti et al. (2016) is considered to remove uncorrelated variables parameters. The theory in Gregorutti et al. (2016) suggest for predicting variable Y and predictors \(X=({X}_{1},\dots ,{X}_{p})\) be a vector of random variables. The rule \(\widehat{\mathrm{f}}\) in regression setting for predicting variable Y is a function that can be measure using the values in \({\mathbb{R}}\). The prediction error of \(\widehat{\mathrm{f}}\) can be defined by \(\mathcal{R}\left(\widehat{\mathrm{f}}\right)=\left[\left(\widehat{\mathrm{f}}\left(X\right)-{Y}^{2}\right)\right]\) and object is to calculate the conditional expectation \(\mathrm{f}\left(x\right)={\mathbb{E}}\left[Y|X=x\right]\). Similarly, let \({\mathcal{D}}_{n}=\left\{\left({X}_{1}, {Y}_{1}\right), \dots \left({X}_{n},{Y}_{n}\right)\right\}\) be a set of learning of \(\mathcal{n}\) replications of \(\left(X,Y\right)\) where \({X}_{i}=\left({{X}_{i}}_{1},..,{{X}_{i}}_{p}\right)\). Since the true prediction error of \(\widehat{\mathrm{f}}\) is unknown in practice, observation of a test dataset (\(\overline{\mathcal{D} })\) is considered for prediction, and therefore, \(\overline{\mathcal{D} }\) can finally be presented as:

$$\overline{\mathcal{D} }: \widehat{\mathcal{R}}\left(\widehat{\mathrm{f}} , \overline{\mathcal{D} }\right)=\frac{1}{\overline{\mathcal{D}} }\sum\nolimits_{i:\left({X}_{i},{Y}_{i}\in \overline{\mathcal{D} }\right)}{Y}_{i}-\widehat{\mathrm{f}}{\left({Y}_{i}-\widehat{\mathrm{f}}\left({X}_{i}\right)\right)}^{2}$$
(2)

Permutation variable importance is a model inspection technique in Breiman (2001) that has shown proficiency in non-linear estimators like our model and therefore adopted in this study. The technique considered predictors \({X}_{i}{X}_{j}\) as the critical predicting \(Y\) from (see equation 2). If the link between the feature \({X}_{i}{X}_{j}\) and \(Y\) is broken, the increase in prediction error score may be observed. The score value in the model reflects how much the model is dependent on the feature. This methodology has the advantage of being model agnostic, allowing it to be measured several times with various function permutations. To demonstrate this model, Breiman (2001) randomly permute the observations of the \({X}_{i}{X}_{j}\).

Formalizing the statistical permutation value calculation is as follows: define a group of out-of-bag samples \(\left\{{\overline{\mathcal{D}} }_{n}^{t}={\mathcal{D}}_{n}\backslash {\overline{\mathcal{D}} }_{n}^{t}, t=1,\dots ,{n}_{tree}\right\}\). Let \(\left\{{\overline{\mathcal{D}} }_{n}^{tj}, t=1,\dots ,{n}_{tree}\right\}\) represent permuted out-of-bag samples by randomized permutations of the \(j\)-th variable’s values in each out-of-bag subset. The variable \({X}_{j}\)’s statistical permutation value is defined as:

$$\widehat{I}\left({X}_{j}\right)=\frac{1}{{n}_{tree}}\sum\nolimits_{t=1}^{{n}_{tree}}\left[\widehat{\mathcal{R}}\left(\widehat{\mathrm{f}} t, {\overline{\mathcal{D}} }_{n}^{tj}\right)-\widehat{\mathcal{R}}\left(\widehat{\mathrm{f}} t, {\overline{\mathcal{D}} }_{n}^{t}\right)\right]$$
(3)

This quantity is the statistical equivalent of the permutation importance measure \(\widehat{I}\left({X}_{j}\right)\) recently formalized by Zhu et al. (2015). Let \(\left({X}_{j}\right)=\left({X}_{1},\dots ,{X}_{j}^{\mathrm{^{\prime}}},\dots , {X}_{p}\right)\) be the random vector such that \({X}_{j}^{\mathrm{^{\prime}}}\) is an independent replicate of \({X}_{j}\) that is also independent of \(Y\) and all other predictors, and the permutation significance measure is provided by:

$$I\left({X}_{j}\right)={\mathbb{E}}\left[{\left(Y-\mathrm{f}\left({X}_{\left(j\right)}\right)\right)}^{2}\right]-{\mathbb{E}}\left[{\left(Y-\mathrm{f}\left(X\right)\right)}^{2}\right]$$
(4)

In the expression of \(\widehat{I}\left({X}_{j}\right)\), the permutation values of \({X}_{j}\) mimics the identical and independent duplicate of the distribution of \(\left({X}_{j}\right)\) in \(I\left({X}_{j}\right)\). Thus, equation 4 can compute the correlation index value of predicting variable and independent variable as presented in Table 3.

Table 3 Predicting variable versus independent variable correlation index

The predictor’s correlation index in relation to predicting variable is computed and displayed in Table 3 to visualize weak correlation values. As presented in Table 3, the variable predictor Date demonstrates a weak correlation index and is removed from the original dataset. The remainder of the variables can feed the model to train the machine learning model and measure its accuracy against the test dataset.

Model training and testing

Typically, datasets are split inform of the train and test ratio during the model training when ML algorithms are employed to make predictions on data to measure their prediction performance. The technique is straightforward and quick for assessing model prediction performance on various ML methods and choosing among the optimal methods that fit the model prediction problem. The technique entails shuffling and splitting the original dataset into training and testing in a ratio, such as 70:30 see (Fig. 6). The first portion, known as the training dataset, is used to match the model. The second portion, known as the test dataset, is used as input to variables’ dataset to feed the model to test prediction and measure the prediction outcomes.

Fig. 6
figure 6

Ratio of training and test dataset

Candidate model

Random forest (RF) model is chosen for inquiry to further measure its performance for both binary classification (occupancy detection) and regression prediction problems (occupancy estimation). This model is not very complex; its existing implementation and recent developments have shown solid performance in many areas. The implementations in this work use the scikit-learn Python library, and details about default algorithm settings can be found in the library documentation ("The Python Standard Library" 2021).

RF is a collection of various decision trees that are applied sequentially from a root (parent) node to a terminal (or child) node to predict the behavior described by trained data (Rodriguez-Galiano et al. 2014). This technique provides several conditional rules as easy as comparing a sensor reading to a threshold to match data samples by related traits. Each decision tree employs bootstrap sampling, also known as bagging (Breiman 1996), which essentially used two-thirds of the training samples for prediction and the remainder for evaluation of prediction accuracy for both deep or very deep trees. This implies each tree in RF is working against the same target but is given separate portions of the training data to learn from. The outcomes from all the trees are added together to generate the results. These rules influence how the models handle bias and uncertainty in their forecasts. The binary classifier uses CO2 as predicting variable to tell whether a room is occupied or vacant. The performance evaluation for RF binary classier is presented in Table 4. The number of decision trees that the model can use to match the data is generated from classification and recursive splitting from the dataset during analysis.

Table 4 RF binary occupancy prediction results using CO2 data

The evaluation is carried out to test and verify the performance of the model against new data. This is essential in many cases, especially on the control system where the model’s performance can exhibit different behavior on the new dataset. Therefore, the scoring bin in Table 4 holds the dataset record split into a training and a testing dataset. The binary classifier prediction performance on ranges from 58.3 to 99.6% accuracy, 73.6 to 99.7% F1 score, 58.3 to 99.9% precision, and 97.8 to 100% recall.

Occupancy detection using binary classification cannot provide enough information about room occupancies which is essential to optimize energy proportional to the number of occupants in the building. For this reason, the proposed RF model performs dataset recursive splitting and regression to estimate room occupancies using five indoor conditions. Fig. 7 represents the model performance analysis using different performance measures.

Fig. 7
figure 7

Occupancy estimation model performance evaluation

Typically, the single metric alone cannot provide enough information for model performance. Therefore, other members of metrics are considered including:

$$\text{F-Score}=2\times \left(\frac{\mathrm{Precision}\times \mathrm{Recall}}{\mathrm{Precision}+\mathrm{Recall}}\right)$$
(5)

Ultimately, it is essential to have an overall metric to trade-off the precision and the recall performance by measuring a single grade value score. Thus, it makes sense to merge the precision and recall metrics (see equation 5). The overall F-score performance for RF is excellent, achieving up to 99.3% (see Fig. 7).

Mean absolute error (MAE) refers to the magnitude of the difference between the model prediction observation and the actual value of that observation which is calculated for the whole group, and therefore, the error between the actual value and the predicted value is 0.0193 (see Fig. 7). Mathematically MAE can be presented as:

$$\mathrm{MAE}=\left(\frac{\sum_{i=1}^{n}{\text{abs}}\left(yi-\lambda \left(xi\right)\right)}{n}\right)$$
(6)

Root mean square error (RMSE) demonstrates how far projections differ from observed true values. Whether during testing or cross-validation, the residual difference between prediction and ground truth for each data point  is referred to as RMSE. The RMSE in RF model is 0.071 (see Fig. 7). Mathematically RMSE can be presented as:

$$\mathrm{RMSE}=\sqrt{\frac{\sum_{i=1}^{n}\parallel y\left(i\right)-\widehat{y}\left(i\right){\parallel }^{2}}{N}}$$
(7)

Relative squared error (RSE) is used to evaluate model efficiency by comparing it to that of a basic predictor. The RSE in RF performance is 0.0052 (see Fig. 7). Mathematically RSE can be presented as:

$${E}_{i}=\left(\frac{{\left(\sum_{j=1}^{n}{P}_{ij}-{T}_{j}\right)}^{2}}{{\sum_{j=1}^{n}\left({T}_{j}-\overline{T }\right)}^{2}}\right)$$
(8)

Relative absolute error (RAE) is expressed as a ratio when a mean error (residual see equation 9) is opposed to errors produced by a negligible or naive model. The model RAE is 0.022 (see Fig. 7). Mathematically RAE can be presented as:

$${E}_{i}=\frac{\sum_{j=1 }^{n}{|P}_{ij}-{T}_{j}|}{\sum_{j=1}^{n}{|T}_{j}-\overline{T }|}$$
(9)

Coefficient of determination (CD), also referred to as R2, clarifies how much a model will perform when replicating observed results. It provides information on the probability of possible events occurring within the expected outcomes. The R2 value produced by RF model is 99.4% (see Fig. 7). Mathematically CD can be presented as:

$$\mathrm{R}2=\frac{n\left(\sum xy\right)-\left(\sum x\right)\left(\sum y\right)}{\left[n\sum {x}^{2}-{\left(\sum x\right)}^{2}\right] \left[n\sum {y}^{2}-{\left(\sum y\right)}^{2}\right]}$$
(10)

Average log loss (ALL) uses to evaluate the model prediction efficiency based on the likelihood of a record being categorized in a particular class and then assign the data point as one of two classes (1 or 0) depending on whether the probability exceeded a threshold value. The proposed RF model achieved R2 score of 0.027 (see Fig. 7). Mathematically ALL can be presented as:

$$\mathrm{logloss}=\frac{1}{n}\sum\nolimits_{i=1}^{n}{\mathrm{logloss}}_{i}$$
(11)

where:

$$\begin{array}{c}{\mathrm{logloss}}_{i}=-\left[{y}_{i}\mathrm{ln}{p}_{i}+\left(1-{y}_{i}\right)\right]\mathrm{ln}\left(1-{p}_{i}\right)\\ \mathrm{logloss}=- \frac{1}{n}\sum_{i=1}^{n}\left[{y}_{i}\mathrm{ln}{p}_{i}+\left(1-{y}_{i}\right)\right]\mathrm{ln}\left(1-{p}_{i}\right)\end{array}$$

Occupancy and air condition usage monitoring

The main objective of binary control is to ensure air condition is turned off when the room is vacant to avoid unnecessary energy consumption. Figure 8 plots the information obtained during the room condition monitoring campaign. Notice in Fig. 8 from 12:00 to 5:00 AM, the living room is vacant, air condition is off, and room temperature is high. Because of the challenge to obtain the aggregated energy consumption data in a time series as there are many mixtures of energy consumption from various appliances and built-in facilities, a watt analyzer is attached to a power outlet to monitor the waveform of air condition power consumption in a time series.

Fig. 8
figure 8

24-h data on indoor occupants, temperature, and air condition operation

Notice from 6:00 AM occupancy keeps on rising from 1 to 5 and drops at 8:00 AM. From 11:00 AM to 1:00 PM, 6:00 to 8:00 PM, and 11:00 PM, the room is vacant, but the programmable controller predicts that the room is occupied during this time. This is because the controller works based on the occupancy schedule assumption, which is modified due to MCO policy. Besides MCO policy, further investigation reveals that indoor CO2 is used as an indicator of the room being occupied. Thus, when no occupants leave the building, it takes a long time for CO2 to disappear, which also contributes to the poor performance of the controller. This results in excess energy consumption for an average of 6 h a day. The total excess energy consumption depends on room temperature and rate of air condition operation.

Furthermore, notice the rise of a waveform of air condition operation from 1:00 to 7:00 PM. This is because, during this period, the outdoor temperature is high, affecting the function of an air conditioner to maintain the desired occupant comfort. However, despite the increase in air condition operation, discomfort can be observed during this period.

Occupancy estimation-based air condition control

DesignBuilder is used to model two separate zones, each attached with a modified HVAC system of 10 kW, using RTP tariff to demonstrate the effectiveness of occupancy estimation on air condition control. The first zone uses the controller proposed IoFClime in Meana-Llorián et al. (2017), and the second zone uses the proposed controller. The final model is sent to EnergyPlus together with local weather. The controller’s goal is to adjust the setpoint temperature to attain the desired comfort based on the predicted number of occupants in the building. Desired temperature, energy consumption, and comfort satisfaction achieved are used as evaluation indices to evaluate the performance of the proposed model under the following three scenarios:

  1. (a)

    The occupants are worried about the energy consumption cost and are knee to participate in the demand response programs. So, the controller adjusts the setpoint temperature remarkably, especially during very hot and extreme temperatures, to attain the desired comfort as possible.

  2. (b)

    The occupants worried about the thermal comfort satisfaction. Thus, the controller slightly adjusts the setpoint temperature.

  3. (c)

    The occupants balance thermal comfort satisfaction and energy consumption cost. Accordingly, the controller reacts moderately to trade-off energy consumption with thermal comfort; the setpoint changes are not as remarkable as in scenario 1 and slightly as in scenario 3.

Setpoint temperature control

It is important to note that 19 °C is considered the desired setpoint with ten constant occupants throughout the experiments. Fig. 9 represents the time series room temperature in Johor Bahru, Malaysia, with air-conditioning turned off. Notice in Fig. 9, from 8:00 to 9:00 AM, the temperature is considered hot, from 10:00 to 11:00 AM and 3:00 to 5:00 PM are considered very hot, and 12:00–2:00 PM is considered extremely hot. The controller’s objective is to adjust the setpoint according to the number of occupants and temperature conditions to achieve the desired comfort without risking the occupants leaning.

Fig. 9
figure 9

Ambient temperature condition in Johor, Malaysia

Notice in Fig. 10, both controllers keep the indoor temperature within the range of 24 °C. This is because the occupant’s choice is to save energy and avoid the aggressive air condition operation. However, notice in Fig. 11 and Fig. 12, the proposed controller was able to adjust setpoint temperature to make indoor temperature closer to the desired comfort. Except during extremely hot temperatures, the controller finds it challenging to maintain. Notice the performance of the proposed controller is better than IoFClime in stabilizing the room temperature and waveform frequency is lower than IoFClime. The proposed controller is designed with a feedback loop that updates the controller about the room temperature condition. Whenever the room temperature goes closer to the desired comfort, the speed of the air conditioner is reduced by adjusting the setpoint temperature, unlike the IoFClime that used deadband setpoint control.

Fig. 10
figure 10

Scenario 1

Fig. 11
figure 11

Scenario 2

Fig. 12
figure 12

Scenario 1

Comfort analysis

The interpretation of thermal comfort analysis focused only on a proposed controller. The scenarios considered and the result is presented in Fig. 13. Nineteen degrees Celsius is chosen as desired indoor comfort for the ten occupancies. Every 30 min, the occupancy feedback on comfort feeling is analyzed in the zone, passed to the controller through a feedback loop, and expected to react based on the information received. Notice in the first scenario, the thermal comfort perception is as follows: 10% report feeling normal, 35% report feeling warm, 40% report feeling hot, and 15% report feeling very hot throughout the ventilation activities. In the second scenario, 88% report feeling normal, and 12% report warm comfort throughout the cooling activities. In the third scenario, 78% report average comfort while 22% report warm comfort through the cooling activities.

Fig. 13
figure 13

Analysis of occupant thermal comfort perception of the proposed approach

Energy consumption

In scenarios 2 and 3, the electricity tariff variation has no greater influence on energy consumption as occupancy gives thermal comfort preferences over energy usage. The air conditioner must maintain zone temperature relatively closer to the initialized setpoint (desired temperature). During the peak hour, compressor is turned on and stays on until the zone temperature drops to the closer level as the desired temperature is set on the thermostat. The compressor turns off after the desired temperature is reached, and the zone temperature rises again. A cycle of the air conditioner is determined by the compressor turning on and off.

An air conditioner’s cycle time is when it takes to operate to keep the zone at the desired temperature. As demonstrated in Fig. 11 and Fig. 12, the compressor works significantly for longer periods to lower the zone temperature, increasing the cycle time. The existing approach’s energy consumption is 18.6328 kW, 32.4284 kW, and 25.6724 kW, while the proposed approach consumed 12.7467 kW, 33.4933 kW, and 19.96 kW in three settings, as indicated in Fig. 14. The energy consumed in scenarios 1 and 3 for the existing controller is much greater than the proposed approach’s energy consumed. Since our approach uses a feedback loop, it provides continuous operation (long cycles); hence, it consumes less energy by 50% in the first scenario and 25 % in the third scenario than the existing IoFClime technique.

Fig. 14
figure 14

Comparison of energy consumption under three settings

Conclusion

Indoor occupancy information and modeling have been considered as key contributors for building energy efficiency, and research highlights the requirements for further investigation in this application area. Particularly occupancy prediction status in the buildings can save an average of 50% unnecessary energy consumption, thereby reducing the demand for building energy generation and consumption.

Research on various technologies has been researched, including cameras, wearables, and passive infrared sensors, to modify or replace existing building infrastructure to optimize building energy usage. These efforts can be classified into direct approaches based on technologies such as cameras and wearables that solely rely on direct contact with occupants to report the presence. On the other hand, the indirect or environmental sensing approach inferred occupants’ status by measuring the effects of occupant presence in the building. These include changes in temperature, humidity, CO2 concentration, among others. Even though the direct approach has proven a solid performance for counting the occupancy, environmental sensing is considered to be a viable alternative to overcome the weakness of the direct approach that presents serious issues, such as privacy, complex processing, expensive hardware, and installation feasibility.

Despite many solutions in environmental sensing to overcome the problem of occupancy detection and estimation, much attention has not been paid to publicly accessible robust datasets that enable the comparison of different algorithms to be easily compared. The proposed framework that uses collaborative intelligence obtained a high-quality dataset, and RF model is trained to count occupant numbers in the building. The proposed solution is tested in the living room with a prototype system, and the model’s prediction results obtained achieved a performance accuracy of 99.3%.

Three different thermostat settings on air condition were used to control the indoor comfort using a two-zone ventilation system to keep indoor comfort consistent with the number of occupants. The simulation is conducted using EnergyPlus software with local climate data. The Fanger model’s thermal comfort analysis demonstrates poor comfort performance in the first scenario, satisfactory performance in the third scenario, and remarkable performance in the second scenario. Furthermore, it demonstrates up to 50% of energy can be saved in the first scenario (if the occupant is willing to compromise his comfort) and 25% in the third scenario (if the occupant wishes to balance energy consumption with thermal comfort).