maxwellhadley / node-red-contrib-rfxcom

node-RED nodes to access an RFXtrx433 transceiver
BSD 2-Clause "Simplified" License
22 stars 13 forks source link

Failure after upgrading to 2.11.1 #102

Closed cris1 closed 4 years ago

cris1 commented 4 years ago

Node-RED v1.1.2 After Palette upgrade software -->

[info] Waiting for missing types to be registered: [info] - rfxtrx-port [info] - rfx-lights-in [info] - rfx-lights-out

Never had this issue before.

maxwellhadley commented 4 years ago

Please can you let me know what versions of NodeJS & npm you are using, the operating system and version number, and whether this is a 'normal' installation or containerised in some way (e.g. Docker or Home Assistant)

There have been several reports of similar problems which I have not yet been able to duplicate here. As much console output from Node-RED as it starts as possible would help, as I may be able to work out where the failure is occurring by seeing when the 'normal' messages stop.

Also, did you upgrade from the palette, or using npm?

cris1 commented 4 years ago

Thanks for replying and I will try to give you as much detail as I can.

I am using a "normal" installation of NodeRed (not containersided) on a VM (ProxMox) on a Debian OS 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64 GNU/Linux

NodeJS version is v10.22.0 NPM version is v6.14.6 NodeRed version is v1.1.2 (*)

(*) Problem was also on v1.1.0

Working node-red-contrib-rfxcom version is v.2.11.0 When upgrading through Palette to v2.11.1 I -->

[info] Upgrading module: node-red-contrib-rfxcom to version: 2.11.1 [info] Upgraded module: node-red-contrib-rfxcom. Restart Node-RED to use the new version

After restarting NodeRed

[info] Waiting for missing types to be registered: [info] - rfxtrx-port [info] - rfx-lights-in [info] - rfx-lights-out

In NodeRed Palette it says :

node-red-contrib-rfxcom

2.11.1 SyntaxError: Unexpected token = (line:26)

Hope this helps!

I have a working snapshot of my environment so I am free to try / play around if needed.

maxwellhadley commented 4 years ago

Thanks. Please can you send me the output of:

head -50 ~/.node-red/node_modules/node-red-contrib-rfxcom/rfxcom.js

It is possible this file is corrupted somehow (or it may be somewhere down the require chain)

cris1 commented 4 years ago

Here is what I did..

I updated to the version 2.11.1 via Palette This was the log result

`

2020-07-23T12:16:25.408Z Install : node-red-contrib-rfxcom 2.11.1

2020-07-23T12:16:26.695Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix="~" --production node-red-contrib-rfxcom@2.11.1 2020-07-23T12:16:32.605Z [out] 2020-07-23T12:16:32.605Z [out] > node-aead-crypto@2.1.4 install /home/cris/.node-red/node_modules/node-aead-crypto 2020-07-23T12:16:32.605Z [out] > node lib/install.js 2020-07-23T12:16:32.605Z [out] 2020-07-23T12:16:32.714Z [err] node-aead-crypto is no longer needed on NodeJS 10+ 2020-07-23T12:16:32.723Z [out] 2020-07-23T12:16:32.723Z [out] > @serialport/bindings@9.0.0 install /home/cris/.node-red/node_modules/serialport/node_modules/@serialport/bindings 2020-07-23T12:16:32.723Z [out] > prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild 2020-07-23T12:16:32.723Z [out] 2020-07-23T12:16:33.636Z [out] 2020-07-23T12:16:33.636Z [out] > serialport@9.0.0 postinstall /home/cris/.node-red/node_modules/serialport 2020-07-23T12:16:33.636Z [out] > node thank-you.js 2020-07-23T12:16:33.636Z [out] 2020-07-23T12:16:33.718Z [out] Thank you for using serialport! 2020-07-23T12:16:33.718Z [out] If you rely on this package, please consider supporting our open collective: 2020-07-23T12:16:33.718Z [out] > https://opencollective.com/serialport/donate 2020-07-23T12:16:33.718Z [out] 2020-07-23T12:16:33.718Z [out] 2020-07-23T12:16:34.344Z [err] npm 2020-07-23T12:16:34.344Z [err] WARN node-red-project@0.0.1 No repository field. 2020-07-23T12:16:34.347Z [err] npm 2020-07-23T12:16:34.347Z [err] WARN node-red-project@0.0.1 No license field. 2020-07-23T12:16:34.348Z [err] npm 2020-07-23T12:16:34.348Z [err] WARN optional 2020-07-23T12:16:34.348Z [err] SKIPPING OPTIONAL DEPENDENCY: node-aead-crypto@2.1.4 (node_modules/node-aead-crypto): 2020-07-23T12:16:34.348Z [err] npm 2020-07-23T12:16:34.348Z [err] WARN optional 2020-07-23T12:16:34.348Z [err] SKIPPING OPTIONAL DEPENDENCY: node-aead-crypto@2.1.4 install: node lib/install.js 2020-07-23T12:16:34.348Z [err] npm 2020-07-23T12:16:34.348Z [err] WARN 2020-07-23T12:16:34.349Z [err] optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1 2020-07-23T12:16:34.349Z [err] 2020-07-23T12:16:34.350Z [out] + node-red-contrib-rfxcom@2.11.1 2020-07-23T12:16:34.350Z [out] added 11 packages from 8 contributors and updated 3 packages in 7.008s 2020-07-23T12:16:34.368Z rc=0 `

