Change value: 1 to true

good night i am new to this program and i find it very interesting i am learning from the good going to the problem and connected a nano plc and i want to activate the output the registry votes me a value 1 but i want to change that to true to be able to activate the output that solution could have here. Thank you.

in this graph the value is shown

In this other graph the value that it reads from msg to change it to true or false but without good result

and in the latter what I wrote in the function to be able to have the value

Thank you in advance for your help

your change node is not working because you are looking for the 0 in the wrong place. You’re msg.payload is an object. instead of payload put the path to the value key that you already have in the function into your change node:

Also if you are dealing with numbers rather than strings (which I think you are) then you should test for equals 0 rather then search for 0.

With this flow works well the output of the plc is activated

Taking as reference this flow that works correctly I try to do the same with the block of ubidots with which I have no results with the first flow it works well for me (MQTT) but with the second it does not respond there are no changes in the plc I already did the indicated for you but without improvement

Have a play with this. You don’t need the function but just one change node:


if you would want to do it in a function it would only be the function instead of the change node:

msg.payload = (msg.payload.pulse_2.value === 0) ? false : true; 
return msg;

and no change node at all.

1 Like

Thanks JGKK in both ways I work excellent the node thank you very much for your support.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.