Node-Red in Home Assistant

Alos relativley new to Node red but I would have done it using the a global variable for MeanLoad and the below flows.

The function “check status” as
var newMsg = msg;
var now = new Date();
var hour = now.getHours();
var minutes = now.getMinutes();
var time = hour*100+minutes;
var MeanLoad = global.get(‘MeanLoad’) || 0;
var SOC = Msg.payload;

if ((time > 1000) && (time < 1530) && (MeanLoad < 5000) && (SOC >70) && (SOC<80))
{
newMsg.payload = “on”;
} else
{
newMsg.payload =“off”;
}
return newMsg;