I restarted NodeRed and entered the command 👍

` cs@srvlinux:~$ head -50 ~/.node-red/node_modules/node-red-contrib-rfxcom/rfxcom.js /* Copyright (c) 2014 .. 2019, Maxwell Hadley All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/

module.exports = function (RED) { "use strict"; const rfxcom = require("rfxcom");

// Set the rfxcom debug option from the environment variable let enableAllDebug = false; if (process.env.hasOwnProperty("RED_DEBUG") && process.env.RED_DEBUG.indexOf("rfxcom") >= 0) { enableAllDebug = true; }

// The config node holding the (serial) port device path for one or more rfxcom family nodes function RfxtrxPortNode(n) { RED.nodes.createNode(this, n); this.port = n.port; this.rfyVenetianMode = n.rfyVenetianMode || "EU"; this.enableDebug = n.enableDebug || false; }

// Register the config node RED.nodes.registerType("rfxtrx-port", RfxtrxPortNode);

// An object maintaining a pool of config nodes const rfxcomPool = function () { let pool = {};

    const connectTo = function (rfxtrx, node) {
        //noinspection JSUnusedLocalSymbols

cs@srvlinux:~$

`

maxwellhadley commented 4 years ago

@cris1 That file looks OK. Your original log showed the "=" token on line 26:

const rfxcom = require("rfxcom");

was unexpected, which implies some file corruption somewhere. Do I understand you have tried another re-install from the palette? Do you get the same error, or is it working now?

cris1 commented 4 years ago

Hi Max,

You are right. The file looks ok, but the error is still there :

[image: image.png]

I don't see what is wrong as well.

I have removed some remark codes just to be sure to see the line number change (and be sure this is the file used) I have removed the line completely and retyped it...

I can't see what is wrong with the code..

node-red-contrib-rfxcom 2.11.1

SyntaxError: Unexpected token = (line:3)

Its the same line as you mentioned.

const rfxcom = require("rfxcom");

maxwellhadley commented 4 years ago

Just a wild idea, but try changing const to let

cris1 commented 4 years ago

Unfortunately the same result

2.11.1

SyntaxError: Unexpected token = (line:26)

let rfxcom = require("rfxcom");

The strange thing is , everything works fine on the previous version.. no other updates are done except this.

matz33 commented 4 years ago

Hello,

Same problem here since i upgraded. I don't remember which version i had before upgrading, it's been a long time i did not upgrade.

I then uninstall the latest version and tried a previous one. In fact, it's starting version 2.7.0 that i have the error "SyntaxError: Unexpected token = "

My nodered is in nodered, on the official nodered image, last version.

Maybe this can help

Regards

Matz

maxwellhadley commented 4 years ago

@matz33 - what version of NodeJS are you using, and which operating system?

matz33 commented 4 years ago

@maxwellhadley

Node JS : v 10.21.0 OS : Alpine Linux v3.11

Below the result of command i ran to have those infos under the docker container :

bash-5.0$ nodejs -v v10.21.0

bash-5.0$ cat /etc/os-release NAME="Alpine Linux" ID=alpine VERSION_ID=3.11.6 PRETTY_NAME="Alpine Linux v3.11" HOME_URL="https://alpinelinux.org/" BUG_REPORT_URL="https://bugs.alpinelinux.org/"

bash-5.0$ npm version { 'node-red-docker': '1.1.2', npm: '6.14.4', ares: '1.15.0', brotli: '1.0.7', cldr: '35.1', http_parser: '2.9.3', icu: '64.2', modules: '64', napi: '6', nghttp2: '1.41.0', node: '10.21.0', openssl: '1.1.1e', tz: '2019c', unicode: '12.1', uv: '1.34.2', v8: '6.8.275.32-node.56', zlib: '1.2.11' }

