# Towards the Real-World Deployment of a Smart Home EMS: A DP Implementation on the Raspberry Pi
## 4 Embedded Implementation of the Chosen EMS
### Dynamic Programming Algorithm
Two metrics were computed for the forecasting errors, namely the Normalized Root Mean Square Error (NRMSE) and the Normalized Maximum Absolute Error (NMAE). It is worth noting that the error metrics of PV and wind generation were normalized with respect to the nominal power of each renewable generator. On the other hand, error metrics on load demand were normalized with respect to the maximum contractual power. The values of the forecasting error metrics for all users during the 30 days are shown in Table 5; the maximum NRMSE and NMAE values are about 8% and 50%, respectively. The same table also reports the cumulated errors obtained combining generation and load NRMSE values in quadrature. As an example of the EMS outputs, the plots of battery power and SOC profiles for Users B and C in the first three days of the considered month are shown in Figure 5c,d. These plots are also representative of the profiles of the other two users. As expected, the maximum battery charging/discharging powers are not exceeded. A plot of the aggregated user-committed GEPP versus the actual cumulative grid power in the same three days is shown in Figure 6. As the figure shows, the two curves overlap each other almost perfectly. Furthermore, Figure 7 shows the difference between planned and measured aggregated GEPP. In particular, the predictability of the power profile is clearly expressed by the error metrics that were computed on the GEPP, as shown in Table 6. The normalization factor for the metrics of each user was the maximum contractual power (i.e., 3 kW for Users A and C, and 4 kW for Users B and D). On the other hand, the normalization factor for the cumulative GEPP was the maximum cumulative contractual power, i.e., 14 kW. Figure 6: Aggregated user-committed GEPP vs. actual cumulative GEPP. It is worth noting that the maximum NRMSE and NMAE values in Table 6 are about 7% and 55%, respectively. Furthermore, the low NRMSE value on the aggregated profile (2.88%) shows that, from the utility perspective, the uncertainty can be even lower than that of the single households. This result is due to the statistical compensation of users' deviations, and it also indicates the effectiveness of the EMS for the utility operator. As an example of the end user's cash flow, a sample day is discussed, i.e., day 4. Despite the forecasting errors and the effort to adhere to the committed GEPP, User B earns $2.46, i.e., 1.46% more than the income without any EMS; User C, instead, pays $0.70, i.e., 3.23% less than the expense without any EMS. The actual profit of both users could even be higher if economic incentives were proposed by the public utility to reward the uncertainty reduction on the GEPP. ## 6 Conclusions and Future Perspectives

An embedded and computationally efficient implementation of an EMS for smart homes has been proposed. The chosen EMS algorithm has been redesigned using DP instead of MILP to simplify the implementation process. As demonstrated by a computational complexity analysis, the obtained EMS \begin{table}
\begin{tabular}{l c c c c c} \hline  & **User A** & **User B** & **User C** & **User D** & **Aggregated** \\ \hline nrmse & 0.0452 & 0.0767 & 0.0135 & 0.0450 & 0.0288 \\ nmae & 0.4667 & 0.5521 & 0.1163 & 0.3694 & 0.2202 \\ \hline \end{tabular}
\end{table} 
Table 6: Error metrics on GEPP. \begin{table}
\begin{tabular}{l c c c c c} \hline  & & **User A** & **User B** & **User C** & **User D** \\ \hline \multirow{3}{*}{generation} & nrmse & 0.0610 & 0.0620 & 0.0843 & 0.0855 \\  & nmae & 0.5014 & 0.4796 & 0.4163 & 0.4253 \\ \cline{1-1}  & nrmse & 0.0351 & 0.0576 & 0.0321 & 0.0648 \\ \cline{1-1}  & nmae & 0.1616 & 0.2473 & 0.1590 & 0.2396 \\ \cline{1-1}  & nrmse & 0.0704 & 0.0846 & 0.0902 & 0.1073 \\ \hline \end{tabular}
\end{table} 
Table 5: Error metrics on input profiles. Figure 7: Absolute error on the aggregated GEPP. is suitable for the embedded implementation. Furthermore, the optimality of the solutions has not been compromised in the algorithm redesign.