recallfx / node-red-contrib-eufy-security

Eufy security node for Node RED
MIT License
6 stars 6 forks source link

Node-red Debug node reports JSON parse errors, even if no inputs allocated #29

Open vinorodrigues opened 2 months ago

vinorodrigues commented 2 months ago

Issue

When adding a Debug node to the Node-red workflow with aeufy-security node, the workflow will generate debug messages like "Non-parsable parameter" messages and "JSON" errors, even when the output the eufy-security node is not connected to a debug node.

This is due to https://github.com/recallfx/node-red-contrib-eufy-security/blob/cc38cf23a3891925fefaa19f2a4a6d838f721630/eufy-security/01-eufy-security.js#L90 setting the global log to the underlying 'eufy-security-client' object being initialized with the RED.log object.

The errors generated are known, and common - as decribed in issue https://github.com/bropat/eufy-security-client/issues/344

This is not predictable, nor fixable in the dependent eufy-security-client object, and thus will flood any/all debug objects used in node-red flows.

Workaround

The quickest way to fix this is to change the initialization line from:

this.driver = await EufySecurity.initialize(driverConnectionConfig, RED.log);

to

// remove `RED.log`, and allow the EufySecurity object to use the default dummy log.
this.driver = await EufySecurity.initialize(driverConnectionConfig);

(This then calls the underlying initialiser https://github.com/bropat/eufy-security-client/blob/2c376bc8889b1f92961289b96a7bc667deda8609/src/eufysecurity.ts#L84-L88 )

Not ideal as this will make issues invisible.

Possible "proper" fixes

  1. Make the initialiser use (or not use) the RED.log object as an option in the Properties page (a checkbox) of the eufy-security node.
  2. Create a custom log object and initialise with that instead. The eufy-security node could then have a second output nodule for log messages passed onto a standard debug node (that you can then switch on an off at will at runtime).