# Return value from OPC.IIoT.Result-Filter

**URL:** https://discourse.nodered.org/t/return-value-from-opc-iiot-result-filter/6787
**Category:** General
**Created:** [14 January 2019 12:21 UTC](https://discourse.nodered.org/t/return-value-from-opc-iiot-result-filter/6787 "2019-01-14T12:21:29Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![olab](https://avatars.discourse-cdn.com/v4/letter/o/d07c76/32.png) [@olab](https://discourse.nodered.org/u/olab)
#### Post date: [14 January 2019 12:21 UTC](https://discourse.nodered.org/t/return-value-from-opc-iiot-result-filter/6787/1 "2019-01-14T12:21:29Z")

</div>

Probaly an easy solution, but I'll ask anyway.

I have a connection to an opc server returning a value of type Float. Payload i returning the correct value until the value is 0. Then the value returned is an complete object. Why?

I'm also not able to set the correct number og decimals in the 'Convert'-tab

Can someone please help me?

Kind regards.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [15 January 2019 16:07 UTC](https://discourse.nodered.org/t/return-value-from-opc-iiot-result-filter/6787/2 "2019-01-15T16:07:30Z")

</div>

> [@olab](#):
>
> Then the value returned is an complete object.

Show us what you mean by that. A screenshot of a debug node output would be good. Also show us what you normally get.  
What node are you using to connect (node-red-something)?

---

<div class="post-metadata">

### Author: ![olab](https://avatars.discourse-cdn.com/v4/letter/o/d07c76/32.png) [@olab](https://discourse.nodered.org/u/olab)
#### Post date: [18 January 2019 12:55 UTC](https://discourse.nodered.org/t/return-value-from-opc-iiot-result-filter/6787/3 "2019-01-18T12:55:21Z")

</div>

Sorry for the delayed response.

Attached sample will show the problem. The OPC tag cycles from 0.0 to 1.0 in intervals of 0.25.

Each time the opc value is 0.0 the debug will raise an error. if the value is greather than 0.0 it will work.

Can you please help me understand why?

```auto
[{"id":"b0029f6e.de8b9","type":"OpcUa-Item","z":"44cfd37b.b7461c","item":"ns=2;s=Simulation Examples.Functions.Ramp2","datatype":"Float","value":"","name":"","x":640,"y":200,"wires":[["91d76d34.2067d"]]},{"id":"91d76d34.2067d","type":"OpcUa-Client","z":"44cfd37b.b7461c","endpoint":"e5d4719e.b6c15","action":"read","time":10,"timeUnit":"s","name":"","x":1180,"y":200,"wires":[["72e8e250.fe1e2c"]]},{"id":"91dd7360.7f467","type":"inject","z":"44cfd37b.b7461c","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":200,"wires":[["b0029f6e.de8b9"]]},{"id":"72e8e250.fe1e2c","type":"OPCUA-IIoT-Result-Filter","z":"44cfd37b.b7461c","nodeId":"ns=2;s=Simulation Examples.Functions.Ramp2","datatype":"Float","fixedValue":false,"fixPoint":2,"withPrecision":false,"precision":2,"entry":1,"justValue":true,"withValueCheck":false,"minvalue":"","maxvalue":"","defaultvalue":"","topic":"","name":"","showErrors":false,"x":1620,"y":200,"wires":[["b15ee614.ef1268"]]},{"id":"b15ee614.ef1268","type":"debug","z":"44cfd37b.b7461c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":2360,"y":200,"wires":[]},{"id":"e5d4719e.b6c15","type":"OpcUa-Endpoint","z":"","endpoint":"opc.tcp://192.168.1.1:49320","secpol":"None","secmode":"NONE","login":false}]

```

Debug info:  
"AssertionError: r.bianco.iiot),r.status({fill:"blue",shape:"ring",text:"new"}),r.bianco.iiot.nodeIdToFilter=function(e){var t=!0,o=a.core.buildNodeListFromClient(e);return o&&o.length&&(t=!o.some(function(e,t,o){return(e.nodeId||e).toString()===r.nodeId.toString()})),t},r.bianco.iiot.isNodeIdNotToFindInAddressSpaceItems=function(e){if(e.addressSpaceItems){if(o.filter(e.addressSpaceItems,function(e){return e.nodeId===r.nodeId}).length\<1)return!0}else if(e.topic!==r.nodeId)return!0},r.bianco.iiot.messageIsToFilter=function(e){return r.bianco.iiot.nodeIdToFilter(e)&&r.bianco.iiot.isNodeIdNotToFindInAddressSpaceItems(e)},r.on("input",function(e){if(e.hasOwnProperty("payload")&&null!==e.payload&&void 0!==e.payload)if(r.bianco.iiot.messageIsToFilter(e))a.internalDebugLog("filtering message on filter");else{var t=Object.assign({},e);t.topic=r.topic||t.topic,t.nodeId=r.nodeId,t.justValue=r.justValue,t.filter=!0,t.filtertype="filter",t.payload=r.bianco.iiot.filterByType(t)||t.payload,r.justValue&&(t.payload=r.bianco.iiot.filterResult(t)),a.core.assert(t.payload),r.send(t)}else a.internalDebugLog("filtering message without payload")}),r.bianco.iiot.filterByType=function(e){var t=null;switch(e.nodetype){case"read":t=r.bianco.iiot.filterByReadType(e);break;case"write":t=r.bianco.iiot.filterByWriteType(e);break;case"listen":t=r.bianco.iiot.filterByListenType(e);break;case"browse":t=r.bianco.iiot.filterByBrowserType(e);break;case"crawl":t=r.bianco.iiot.filterByCrawlerType(e);break;default:a.internalDebugLog("unknown node type injected to filter for "+e.nodetype),r.showErrors&&r.error(new Error("unknown node type injected to filter for "+e.nodetype),e)}return t},r.bianco.iiot.convertResult=function(t,o){try{var e=null;return 0\<=r.fixPoint&&r.fixedValue&&(e=Number.parseFloat(o).toFixed(r.fixPoint),e=parseFloat(e)),0\<=r.precision&&r.withPrecision&&(e=Number.parseFloat(o).toPrecision(r.precision),e=parseFloat(e)),null===e&&(e=o),r.withValueCheck&&(e\<r.minvalue||e\>r.maxvalue)&&(e=r.defaultvalue),e}catch(e){return a.internalDebugLog("result converting error "+e.message),r.showErrors&&r.error(e,t),o}},r.bianco.iiot.convertResultValue=function(e){var t=e.payload;return null==t?(a.internalDebugLog("result null or undefined"),r.showErrors&&r.error(new Error("converted result null or undefined"),e)):(t.hasOwnProperty("value")&&(t=t.value),r.datatype?null==(t=r.bianco.iiot.convertDataType(t))?(a.internalDebugLog("data type result null or undefined"),r.showErrors&&r.error(new Error("converted by data type result null or undefined"),e)):t=r.bianco.iiot.convertResult(e,t):a.internalDebugLog("data type unknown - set the data type inside the result filter node")),t},r.bianco.iiot.filterResult=function(e){return("read"===e.nodetype||"listen"===e.nodetype)&&r.bianco.iiot.convertResultValue(e)||e.payload},r.bianco.iiot.extractValueFromOPCUAArrayStructure=function(e,t){var o=null,r=e.payload[t];return r?o=r.hasOwnProperty("value")?r.value.hasOwnProperty("value")?r.value.value:r.value:r:o},r.bianco.iiot.extractValueFromOPCUAStructure=function(e){return e.payload.hasOwnProperty("value")?e.payload.value.hasOwnProperty("value")?e.payload.value.value:e.payload.value:e.payload},r.bianco.iiot.filterByReadType=function(e){var t=null;return(t=e.payload.length\>=r.entry?r.bianco.iiot.extractValueFromOPCUAArrayStructure(e,r.entry-1):r.bianco.iiot.extractValueFromOPCUAStructure(e)).hasOwnProperty("value")&&(t=t.value),t},r.bianco.iiot.filterByWriteType=function(e){return null},r.bianco.iiot.filterByListenType=function(e){var t=null;return(t=e.payload&&e.payload.hasOwnProperty("value")?e.payload.value:e.payload)&&t.hasOwnProperty("value")&&(t=t.value),t},r.bianco.iiot.filterByBrowserType=function(e){var t=a.core.filterListByNodeId(r.nodeId,e.payload.browserResults);return e.addressSpaceItems&&e.addressSpaceItems.length&&(e.addressSpaceItems=a.core.filterListByNodeId(r.nodeId,e.addressSpaceItems)),e.nodesToRead&&e.nodesToRead.length&&(e.nodesToRead=a.core.filterListEntryByNodeId(r.nodeId,e.nodesToRead),e.nodesToReadCount=e.nodesToRead.length),e.addressItemsToRead&&e.addressItemsToRead.length&&(e.addressItemsToRead=a.core.filterListByNodeId(r.nodeId,e.addressItemsToRead),e.addressItemsToReadCount=e.addressItemsToRead.length),e.addressItemsToBrowse&&e.addressItemsToBrowse.length&&(e.addressItemsToBrowse=a.core.filterListByNodeId(r.nodeId,e.addressItemsToBrowse),e.addressItemsToBrowseCount=e.addressItemsToBrowse.length),t},r.bianco.iiot.filterByCrawlerType=function(e){var t=a.core.filterListByNodeId(r.nodeId,e.payload.crawlerResults);return e.addressSpaceItems&&e.addressSpaceItems.length&&(e.addressItems=a.core.filterListByNodeId(r.nodeId,e.addressSpaceItems)),t},r.bianco.iiot.convertDataType=function(e){return a.internalDebugLog("data type convert for "+r.nodeId),a.core.convertDataValueByDataType({value:e},r.datatype)},r.withValueCheck&&(r.minvalue=r.bianco.iiot.convertDataType(r.minvalue),r.maxvalue=r.bianco.iiot.convertDataType(r.maxvalue)),r.status({fill:"green",shape:"dot",text:"active"})}"

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [18 January 2019 16:45 UTC](https://discourse.nodered.org/t/return-value-from-opc-iiot-result-filter/6787/5 "2019-01-18T16:45:08Z")

</div>

Your flow is not importable. Please read this and then go back and edit your post so the flow becomes importable.

> [@How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506):
>
> To share code samples or flow json in this forum, you need to take care to format it properly so that it is displayed correctly. The easiest way to do that is to click the 'Preformatted Text' button in the toolbar: [image] Then paste in your code or flow json. You should end up with three back-tick characters - ``` - on their own line before and after the code. On standard US English keyboards, this is on the same key as the ~ character. Using the backticks will ens…

---

<div class="post-metadata">

### Author: ![olab](https://avatars.discourse-cdn.com/v4/letter/o/d07c76/32.png) [@olab](https://discourse.nodered.org/u/olab)
#### Post date: [18 January 2019 16:52 UTC](https://discourse.nodered.org/t/return-value-from-opc-iiot-result-filter/6787/6 "2019-01-18T16:52:52Z")

</div>

Sorry about that...

Hopefully readable now

I think the problem is in the OPCUA-IIO-Result-Filter node. If I remove this it works. Neither does the Convert function work in this node.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [18 January 2019 17:02 UTC](https://discourse.nodered.org/t/return-value-from-opc-iiot-result-filter/6787/7 "2019-01-18T17:02:03Z")

</div>

Sounds like you need to raise an issue against the origin of that node.
