-
Notifications
You must be signed in to change notification settings - Fork 503
Closed
Description
I would like to use OPC UA and as I got new value I am trying to update fact first.
Then I want to run actual rules. So it will be more event based.
For some reason this snippet does not call actual addFact:
monitoredItemGroup.on("changed", (monitoredItem, dataValue, index) => {
var tag = items[index].nodeId.toString();
var val = dataValue.value.value.toString();
if (dataValue.value.dataType === 10) {
val = dataValue.value.value.toFixed(2).toString();
}
// update facts!!
console.log("update facts:" + tag + " value: " + val);
engine.addFact('pump-information', function (params, almanac) {
console.log('Updating live values...' + JSON.stringify(params) + " " + JSON.stringify(almanac));
return almanac.factValue('nodeId')
.then((tag) => {
console.log("Updating facts for nodeId: " + tag + " value:" + val);
return { value: val }
})
});
});Metadata
Metadata
Assignees
Labels
No labels