Hi, could somebody explain me what I am doing wrong? I have a datalogger with Modbus TCP and I would like to get status of digital outputs into my Home assistant. Here is my function setting:
var boolholding = false;
var holdingint = msg.payload[0];
var myboolword = holdingint.toString(2); //take the first element of the modbus array and convert it to a base 2 string
boolholding = myboolword[0];
if (boolholding ==1){msg.payload = true} else {msg.payload = false}
//msg.payload = boolholding;
return msg;
My flow is this one:
Thanks a lot, Jiri