cris1 commented 4 years ago

@maxwellhadley If it helps you to have an Anydesk session where you can try some things out ,I'd be happy to provide that. Just let me know and we can setup something.

matz33 commented 4 years ago

I forgot : with 2.6.3 it is ok, no error. Except that the node keep saying "connecting..."

maxwellhadley commented 4 years ago

Erm... version 2.6.3 of what?

matz33 commented 4 years ago

Of your module node-red-contrib-rfxcom. If I install 2.7.0 i start to have the error Unexpted token. With 2.6.3 it is ok

cris1 commented 4 years ago

Of your module node-red-contrib-rfxcom. If I install 2.7.0 i start to have the error Unexpted token. With 2.6.3 it is ok

That is odd.. for me the error starts when I upgrade to 2.11.1 .. This is a very strange issue.. (the common thing is is : failure happens after upgrading) .. maybe the version is not important then.

maxwellhadley commented 4 years ago

I think I might be making progress. It's something to do with the version of the dependent package rfxcom, and the serialport that package uses, combined with the version of NodeJS. With node-red-contrib-rfxcom v2.11.1, running in NodeRED v1.1.2, under NodeJS v10.22.0 I got to the SyntaxError: Unexpected token = state (but no line number was shown?) and then recovered a working installation by running:

cd ~/.node-red
npm uninstall node-red-contrib-rfxcom node-red-node-serialport rfxcom serialport
nvm use 12
npm install node-red-contrib-rfxcom node-red-node-serialport

I had to uninstall all four packages, it looks like npm isn't following the dependency chain all the way. This seems to lie behind the various 'version mismatch' errors people have been seeing - #99. (Note that I am using nvm to switch between node versions - presumably you could also upgrade at this point)

This isn't the whole story, but it may help. I will keep looking for the underlying cause, which I suspect is some construct provoking a NodeJS (V8) compiler bug

matz33 commented 4 years ago

I ran the command you sent (after installing nvm that i don't know at all), but i still get the error. Like you i don't have a line number) :

[warn] [node-red-contrib-rfxcom/rfxcom] SyntaxError: Unexpected token =

And after that flows are stopped : 29 Jul 00:35:47 - [info] Waiting for missing types to be registered: 29 Jul 00:35:47 - [info] - rfxtrx-port 29 Jul 00:35:47 - [info] - rfx-lights-in 29 Jul 00:35:47 - [info] - rfx-lights-out 29 Jul 00:35:47 - [info] - rfx-doorbell-in

cris1 commented 4 years ago

The line number "error" only appears in the NodeRed Palette for me (after upgrading)

Meanwhile I updated another package through Palette (unifi) just to see if this worked , and that worked ok.

maxwellhadley commented 4 years ago

@matz33 - when NodeRED starts, does it report the NodeJS version number as 12.something? I found that I had to start nodeRED from a terminal window to get it to 'see' the nvm-installed version of NodeJS.

paddenstoeltje commented 4 years ago

It seems I get the same problem, some details of the log:

29 Jul 11:43:18 - [warn] [node-red-contrib-rfxcom/rfxcom] Error: Cannot find module '@serialport/bindings' Require stack:

29 Jul 11:43:18 - [info] Waiting for missing types to be registered: 29 Jul 11:43:18 - [info] - rfxtrx-port 29 Jul 11:43:18 - [info] - rfx-blinds-out 29 Jul 11:43:18 - [info] - rfx-lights-out

maxwellhadley commented 4 years ago

@paddenstoeltje - it looks like the serialport package has not installed properly. What versions of NodeJS & NodeRED are you using, and which operating system? Are you using Docker?

The problem seems to be linked to NodeJS v10 on Linux

paddenstoeltje commented 4 years ago

Hi Max, thank you for your tip. I updated the serial port and it seems to be working with the latest version.

matz33 commented 4 years ago

Hi Max,

It seems it's using NodeJS 10.21.0. I'm using the last container published by nodeRed here : https://hub.docker.com/r/nodered/node-red/

I start docker, i uninstall everything concerning rfxcom like you did above : npm uninstall node-red-contrib-rfxcom node-red-node-serialport rfxcom serialport

I don't use nvm this time, i don't know how to use it, and it seems i don't have nodejs version 12, so i reinstall everything concerning RFXcom like you did above without "nvm use 12" : npm install node-red-contrib-rfxcom node-red-node-serialport

I got a looooong log after that, I attached it : log.txt

Then i start nodered again and here is the log :

node-red-docker@1.1.2 start /usr/src/node-red node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"

