mindsphere / node-red-contrib-mindconnect

Node-RED Agent for the MindConnect API (community driven project)
https://opensource.mindsphere.io/docs/node-red-contrib-mindconnect/index.html
MIT License
48 stars 1 forks source link

validation failure if more than one data source #96

Closed ToSa27 closed 4 years ago

ToSa27 commented 4 years ago

If more than one data source is defined on the Mindsphere side and data is pushed for a data point that is not in the first data source, the "Validate datapoints before sending" fails claiming that the data point ID is not part of the list of valid IDs (and the list provided in the error message is the list of data point IDs from the first data source only). Diasbling this validation resolves the issue but is obviously not intended behaviour.

To Reproduce Steps to reproduce the behavior:

  1. Create an agent in Mindsphere with at least two data sources and at least one variable in the second data source
  2. Creafe a flow in NodeRed connecting to the agent and enable the "Validate datapoints before sending" option
  3. Push a value to a variable in the second data source
  4. See error

Expected behavior The validation should check for valid data point IDs from all available data sources in that agent.

Desktop (please complete the following information):

sn0wcat commented 4 years ago

@ToSa27

Hi

I am having a bit of trouble reproducing this.

Config: image

Node-RED Node:

image

image

could you include

msg._forceGetConfig=true;

in your message to force the node to refresh the configuration?

I also looked into the code and it enumerates accross all data sources.


    model.dataSources.forEach(function(elem) {
        elem.dataPoints.forEach(function(elem2) {
            dataPointIdArray.push(elem2.id);
            valueArray.push(elem2.type.toString());
        });
    });

Btw, this seems to work too (just 2nd datasource...)

image

sn0wcat commented 4 years ago

@ToSa27 One more question :) Are you by any chance using TIMESTAMP or BIG_STRING data points in your configuration?

ToSa27 commented 4 years ago

@sn0wcat Adding msg._forceGetConfig=true; fixed it. The second data source was definitely created after the NodeRed flow was setup so this makes some sense but even after quite some time it still failed. Without forcing it, will the config ever be pulled again e.g. on a given frequency or is there a way to manually trigger a one-time refresh (other than removing and re-adding the node)? I'm not using TIMESTAMP or BIG_STRING.

sn0wcat commented 4 years ago

@ToSa27 the node pulls the data source once from the mindsphere and never again unless you force it. you should remove the msg._forceGetConfig now, to minimize the load on the system.

I am planning to change the node configuration a bit now that the agents actually can get list of assets from Mindsphere (we will provide a dialog where you can select the assets and the agent will automatically create data source config and mappings for them). For that I have to touch that code anyhow, I will see if I can do here a bit more ...