BiancoRoyal / node-red-contrib-iiot-opcua

deprecated - very new developed by PLUS for Node-RED - https://plus4nodered.com
https://www.npmjs.com/package/node-red-contrib-iiot-opcua
BSD 3-Clause "New" or "Revised" License
34 stars 8 forks source link

Passing falsy payload values to OPCUA-IIoT-Node does not work #88

Closed systec-ad closed 5 years ago

systec-ad commented 5 years ago

Problem

bug report

Information

Current behaviour

  1. Passing a falsy value (e.g. 0.0) to a OPCUA-IIoT-Node node will result wrong output messages. (NaN, empty strings)

  2. The value of messages overrides the Value setting

    Expected behaviour

  3. Falsy values should be handled/passed "normal" values

  4. The Value should override the message payload as the documentation says. ("It overrides the given payload if it is not null.")

    Minimal reproduction of the problem with instructions

    1. Inject a falsy value ("" / 0.0 / 0 / false) to a node of type OPCUA-IIoT-Node
    2. Inject a arbitrary value to OPCUA-IIoT-Node, when this node has a valid "Value" setting

Your Environment

Possible solution

I think the problem is located here.

Changing the line from

msg.payload || node.value

to

node.value === "" : msg.payload : node.value

should solve the main issue.

Hint: This solution would not allow an empty string as "Value" setting. Not sure if this would be a big issue.

Thanks

biancode commented 5 years ago

moved to https://github.com/BiancoRoyal/node-red-contrib-iiot-opcua/issues/1