29 Jul 16:14:21 - [info]

Welcome to Node-RED

29 Jul 16:14:21 - [info] Node-RED version: v1.1.2 29 Jul 16:14:21 - [info] Node.js version: v10.21.0 29 Jul 16:14:21 - [info] Linux 3.10.35 x64 LE 29 Jul 16:14:21 - [info] Loading palette nodes 29 Jul 16:14:22 - [debug] Module: node-red-contrib-simple-weekly-scheduler 0.0.14 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-simple-weekly-scheduler 29 Jul 16:14:22 - [debug] Module: node-red-contrib-alexa 0.0.7 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-alexa 29 Jul 16:14:22 - [debug] Module: node-red-contrib-amazon-echo 0.1.10 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-amazon-echo 29 Jul 16:14:22 - [debug] Module: node-red-contrib-bigtimer 2.3.1 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-bigtimer 29 Jul 16:14:22 - [debug] Module: node-red-contrib-config 1.1.3 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-config 29 Jul 16:14:22 - [debug] Module: node-red-contrib-fs-ops 1.5.0 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-fs-ops 29 Jul 16:14:22 - [debug] Module: node-red-contrib-heater-controller 2.0.2 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-heater-controller 29 Jul 16:14:22 - [debug] Module: node-red-contrib-huemagic 2.8.2 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-huemagic 29 Jul 16:14:22 - [debug] Module: node-red-contrib-influxdb 0.4.1 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-influxdb 29 Jul 16:14:22 - [debug] Module: node-red-contrib-looptimer 0.0.8 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-looptimer 29 Jul 16:14:22 - [debug] Module: node-red-contrib-moment 3.0.3 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-moment 29 Jul 16:14:22 - [debug] Module: node-red-contrib-netatmo 0.2.0 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-netatmo 29 Jul 16:14:22 - [debug] Module: node-red-contrib-netatmo-dashboard 0.5.2 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-netatmo-dashboard 29 Jul 16:14:22 - [debug] Module: node-red-contrib-persist 1.0.4 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-persist 29 Jul 16:14:22 - [debug] Module: node-red-contrib-pythonshell 1.5.4 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-pythonshell 29 Jul 16:14:22 - [debug] Module: node-red-contrib-rfxcom 2.11.1 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-rfxcom 29 Jul 16:14:22 - [debug] Module: node-red-contrib-schedex 1.10.2 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-schedex 29 Jul 16:14:22 - [debug] Module: node-red-contrib-alexa-local 0.3.24 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-alexa-local 29 Jul 16:14:22 - [debug] Module: node-red-contrib-slack 2.0.0 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-slack 29 Jul 16:14:22 - [debug] Module: node-red-contrib-slack-files 0.1.2 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-slack-files 29 Jul 16:14:22 - [debug] Module: node-red-contrib-stoptimer 0.0.7 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-stoptimer 29 Jul 16:14:22 - [debug] Module: node-red-contrib-time-range-switch 1.0.0 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-time-range-switch 29 Jul 16:14:22 - [debug] Module: node-red-contrib-timerswitch 1.3.0 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-timerswitch 29 Jul 16:14:22 - [debug] Module: node-red-contrib-vacation-timer 2.2.8 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-vacation-timer 29 Jul 16:14:22 - [debug] Module: node-red-contrib-wemo-emulator 1.0.0 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-contrib-wemo-emulator 29 Jul 16:14:22 - [debug] Module: node-red-dashboard 2.23.0 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-dashboard 29 Jul 16:14:22 - [debug] Module: node-red-node-emoncms 0.2.1 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-node-emoncms 29 Jul 16:14:22 - [debug] Module: node-red-node-openweathermap 0.3.1 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-node-openweathermap 29 Jul 16:14:22 - [debug] Module: node-red-node-ping 0.2.1 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-node-ping 29 Jul 16:14:22 - [debug] Module: node-red-node-prowl 0.0.10 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-node-prowl 29 Jul 16:14:22 - [debug] Module: node-red-node-serialport 0.10.3 29 Jul 16:14:22 - [debug] /data/node_modules/node-red-node-serialport 29 Jul 16:14:22 - [debug] Module: rika-stove-node 1.0.0 29 Jul 16:14:22 - [debug] /data/node_modules/rika-stove-node 29 Jul 16:14:22 - [debug] Module: node-red-node-rbe 0.2.9 29 Jul 16:14:22 - [debug] /usr/src/node-red/node_modules/node-red-node-rbe 29 Jul 16:14:22 - [debug] Module: node-red-node-tail 0.1.1 29 Jul 16:14:22 - [debug] /usr/src/node-red/node_modules/node-red-node-tail 29 Jul 16:14:24 - [info] Dashboard version 2.23.0 started at /ui 29 Jul 16:14:25 - [warn] ------------------------------------------------------ 29 Jul 16:14:25 - [warn] [node-red-contrib-rfxcom/rfxcom] SyntaxError: Unexpected token = 29 Jul 16:14:25 - [warn] ------------------------------------------------------ 29 Jul 16:14:25 - [info] Settings file : /data/settings.js 29 Jul 16:14:25 - [info] Context store : 'default' [module=memory] 29 Jul 16:14:25 - [info] User directory : /data 29 Jul 16:14:25 - [warn] Projects disabled : editorTheme.projects.enabled=false 29 Jul 16:14:25 - [info] Flows file : /data/flows.json 29 Jul 16:14:25 - [info] Server now running at http://127.0.0.1:1880/ 29 Jul 16:14:25 - [debug] loaded flow revision: 5e639b5116c25abf4c011f806dfb2deb 29 Jul 16:14:25 - [debug] red/runtime/nodes/credentials.load : no user key present 29 Jul 16:14:25 - [debug] red/runtime/nodes/credentials.load : using default key 29 Jul 16:14:25 - [debug] red/runtime/nodes/credentials.load : keyType=system 29 Jul 16:14:25 - [warn]

Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials file will not be recoverable, you will have to delete it and re-enter your credentials.

