Getting information from 2 different msg and putting out a msg that can be charted

ok, here is what I am doing.
I have HomeSeer (z-wave hub) and Ambient Weather.
I can read both of these just fine, what I am trying to do is:
Check the thermostat to see if it is on/off

  • if it is on then chart the Cooling Temp setting from the Thermostat on the chart with the inside and outside temps.
    i.e. - Outside Temp - 60
    Inside Temp - 80
    Cooling Temp - 75, Fan On
    What I want to see is a chart with all of the current Temps (Outside, Inside, Cooling (75)
    if the Fan is off then set the Cooling Temp to 0 or simply not display it.

I think that my problem is the Fan returns a status of "On" or "Off" while the Thermostat returns a number - 75

Here is the function I am using -

context.data = context.data || {};
switch (msg.topic) {
    case "BarnFan":
        context.data.BarnFan = msg.payload;
        node.warn("Fan Status Received")
        msg = null;
        break;
    case "BarnCooling":
        context.data.BarnCooling =msg.payload;
        node.warn("Cooling Temp Received")
        msg = null;
        break;
    default:
        msg = null;
        break;
}

if (context.data.task1 != null && context.data.task2 != null) {
node.warn("Both received")
    if (context.data.task1 == "On") {
        return {payload:0};
    } else return {payload:context.data.BarnCooling};
} else return msg;
    

Screenshot 2022-05-24 074226

Ok, I fixed it. Cafeful when you copy examples and drink more tea :slight_smile:

context.data = context.data || {};
switch (msg.topic) {
    case "BarnFan":
        context.data.BarnFan = msg.payload;
        node.warn("Fan Status Received")
        msg = null;
        break;
    case "BarnCooling":
        context.data.BarnCooling =msg.payload;
        node.warn("Cooling Temp Received")
        msg = null;
        break;
    default:
        msg = null;
        break;
}

if (context.data.BarnFan != null && context.data.BarnCooling != null) {
node.warn("Both received")
    if (context.data.BarnFan == "Off") {
        return {payload:0};
    } else return {payload:context.data.BarnCooling};
    //   var ratio = context.data.task1 / context.data.task2;
    //   context.data=null;
    //   return {payload:ratio};
    } else return msg;
    

Ok, next step
I want to only plot on the chart if the Fan is On.
I tried setting the payload to null that doesn't work, it is an error.

Do not set the payload to null, if you want to send nothing specify

return null;

So no object will be returned.

Thanks, I will try that.
I am using the dashboard Chart Node and want a gap in the line when the fan is off and when the fan is on, the Cooling Temp setting.