Filter node throwing errors when being reset

I have this Filter node that is "filtering" the consumption output from my appliances. It gets the value to filter as a property under payload. And it is configured to distinguish devices by topic.
imagen

There's another node/flow that processes devices that publish their consumption on another property.

Every night at 0h, an inject node resets the daily kWh value and resets the filter node to force it to process the first value even if it's the same as the previous.
imagen

imagen

But every night at 0h I'm getting two exceptions on the log. One for every flow and filter node.
I seems like the node is trying to process the reset message and then fails because it doesn't have the configured property.

23 May 00:00:00 - [error] [rbe:6ccbda17501c01d7] TypeError: Cannot read properties of undefined (reading 'energy_daily_kwh')
    at /usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/util.js:430:29
    at Array.reduce (<anonymous>)
    at getObjectProperty (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/util.js:429:18)
    at Object.getMessageProperty (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/util.js:401:12)
    at RbeNode._inputCallback (/usr/lib/node_modules/node-red/node_modules/@node-red/nodes/core/function/rbe.js:38:34)
    at /usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:210:26
    at Object.trigger (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/hooks.js:166:13)
    at RbeNode.Node._emitInput (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:202:11)
    at RbeNode.Node.emit (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:186:25)
    at RbeNode.Node.receive (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:485:10)
    at Immediate._onImmediate (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:831:52)
    at processImmediate (node:internal/timers:476:21)
23 May 00:00:00 - [error] [rbe:e01ede74ce12e631] TypeError: Cannot read properties of undefined (reading 'energy_import_kwh')
    at /usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/util.js:430:29
    at Array.reduce (<anonymous>)
    at getObjectProperty (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/util.js:429:18)
    at Object.getMessageProperty (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/util.js:401:12)
    at RbeNode._inputCallback (/usr/lib/node_modules/node-red/node_modules/@node-red/nodes/core/function/rbe.js:38:34)
    at /usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:210:26
    at Object.trigger (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/hooks.js:166:13)
    at RbeNode.Node._emitInput (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:202:11)
    at RbeNode.Node.emit (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:186:25)
    at RbeNode.Node.receive (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:485:10)
    at Immediate._onImmediate (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:831:52)
    at processImmediate (node:internal/timers:476:21)

Is this normal?

Edit: The switch node before the filter is precisely blocking messages that doesn't have the target property defined.
imagen

It would help to see more of the flow and maybe even be able to import it.
Why not put a debug node before the filter to see what is coming in.

is not null is not the same as "is undefined", right?

Besides, there is another input, maybe that is the way msg come in? Is it disabled all the time?

EDIT: Are you sure the error is thrown by that filter node shown above?

Make sure the reset message has msg.reset set and nothing else (except msg._id). Feed it into a debug node and check there is no topic present for example. Perhaps you have left the msg.topic line in the Inject node.

FYI - we've just merged a fix for the Filter node for the specific error you are hitting - where the property it is configured to monitor is missing from a message.

2 Likes

Yes, the secondary input is for debugging purposes and it's always disabled.

Yep. I still don't know how to test that an incoming object is present, is defined and has value.
It would be nice to have a shortcut way in the switch node alongside with the "language" methods.

If I gave an export it would mean nothing to you without the incoming data, I think.
And putting a debug node would be a mess, as this flow receives data from mqtt many times a second. Some devices, like the ones related to PV report every second to be able to manage excess diverting and overload.

Hi Colin.

Nope. Not the case...
I Should had made the screenshot a little bigger:
imagen

But based on your idea today I tried by not having that change node inline after the reset. But it gave the same exception.

Thanks Nick, That could be my problem.

I've seen that node-red last release was one year ago.
How I know when this fix is released? Or how I do incorporate it?

At least docker got an update today (26.5.2023).

The fix is also in the latest beta - 🎉 Node-RED 3.1.0-beta.3 released

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