You should set your own key using the 'credentialSecret' option in your settings file. Node-RED will then re-encrypt your credentials file using your chosen key the next time you deploy a change.

29 Jul 16:14:25 - [info] Waiting for missing types to be registered: 29 Jul 16:14:25 - [info] - rfxtrx-port 29 Jul 16:14:25 - [info] - rfx-lights-in 29 Jul 16:14:25 - [info] - rfx-lights-out 29 Jul 16:14:25 - [info] - rfx-doorbell-in

And after that my flows are not launched. All i can do is uninstall node-red-contrib-rfxcom and force an install of version 2.6.3 : npm install node-red-contrib-rfxcom@2.6.3

After that my flows works. but RFXCom nodes are in "Connecting..." mode, but this is maybe another problem.

maxwellhadley commented 4 years ago

@matz33 - OK so this is the same problem, a just-plain-wrong syntax error message from the NodeJS V10 compiler, on Linux. Something in one of the updated packages, not necessarily node-red-contrib-rfxcom, is triggering this bug. The serialport/Docker/HA/nvm issues are all to do with not correctly updating either the serialport node or NodeJS itself, thereby hiding the underlying problem from view.

Hopefully I will be able to get my Raspberry Pi back into the situation with the syntax error, and try manually reverting source code changes one-by-one until it goes away..

matz33 commented 4 years ago

Thanks a lot Max.

To be noted that now the RFXCom nodes are connected. Sometimes they don't connect. Trying to debug this until I get the latest version (after you will find the solution) is certainly a waste of time.

maxwellhadley commented 4 years ago

@cris1 @matz33 - I think I found the issue. It's in a completely different file, part of another package!

To test this out, please can you edit the file:

~.node_red/node_modules/rfxcom/lib/security1.js

and comment out lines 156 & 157, like this:

 154: 
 155:    // Synonyms to (temporarily) support deprecated function names
 156:    // switchOnLight = this.switchLightOn;
 157:    // switchOffLight = this.switchLightOff;
 158: }

For me, this suppresses the SyntaxError message using NodeJS v10.22.0 under Linux. If this works, I will change the compatibility synonyms to be call-through functions & publish new updates.

Fingers crossed!

cris1 commented 4 years ago

Hi Max,

I might have a different version of security1.js. The file it exactly on the same spot, but it does not have the same text on the same line numbers.

I will show you a dump starting from line 130 to 157 (where line 156 = module.exports = Security)

My security1.js starts with : * Created by max on 11/07/2017. and is 5.2Kb

`

switchOnLight(deviceId, channel, callback) {
    if (this.isSubtype("X10_SECURITY")) {
        if (channel === 1 || channel === 2) {
            return this._sendCommand(deviceId, 0xf + 2*channel, callback);
        } else {
            throw new Error("Invalid channel: value must be in range 1-2");
        }
    } else {
        throw new Error("Device does not support switchOnLight()");
    }
};

switchOffLight(deviceId, channel, callback) {
    if (this.isSubtype("X10_SECURITY")) {
        if (channel === 1 || channel === 2) {
            return this._sendCommand(deviceId, 0xe + 2*channel, callback);
        } else {
            throw new Error("Invalid channel: value must be in range 1-2");
        }
    } else {
        throw new Error("Device does not support switchOffLight()");
    }
};

}

module.exports = Security1; `

