What I need to do is very simple. I need to set the PV1-2.1 value if the received PV1-18.1 value is in a list of values. I set my variable to an array of those values but the check doesn't seem to be working
var type = ['YB','ES','EO','SO','CX']
if msg['PV1']['PV1.18']['PV1.18.1'] = type {
msg['PV1']['PV1.2']['PV1.2.1'] = 'V';
}
You should try writing your condition as:
if(type.includes(msg['PV1']['PV1.18']['PV1.18.1'])){
msg['PV1']['PV1.2']['PV1.2.1'] = 'V';
}
You can try looping through the array and comparing to each element:
var type = ['YB','ES','EO','SO','CX'];
var i = type.length();
while (i--){
if (type[i] == msg['PV1']['PV1.18']['PV1.18.1']){
msg['PV1']['PV1.2']['PV1.2.1'] = 'V';
}
}