originallyus / node-red-contrib-alexa-local

An easy-to-use NodeRED node for adding Alexa capability to NodeRED. NO Alexa Skills required.
107 stars 25 forks source link

Alexa not discovering ("SyntaxError: Unexpected token =" error) #7

Closed skot0123 closed 6 years ago

skot0123 commented 6 years ago

I installed the node and ran discover devices but nothing was found. I saw in a closed issue that there may be issues with nodered when it is in a docker container. Am I correct that this will not work inside Docker?

torinnguyen commented 6 years ago

3 yes. that is exactly the problem

tfatykhov commented 6 years ago

easiest fix for now - is to run docker container with node red attached to host network (docker run --network=host ....) but that may not suite all especially if you are using linking. another more complicated way is to use piperwork - https://github.com/jpetazzo/pipework

Bodge-IT commented 6 years ago

My node-red is not in a docker container but I am also unable to discover new devices. Any suggestions? Running NR 0.17.5 on PI.

torinnguyen commented 6 years ago

@Bodge-IT please provide more information than just 1 sentence

Bodge-IT commented 6 years ago

I have alexa-local(0.3.0) node installed on node-red 0.17.5. I have created a new device as instructed, asked Echo to discover but nothing is found. My node-red is not in a docker container, its installed on a RaspBPi running rasbian. Echo and node-red are in the same subnet but node-red is not connected to wifi. alexa-local

torinnguyen commented 6 years ago

can you take a look at the log coming from NodeRed when you ask Echo to discover devices? if you are running from pm2, use this command: pm2 log

Bodge-IT commented 6 years ago

Aha..sorry still quite new at node-red.

I get this in the startup log: [error] [alexa-local:6bedefe6.81c1d8] SyntaxError: Unexpected token =

torinnguyen commented 6 years ago

it looks like somehow you have a dirty version of alexa-local node. here' what you can try on your rpi

cd ~/.node-red
rm -rf node_modules/node-red-contrib-alexa-local
npm install node-red-contrib-alexa-local

then restart your NodeRed

Bodge-IT commented 6 years ago

Same. This was output of install: pi@lofty:~/.node-red $ npm install node-red-contrib-alexa-local npm WARN package.json node-red-project@0.0.1 No repository field. npm WARN package.json node-red-project@0.0.1 No README data npm WARN package.json node-red-project@0.0.1 No license field. npm WARN engine stoppable@1.0.4: wanted: {"node":">=7.6.0"} (current: {"node":"5.12.0","npm":"2.14.7"}) npm WARN engine awaiting@2.2.0: wanted: {"node":">=7.6.x"} (current: {"node":"5.12.0","npm":"2.14.7"}) node-red-contrib-alexa-local@0.3.0 node_modules/node-red-contrib-alexa-local ├── ip@1.1.5 ├── peer-ssdp@0.0.5 ├── stoppable@1.0.4 (awaiting@2.2.0) └── node-persist@2.1.0 (q@1.1.2, is-absolute@0.2.6, mkdirp@0.5.1)

I notice I get an nodered/alexa-local/persist dir appear in the root of my home dir with nothing in it...is this expected?

Bodge-IT commented 6 years ago

Thought I found something on line 112 of index.js. LOCATION: "http://{{networkInterfaceAddress}}:" + port + "/upnp/amazon-ha-bridge/setup.xml",

Looks like superfluous ','

torinnguyen commented 6 years ago

nice spotting. I've published version 0.3.1 with that fixed. You need to use npm install to get the latest version if you don't want to wait.

Bodge-IT commented 6 years ago

Yes but didn't fix issue, still have Unexpected token =

torinnguyen commented 6 years ago

I've just run my code through jslint but didn't find any syntax error. Probably it's an error in one of the dependencies. I don't know how to pin point it out.

Bodge-IT commented 6 years ago

Anyway to get more info out of node-red log?

Bodge-IT commented 6 years ago

index.js:348 if (msg == null || msg.payload === null || msg.payload === undefined) {

Think should be ===?

Bodge-IT commented 6 years ago

Can you check 326-329 in peer-ssdp.js

} else { var t = line.split(' ')[0] type = (t == TYPE_M_SEARCH) ? "search" : (t == TYPE_NOTIFY ? "notify" : null); } I don't think that VAR is closed properly.

Bodge-IT commented 6 years ago

Fixed it. I noticed some weird disparity between running node-red from command line or as a service. Checking this page on Pi site, fixed the issue and has hopefully addressed other parity issues too.

Sorry to take up your time on a wild goose chase.

torinnguyen commented 6 years ago

The error is due to syntax error when running on older version of NodeJS. This has now been fixed in latest version of alexa node. You can upgrade NodeJS version using the following command sudo npm cache clean -f sudo npm install -g n sudo n stable