maxwellhadley commented 4 years ago

That's the previous version. Are you currently seeing the SyntaxError: Unexpected token = message when NodeRED starts? With the older version, I don't think the error will occur

Edit to add: If you aren't getting the error message, try adding a line

ProvokeCompilerBug = this.SwitchOffLight;

immediately after the closing}; of SwitchOffLight. That should provoke it!

matz33 commented 4 years ago

Max

It is working now !

I've done a complete reinstall under the nodered folder :

npm uninstall node-red-contrib-rfxcom node-red-node-serialport rfxcom serialport npm install node-red-contrib-rfxcom node-red-node-serialport

I edited the file "/node_modules/rfxcom/lib/security1.js" like you asked me. Line numbers was correct. I saved, restarted node red and voilĂ  ! It is ok. Flows started with no errors, and my nodes are connected !

To be noted that in the log, with " | grep rfx", I have messages like "Unhandled packet type". I don't know if this happened before as i've never looked at this kind of logs before :

31 Jul 11:50:11 - [info] [rfx-lights-in:Téléc Salon neutre] connecting to /dev/ttyUSB0 2020-07-31 11:50:16.866 [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,00,00,00,00,00,00,00,00,00,00,00 2020-07-31 11:50:17.370 [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,01,02,00,00,00,00,00,00,00,00,00 2020-07-31 11:50:17.380 [rfxcom] on /dev/ttyUSB0 - Received: 14,01,00,01,02,53,10,01,08,A6,02,01,03,1C,04,52,46,58,43,4F,4D 2020-07-31 11:50:17.383 [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,02,07,00,00,00,00,00,00,00,00,00 2020-07-31 11:50:17.659 [rfxcom] on /dev/ttyUSB0 - Received: 07,43,6F,70,79,72,69,67 2020-07-31 11:50:17.659 [rfxcom] on /dev/ttyUSB0 - Unhandled packet type = 43 2020-07-31 11:51:44.825 [rfxcom] on /dev/ttyUSB0 - Received: 68,74,20,52,46,58,43,4F,4D,02,00,00,60,0B,11,00,05,02,46,80,00,03,00,00,70,0B,11,00,06,02,46,80,00,03,01,0F,70,0B,11,00,07,02,46,80,00,03,00,00,70,0B,11,00,08,02,46,80,00,03,01,0F,70,0B,11,00,09,02,46,80,00,03,00,00,70,0B,11,00,0A,02,4A,EC,00,04,01,0F,70,0B,11,00,0B,02,4A,EC,00,05,01,0F,70,14,01,07,16,07,43,6F,70 2020-07-31 11:51:44.825 [rfxcom] on /dev/ttyUSB0 - Unhandled packet type = 74

Thank you very much Max

cris1 commented 4 years ago

ProvokeCompilerBug = this.SwitchOffLight;

Oops, you are right.. I forgot to upgrade first. I upgraded to the new version.. then I had the security1.js as you described and I remarked the code as requested.

NodeRed starts up perfectly now. It seems you have found the issue :) Thanks !!

maxwellhadley commented 4 years ago

@matz33 - What has happened there is the that the first few bytes of the response to the receiver start message have been misplaced. The response should have been:

14,01,07,02,07,43,6F,70,79,72,69,67,68,74,20,52,46,58,43,4F,4D

In the lines that follow I can see where some of the missing bytes appear, out of order and mixed in with a bunch of lighting messages!

I've not seen anything like this before! What firmware version is your RFXtrx running?

matz33 commented 4 years ago

It seems 1016. I never upgraded it, i'm always afraid of upgrading a firmware. Should i do it ?

Here is the log from RFXmgr :

RFXtrx433 COM13 Serialnr: A11AAV2X

31/07/2020 12:48:11:045= Reset receiver/transceiver: 0D 00 00 00 00 00 1C 00 00 00 00 00 00 00

31/07/2020 12:48:11:533= Get Status: 0D 00 00 01 02 00 1C 00 00 00 00 00 00 00 31/07/2020 12:48:11:638= 140100010253100108A60201031C04000000000000 Packettype = Interface Message subtype = Interface Response Sequence nbr = 1 response on cmnd = Get Status Transceiver type = 433.92MHz Firmware version = 1016 Firmware Type = Ext2 Transmit power = 10dBm Hardware version = 1.3 RFXtrx433E Undec off Imagintronix disabled Byron SX disabled RSL disabled Lighting4 disabled FineOffset disabled Rubicson disabled AE Blyss enabled BlindsTx disabled BlindsT0 disabled Legrand disabled La Crosse enabled Hideki disabled AD LightwaveRF disabled Mertik disabled Visonic enabled ATI,Cartelectroni disabled Oregon Scientific enabled Meiantech disabled HomeEasy EU disabled AC enabled ARC enabled X10 disabled HomeConfort,Fan enabled KeeLoq disabled

What is strange is that when i change something on node red, and redeploy, i have the "Connecting..." status on the RFX nodes, and logs are :

31 Jul 12:25:56 - [debug] Module: node-red-contrib-rfxcom 2.11.1 31 Jul 12:25:56 - [debug] /data/node_modules/node-red-contrib-rfxcom 31 Jul 12:26:02 - [info] [rfx-lights-in:Téléc Salon neutre] connecting to /dev/ttyUSB0 2020-07-31 12:26:07.964 [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,00,00,00,00,00,00,00,00,00,00,00 2020-07-31 12:26:08.468 [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,01,02,00,00,00,00,00,00,00,00,00

I unplug the RFXCom and replug, the nodes connect again. During that, including the unplug, logs are :

2020-07-31 12:29:34.167 [rfxcom] on /dev/ttyUSB0 - RFXtrx433 disconnected from /dev/ttyUSB0 2020-07-31 12:29:34.168 [rfxcom] on /dev/ttyUSB0 - Cleared command message queue 31 Jul 12:29:34 - [info] [rfx-lights-in:Téléc Salon neutre] disconnected: bad file descriptor 31 Jul 12:29:40 - [info] [rfx-lights-in:Téléc Salon neutre] connecting to /dev/ttyUSB0 2020-07-31 12:29:45.679 [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,00,00,00,00,00,00,00,00,00,00,00 2020-07-31 12:29:46.182 [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,01,02,00,00,00,00,00,00,00,00,00 2020-07-31 12:29:46.193 [rfxcom] on /dev/ttyUSB0 - Received: 14,01,00,01,02,53,10,01,08,A6,02,01,03,1C,04,00,00,00,00,00,00 2020-07-31 12:29:46.200 [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,02,07,00,00,00,00,00,00,00,00,00 2020-07-31 12:29:46.475 [rfxcom] on /dev/ttyUSB0 - Received: 14,01,07,02,07,43,6F,70,79,72,69,67,68,74,20,52,46,58,43,4F,4D 2020-07-31 12:29:46.476 [rfxcom] on /dev/ttyUSB0 - Copyright RFXCOM 2020-07-31 12:29:46.476 [rfxcom] on /dev/ttyUSB0 - Started command message queue 31 Jul 12:29:46 - [info] [rfx-lights-in:Téléc Salon neutre] connected: Serial port /dev/ttyUSB0

maxwellhadley commented 4 years ago

I have published version 2.11.2 to npm which includes this fix. Because it also downgrades serialport to version 8.0.8 (which is what node-red-node-serialport uses, it may be necessary to do the manual uninstall-and-reinstall dance I described above (but without using nvm to change NodeJS version). Hopefully this won't be necessary though.

maxwellhadley commented 4 years ago

@matz33 - This problem with messages getting disrupted is why you sometimes get stuck at the connecting stage. If the initial handshake sequence doesn't take place correctly, the firmware version number and status don't get read so I can't update the status. And yes, removing and reconnecting the RFXtrx will reset it, and force the handshake to be repeated, when it may work.

The strange thing I see is that bytes are not simply being dropped, but are appearing out of order! This could be happening either in the RFXtrx or in your computer, but not 'on the wire' between the two. I have not heard of such a problem before in the RFXtrx, but it could be a Docker problem with virtualising USB serial ports. Presumably the Docker host you are using was installed by Home Assistant - is it possible to check if it is at the latest (Docker) version?

Also check on the HA forums if anyone else is seeing a similar problem.

matz33 commented 4 years ago

I'm not using Home Assistant at all. I don't know what it could give me. Nodered is enough for me.

I'm using Docker on Synology. I had to install Domoticz to have the drivers for RFXCom on the Synology. And I added the --device /dev/ttyUSB0 option command to add the host device to the container, as I've seen in many post in how to bring the RFXCom to the nodered Docker container.

Maybe i should upgrade firmware ? In your experience, it is not risky at all ?

maxwellhadley commented 4 years ago

I have a couple of RFXtrx's I use for development which I have upgraded (& downgraded) many times without any problems. I always use the latest version of rfxmngr.exe from the RFXCOM website, and I always run on a 'normal' windows machine (i.e. not a virtual PC). I've used Windows 7 & 10 without problems. I have never tried using Docker (or HA, or Domoticz)

cris1 commented 4 years ago

Hi Max, upgraded to v2.11.2 from a snapshot running the v2.11.0 through the NodeRed Palette and that worked flawless. Everything ok now! Thanks a lot!

matz33 commented 4 years ago

Hi, same here : i upgraded successfully.

I'm still having problems to get it working though. This is the case since a lot of time, i gave up, and these days i tried to make it run again. That's why i upgraded to last version and then had the installation probleme and my posts here.

@maxwellhadley I will open a new case if necessary, unless is it is related to a docker problem. I upgraded the rfxcom to last fimrware (1025). I installed last node-red-contrib-rfxcom version, and you know i uninstall and resintall all serial and rfxcom components. Here is what i have :

Here are the logs (grep rfxcom) with my comments:

After sarting nodered and "connecting..." only :

2020-08-01 11:34:00.135 [rfxcom] on /dev/ttyUSB0 - Cleared command message queue 1 Aug 11:34:00 - [info] [rfx-lights-in:Téléc Salon neutre] connecting to /dev/ttyUSB0 2020-08-01 11:34:06.413 [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,00,00,00,00,00,00,00,00,00,00,00 2020-08-01 11:34:06.914 [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,01,02,00,00,00,00,00,00,00,00,00

After unplugging and replug of the rfxcom and having "Ok (v1025 ext 2)" after that :

2020-08-01 11:34:58.341 [rfxcom] on /dev/ttyUSB0 - RFXtrx433 disconnected from /dev/ttyUSB0 2020-08-01 11:34:58.342 [rfxcom] on /dev/ttyUSB0 - Cleared command message queue 1 Aug 11:34:58 - [info] [rfx-lights-in:Téléc Salon neutre] disconnected: bad file descriptor 1 Aug 11:35:04 - [info] [rfx-lights-in:Téléc Salon neutre] connecting to /dev/ttyUSB0 2020-08-01 11:35:09.850 [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,00,00,00,00,00,00,00,00,00,00,00 2020-08-01 11:35:10.352 [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,01,02,00,00,00,00,00,00,00,00,00 2020-08-01 11:35:10.363 [rfxcom] on /dev/ttyUSB0 - Received: 14,01,00,01,02,53,19,63,DF,FF,03,01,03,1C,04,00,00,00,00,00,00 2020-08-01 11:35:10.366 [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,02,07,00,00,00,00,00,00,00,00,00 2020-08-01 11:35:10.644 [rfxcom] on /dev/ttyUSB0 - Received: 14,01,07,02,07,43,6F,70,79,72,69,67,68,74,20,52,46,58,43,4F,4D 2020-08-01 11:35:10.645 [rfxcom] on /dev/ttyUSB0 - Copyright RFXCOM 2020-08-01 11:35:10.645 [rfxcom] on /dev/ttyUSB0 - Started command message queue 1 Aug 11:35:10 - [info] [rfx-lights-in:Téléc Salon neutre] connected: Serial port /dev/ttyUSB0 2020-08-01 11:35:28.568 [rfxcom] on /dev/ttyUSB0 - Received: 14,01,07,2E,07,43,6F,70,79,72,69,67,68,74,20,52,46,58,43,4F,4D 2020-08-01 11:35:28.569 [rfxcom] on /dev/ttyUSB0 - Copyright RFXCOM 2020-08-01 11:35:28.644 [rfxcom] on /dev/ttyUSB0 - Received: 14,01,00,2F,02,53,19,63,DF,FF,03,01,03,1C,04,52,46,58,43,4F,4D 2020-08-01 11:35:28.646 [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,03,07,00,00,00,00,00,00,00,00,00

After redeploying the flow and hving only "Connecting..." after that :

2020-08-01 11:52:04.321 [rfxcom] on /dev/ttyUSB0 - Cleared command message queue 1 Aug 11:52:05 - [info] [rfx-lights-in:Téléc Salon neutre] connecting to /dev/ttyUSB0 2020-08-01 11:52:10.524 [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,00,00,00,00,00,00,00,00,00,00,00 2020-08-01 11:52:11.025 [rfxcom] on /dev/ttyUSB0 - Sent : 0D,00,00,01,02,00,00,00,00,00,00,00,00,00

maxwellhadley commented 4 years ago

@matz33 - please open a new issue: this problem may well be Docker related, but it isn't anything to do with the original bug in 2.11.1 which I think is now fixed. I will close this issue and work on the new one, my chance to learn how to use Docker...