Hi @tirosh_gutte ,
It sounds like you are looking for a way to set your ValueTot to positive or negative based on the reading from D9. I would recommend making some adjustments to your Function Node to do this in the workflow, but if you would like to see your value displayed on a dashboard as “+42,” for example, you will need to use {{format val formatStr}} with D3 formatting (documentation).
I would use an if statement in your Function Node to decipher if the value is + or -. Keep in mind you will see only a - sign in the workflow, the + sign is removed from positive numbers. Instead of setting Sign to 42 or 43, you could set it to 1 or -1:
var fullString=payload.data.body.data;
var x=parseInt(fullString.substring(4, 6),16);
payload.data.body.ChaNum1=parseInt(fullString.substring(1, 2),16);
payload.data.body.ChaNum2=parseInt(fullString.substring(3, 4),16);
if(x==43){
payload.data.body.Sign=1;
}else if(x=45){
payload.data.body.Sign=-1;
}
payload.data.body.Par1=parseInt(fullString.substring(7, 8),16);
payload.data.body.Par2=parseInt(fullString.substring(9, 10),16);
payload.data.body.Par3=parseInt(fullString.substring(11, 12),16);
payload.data.body.Par4=parseInt(fullString.substring(13, 14),16);
payload.data.body.Par5=parseInt(fullString.substring(15, 16),16);
payload.data.body.Par6=parseInt(fullString.substring(17, 18),16);
payload.data.body.Par7=parseInt(fullString.substring(19, 20),16);
payload.data.body.Par8=parseInt(fullString.substring(21, 22),16);
payload.data.body.Digin=parseInt(fullString.substring(23, 24),16);
payload.data.body.ChaNum = payload.data.body.ChaNum1 + payload.data.body.ChaNum2;
payload.data.body.ValueTot=payload.data.body.Sign*(payload.data.body.Par1+payload.data.body.Par2+payload.data.body.Par3+payload.data.body.Par4+payload.data.body.Par5+payload.data.body.Par6+payload.data.body.Par7+payload.data.body.Par8);
Your payload will look like this if Sign is negative, and your ValueTot will also be negative:
If Sign is positive, your ValueTot will also be positive:
To set your device state, you will only have to set the path for your values. You can also use Payload Path instead of Individual Fields if your path holds only the values you have just set.

Let me know how else I can help!
Julia