Ok but how to designate it as a tag and not as a field?
RIght now I'm adding a tag named "BATCH" with a value of 'idle' and I can filter grafana using the tag in the WHERE field.
var payload = msg.payload;
var topic = msg.topic;
switch (topic){
case 'tick':
context.set('time_tick', payload);
//node.status({fill:"red",shape:"dot",text:msg.topic});
if (context.get('enable') === true){
msg.payload=[{
AMBIENT:context.get('ambient')||0,
BREWBOX:context.get('brewbox')||0,
BREWBUCKET:context.get('brewbucket')||0,
SETPOINT:context.get('setpoint')||0,
HEAT:context.get('heat')||0,
COOL:context.get('cool')||0},{
BATCH:'idle'
}]
msg.topic = 'status_tick';
return msg;
}
break;
case 'enable':
node.status({fill:"red",shape:"dot",text:topic +':' + payload});
context.set('enable', payload);
break;
case 'ambient':
//node.status({fill:"red",shape:"dot",text:msg.topic});
context.set('ambient',payload);
break;
case 'brewbox':
//node.status({fill:"red",shape:"dot",text:msg.topic});
context.set('brewbox',payload);
break;
case 'brewbucket':
//node.status({fill:"red",shape:"dot",text:msg.topic});
context.set('brewbucket',payload);
break;
case 'setpoint':
//node.status({fill:"red",shape:"dot",text:msg.topic});
context.set('setpoint',payload);
break;
case 'heat':
//node.status({fill:"red",shape:"dot",text:msg.topic});
context.set('heat',payload);
break;
case 'cool':
//node.status({fill:"red",shape:"dot",text:msg.topic});
context.set('cool',payload);
break;
case 'end':
context.set('enable', false);
msg.topic = 'status_tick';
return msg;
}
The magic happens in the case 'tick' switch.
This is a trail setup which will change when I'm satisfied it's going to be useful.
I'll ad a case 'tag' to make the 'BATCH' changeable from the UI.