Coder Social home page Coder Social logo

Comments (34)

Barabba11 avatar Barabba11 commented on September 16, 2024 3

I think I soved it, I typed the following commands:
first I checked it the port is in use already: sudo iptables -L -n (it was empty, so ok I proceeded)
I added a listening port: sudo iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8000
save the table and have them automatically after reboot: sudo apt-get install iptables-persistent.
Works, thanks :) tomorrow I report if Alexa can find module )

from node-red-contrib-amazon-echo.

datech avatar datech commented on September 16, 2024

Hello,

Yes, it is confirmed that package is working with Echo Dot 2 and 3 gen. I don’t have Echo Plus to test the integration and no one has confirmed that is working on such device.

Do you experience any issues on Echo Plus?

from node-red-contrib-amazon-echo.

Barabba11 avatar Barabba11 commented on September 16, 2024

I'll test it soon! :) Is Echo Plus a 3rd generation? Maybe..

from node-red-contrib-amazon-echo.

datech avatar datech commented on September 16, 2024

Great!

All types of Echo devices have to be supported including 2rd gen of Echo Plus, as this package is simulating Philips Hue hub which is supported by all Echo generations.

Let me know if you have any problem.

from node-red-contrib-amazon-echo.

Barabba11 avatar Barabba11 commented on September 16, 2024

Got it! I can test it only tomorrow!
One question, is it normal that the module takes about 4 minutes to install keeping the cpu average 30% (peak of 40) (when normally is 2-4%) and the ram usage float from 0,23GB to 0,28? First time I see it takes so long..
I'm asking because I would know if all is ok with my Raspberry3 and installations. thanks

from node-red-contrib-amazon-echo.

Zabov79 avatar Zabov79 commented on September 16, 2024

I can confirm that it works on echo plus 3rd gen.

from node-red-contrib-amazon-echo.

datech avatar datech commented on September 16, 2024

Thanks for checking this out!

On your question:
The installation is similar to other NPMs - download and unarchive, nothing special. After the deployment of the Amazon Echo Hub node it will start an HTTP server that will simulated the Philips Hue hub. This might be take some of the Raspberry resources. I’m running Home Assistant over Raspberry PI 3 Model B which uses Node-Red as a docker container and I don’t see any significant performance degradations.

from node-red-contrib-amazon-echo.

Barabba11 avatar Barabba11 commented on September 16, 2024

Thanks for answering, no performance degradations, only long time to install it. Is it normal to have 4-5 minutes for install?
I would consider this a health sign form my installation, maybe too long and something have to bee check.
Well I have many modules loading at startup, mqtt server, broker, dashboard, cutoms nodes and now Alexa.. it took about 90 seconds, after it the cpu goes to usually 2-4%

from node-red-contrib-amazon-echo.

Barabba11 avatar Barabba11 commented on September 16, 2024

Hi friend, I tested it, I mean I deployed the both nodes on the flow and I have suddenly and error, unable to start on port 80. I tried to change port, same result. WHat is wrong? The Http server does not start? In console I read this. [error] Error: listen EACCES: permission denied 0.0.0.0:80

from node-red-contrib-amazon-echo.

Barabba11 avatar Barabba11 commented on September 16, 2024

Ok, searching with google I found that for open low ports I need to execute EACCES with root privileges, and I can confirm it is the problem because if I choose a high port it starts correctly.
Now the Node red staff always recomended to start it without root privileges, the reason is not clear but seems it keeps it clean and working as it should. We need port 80, how can we have then EACCES with su privileges?

UPDATE: I tried run node red from root account, bad idea, I've had an empty flow as result and try to install on it the module in console I had:
22 Jan 22:29:18 - [info] Waiting for missing types to be registered:
22 Jan 22:29:18 - [info] - amazon-echo-hub
22 Jan 22:29:49 - [info] Stopping flows
22 Jan 22:29:49 - [info] Stopped flows
22 Jan 22:29:49 - [info] Waiting for missing types to be registered:
22 Jan 22:29:49 - [info] - amazon-echo-hub
22 Jan 22:29:49 - [info] - amazon-echo-device
Fortunately starting all back in user mode I had my flow back:
so we need to solve the issue on lower ports, thanks

from node-red-contrib-amazon-echo.

Barabba11 avatar Barabba11 commented on September 16, 2024

Somebody suggested solutions:

Try authbind:

http://manpages.ubuntu.com/manpages/hardy/man1/authbind.1.html

After installing, you can add a file with the name of the port number you want to use in the following folder: /etc/authbind/byport/

Give it 500 permissions using chmod and change the ownership to the user you want to run the program under.

After that, do "authbind node ..." as that user in your project.

Another approach is to make port redirection:

sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 900 -j REDIRECT --to-port 3000

And run your server on >1024 port:

require('http').createServer().listen(3000);

ps the same could be done for https(443) port by the way.

Give Safe User Permission To Use Port 80

Remember, we do NOT want to run your applications as the root user, but there is a hitch: your safe user does not have permission to use the default HTTP port (80). You goal is to be able to publish a website that visitors can use by navigating to an easy to use URL like http://ip:port/

Unfortunately, unless you sign on as root, you’ll normally have to use a URL like http://ip:port - where port number > 1024.

A lot of people get stuck here, but the solution is easy. There a few options but this is the one I like. Type the following commands:

sudo apt-get install libcap2-bin
sudo setcap cap_net_bind_service=+ep `readlink -f \`which node\``

Now, when you tell a Node application that you want it to run on port 80, it will not complain.

The last one seems the cleanest..

from node-red-contrib-amazon-echo.

datech avatar datech commented on September 16, 2024

Yes, port 80 is required. I’ve listed it in the doc. All new Echo devices will try to connect to port 80.

Here (#1) we’ve had a discussion around this topic. There are a lot of different solutions. Here are just two of them

from node-red-contrib-amazon-echo.

Barabba11 avatar Barabba11 commented on September 16, 2024

Thanks for answer,
Option2: can you kindly explain how to run the docker container with root user in your module? Can we change something inside Javascripts?
Option1: running Node-Red as root is not a choice, it will spoil, I tested it, files will be stored in wrong paths, not all modules will work.
Option3: NAT the port can be ok, but it would be better support natively 80.. Anyway, how to do that? Running the NAT is possible to find, but if in your module is needed to specify the port.. and I chose for example 8000, it will set the server to 8000 and connect to it, now how to change only the 8000 to 80 and leave the server to 8000?

Another question, I've heard about control Alexa by the "skills", do you know this? I'm new to Alexa..
If yes, any bad sides using "skills"? Better to simulate Philips? Thank you.

from node-red-contrib-amazon-echo.

datech avatar datech commented on September 16, 2024

For option 2 you have to run the Node-Red in a docker container. Here is a how to do it: https://nodered.org/docs/platforms/docker

About skills: This module doesn't use any cloud services. So, you can do the same with modules that utilize skills, if you don't mind to send data to the cloud.

from node-red-contrib-amazon-echo.

Barabba11 avatar Barabba11 commented on September 16, 2024

you perfect cleared me, so NAT is the solution. Please clear me how can I NAT, I mean, is it enough to do that and leave for example 8000 in the module? (with nat the server will listen to original 8000 and natted 80).
Thank you

from node-red-contrib-amazon-echo.

datech avatar datech commented on September 16, 2024

Just edit the Amazon Echo Node to use port 8000, this will run the Hue hub on port 8000. Next step is to use iptables to forward port 80 to 8000.

from node-red-contrib-amazon-echo.

wongnam avatar wongnam commented on September 16, 2024

@Barabba11 Just tried it. I confirm that your solution work as a charm. Thank you very much.
update: My gears are Echo Dot 3rd gen; Echo Dot 1st gen; Echo Dot 2nd gen; + Pi 3B+

from node-red-contrib-amazon-echo.

datech avatar datech commented on September 16, 2024

@wongnam Can you confirm that device discovery process is working if it is initiated from Echo Dot 1st gen?

Thanks in advance

from node-red-contrib-amazon-echo.

wongnam avatar wongnam commented on September 16, 2024

@datech I have just disconnected all Echo Dot gen 1 and 2, only 1 Echo Dot 3rd gen is up, I can confirm that it can discover your node as expected on port 8000 with NAT solution(port 80 ->8000).
I am very happy. :)

Screen shot FYI.
image
update more screen shot FYR
image

from node-red-contrib-amazon-echo.

datech avatar datech commented on September 16, 2024

@wongnam I'm glad you like it :)

It was confirmed that it is working with Echo Dot 2nd and 3rd generations, but no one has tested it with Echo 1st gen. As you have such device can test the module with it? Thanks

from node-red-contrib-amazon-echo.

Barabba11 avatar Barabba11 commented on September 16, 2024

Ok works, just noticed that the message exiting from node ha no topic, even if I specified one.
I also tried to create topic (in the node proprieties) before Alexa recognizes device (in case Alexa acquire this topic and send it back at every message) but didn't help.
Maybe a little bug? This is the output I have:
msg : Object
object
on: true
bri: 52
hue: 0
sat: 254
ct: 199
colormode: "ct"
payload: "on"
deviceid: "5af2ea8d2e5***"
topic: ""
_msgid: "145eb1ee.c32f9e

from node-red-contrib-amazon-echo.

wongnam avatar wongnam commented on September 16, 2024

@Barabba11 It works as its way, no issue at all.

1/23/2019, 3:13:08 PMnode: 7ba9259b.2cbccc
cmnd/newnode/test : msg : Object
object
on: true
bri: 120
hue: 35862
sat: 107
ct: 350
colormode: "hs"
payload: "on"
deviceid: "6ad2b221dbb35c"
topic: "cmnd/newnode/test"
_msgid: "83a981b7.d97cf"
1/23/2019, 3:13:08 PMnode: 85904c83.36fcf
cmnd/newnode/test : msg.payload : string[2]
"on"

image
image

from node-red-contrib-amazon-echo.

Barabba11 avatar Barabba11 commented on September 16, 2024

ok I got where was the problem, I didn't connect the node Hub with the device node. Now I did and I receive the right topic..
With only device node connected I had the same payload without topic. Thank you

from node-red-contrib-amazon-echo.

Barabba11 avatar Barabba11 commented on September 16, 2024

mates, i've an issue..
I'm telling Alexa to switch on and regulate intensity, actually the output packet from Alexa is the same! It reports the same payload "ON", and same intensity (it remembers the previous one).
Now I have a dimmer that have two functions, I can simply swicth on and switch off it, it will remeber it last settings, or I can tell it the intensity. I need alexa tell me only to switch it on, if i tell her only that, I need to know if I tell her to regulate or to switch on (and use the last setting), how to solve this?
Thank you

from node-red-contrib-amazon-echo.

datech avatar datech commented on September 16, 2024

Can you test this from the Alexa app?

Also you can check what Alexa is sending to the Amazon Echo Hub node in the Node-Red console. All Alexa commands are logged as debug messages in the console like these:

20 Jan 22:19:44 - [debug] Request body: {"on":true}
20 Jan 22:19:49 - [debug] Request body: {"on":false}
21 Jan 20:25:21 - [debug] Request body: {"on":true}

from node-red-contrib-amazon-echo.

wongnam avatar wongnam commented on September 16, 2024

@wongnam I'm glad you like it :)

It was confirmed that it is working with Echo Dot 2nd and 3rd generations, but no one has tested it with Echo 1st gen. As you have such device can test the module with it? Thanks

@datech My Echo Dot 1st gen and also Echo Dot 2nd gen do not detect HUB/Device node. Even i do not use NAT, I just use port >1024. I don't know why.

from node-red-contrib-amazon-echo.

Barabba11 avatar Barabba11 commented on September 16, 2024

wongnam use NAT (why not, nothing to install, just configure how linux manage IP protocol) and see if it helps. If not, check if the http server port is reachable from the same wifi where alexa is connected, chances are you have network problem

from node-red-contrib-amazon-echo.

Barabba11 avatar Barabba11 commented on September 16, 2024

datech I'm not sure I'm doing right debug. Can you please test yourself how Alexa outputs after request "regulate it at 80% " and @switch on it"? In my opinion they are the same as your module outputs, but maybe, maybe there is some other data that can change and you descard from outputing in the module, please check.
It has sense actually that Alexa output always the last dimming she remember I used with her, there are few systems that allow change the dimmer else (for example red node, or the dimmer specific app, or a physical button in the wall connected to dimmer by wires), so if the dimmer is "stuoid" maybe it needs always to be remembered of the last setting.|
Anyway I hope something, maybe only a bit, can differ between the two commands. Thank you!

from node-red-contrib-amazon-echo.

datech avatar datech commented on September 16, 2024

The messages you’ve sent are debug message of the nodes. There is one more way to debug Node-Red - it’s to check the Node-Red console.

In Node-Red console you can see all log messages printed by the Node-Red process. When you start the Node-Red you will usually see something like this:

$ node-red
23 Jan 20:19:04 - [info] 

Welcome to Node-RED
===================

23 Jan 20:19:04 - [info] Node-RED version: v0.19.5
23 Jan 20:19:04 - [info] Node.js  version: v8.15.0
23 Jan 20:19:04 - [info] Linux 4.15.0-29-generic x64 LE
23 Jan 20:19:04 - [info] Loading palette nodes

At the same console you can see the body of all requests coming from Alexa. For example:

23 Jan 20:22:29 - [debug] Request body: {"bri":128}
23 Jan 20:22:35 - [debug] Request body: {"hue":0,"sat":254}
23 Jan 20:22:57 - [debug] Request body: {"on":false}
23 Jan 20:22:29 - [debug] Request body: {"bri":128}

Set brightness to 50%

23 Jan 20:22:35 - [debug] Request body: {"hue":0,"sat":254}

Set color to red

23 Jan 20:22:57 - [debug] Request body: {"on":false}

Turn off the device

Do you have such logs in your Node-Red console, when you change the device settings from the Alexa mobile app?

from node-red-contrib-amazon-echo.

Barabba11 avatar Barabba11 commented on September 16, 2024

Maybe I wrote it not cleared and you don't understand, you better than me know the object we see in node red outputed from Alexa. If there are all parameters that Alexa outputs we can't do nothing, the two packets generated by "regulate it to 80%" and "switch it on" (and previously was 80% too) are equal, and we can't distinguish them.
May you please confirm it? Thank you!

from node-red-contrib-amazon-echo.

wongnam avatar wongnam commented on September 16, 2024

@Barabba11 I don't know that i understood your comment yet, but i am using this node without issue.

update: only one thing is strange that when i change the Bri:value only, the node does not turn on the light as Alexa app did.

Below flow is a simulation the feedback of device that send value to Hub.
image

[{"id":"4b6f8a3d.70b1c4","type":"amazon-echo-hub","z":"873876cd.790978","port":"8000","enableinput":true,"x":540,"y":380,"wires":[["294ece1.3ac9e32"]]},{"id":"204e0e5a.1c23d2","type":"debug","z":"873876cd.790978","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":860,"y":380,"wires":[]},{"id":"294ece1.3ac9e32","type":"amazon-echo-device","z":"873876cd.790978","name":"new plug","topic":"newplug","x":720,"y":380,"wires":[["204e0e5a.1c23d2"]]},{"id":"887fbea8.7741d","type":"function","z":"873876cd.790978","name":"Hub Input","func":"var nodeid=\"294ece1.3ac9e32\";\n\nif (msg.payload == \"on\"){\n msg.payload = {\n on: true,\n nodeid: nodeid\n }\n\n} else if(msg.payload == \"off\"){\n msg.payload = {\n on: false,\n nodeid: nodeid\n }\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":280,"y":380,"wires":[["4b6f8a3d.70b1c4"]]},{"id":"5e2d808f.9670d","type":"inject","z":"873876cd.790978","name":"","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":380,"wires":[["887fbea8.7741d"]]},{"id":"f9ba3156.bb992","type":"inject","z":"873876cd.790978","name":"","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":340,"wires":[["887fbea8.7741d"]]},{"id":"f2bfc92a.1f5798","type":"inject","z":"873876cd.790978","name":"{\"on\":true,\"bri\":33, \"nodeid\":\"294ece1.3ac9e32\"}","topic":"","payload":"{\"on\":true,\"bri\":33, \"nodeid\":\"294ece1.3ac9e32\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":700,"wires":[["4b6f8a3d.70b1c4"]]},{"id":"804b60f.0e355a","type":"inject","z":"873876cd.790978","name":"{\"on\":false, \"nodeid\":\"294ece1.3ac9e32\"}","topic":"","payload":"{\"on\":false, \"nodeid\":\"294ece1.3ac9e32\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":580,"wires":[["4b6f8a3d.70b1c4"]]},{"id":"d1f73c17.ec0eb","type":"inject","z":"873876cd.790978","name":"{\"on\":true,\"bri\":135, \"nodeid\":\"294ece1.3ac9e32\"}","topic":"","payload":"{\"on\":true,\"bri\":135, \"nodeid\":\"294ece1.3ac9e32\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":740,"wires":[["4b6f8a3d.70b1c4"]]},{"id":"40b5ede.7304c14","type":"inject","z":"873876cd.790978","name":"{\"on\":true,\"bri\":254, \"nodeid\":\"294ece1.3ac9e32\"}","topic":"","payload":"{\"on\":true,\"bri\":254, \"nodeid\":\"294ece1.3ac9e32\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":780,"wires":[["4b6f8a3d.70b1c4"]]},{"id":"a4fe3ca2.2640e","type":"inject","z":"873876cd.790978","name":"{\"bri\":63, \"nodeid\":\"294ece1.3ac9e32\"}","topic":"","payload":"{\"bri\":63, \"nodeid\":\"294ece1.3ac9e32\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":460,"wires":[["4b6f8a3d.70b1c4"]]},{"id":"3404716f.84062e","type":"inject","z":"873876cd.790978","name":"{\"bri\":127, \"nodeid\":\"294ece1.3ac9e32\"}","topic":"","payload":"{\"bri\":127, \"nodeid\":\"294ece1.3ac9e32\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":500,"wires":[["4b6f8a3d.70b1c4"]]},{"id":"34e4a1d6.63c87e","type":"comment","z":"873876cd.790978","name":"Set Brightness Only","info":"","x":110,"y":420,"wires":[]},{"id":"a4cbf474.3212c8","type":"comment","z":"873876cd.790978","name":"Off","info":"","x":70,"y":540,"wires":[]},{"id":"853584ce.1d6608","type":"comment","z":"873876cd.790978","name":"On and set Brightness","info":"","x":120,"y":660,"wires":[]},{"id":"64f98a98.76e374","type":"inject","z":"873876cd.790978","name":"{\"on\":true, \"nodeid\":\"294ece1.3ac9e32\"}","topic":"","payload":"{\"on\":true, \"nodeid\":\"294ece1.3ac9e32\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":620,"wires":[["4b6f8a3d.70b1c4"]]}]

from node-red-contrib-amazon-echo.

datech avatar datech commented on September 16, 2024

@Barabba11
Here are a few examples how it is working:

Example 1:

  • Command: Turn on
    Alexa will send to the hub:
    {on: true}

  • Command: Set brightness to 50%
    Alexa will send to the hub:
    {"bri":128}

  • Command: Set color to red
    Alexa will send to the hub:
    {"hue":0,"sat":254}

  • Command: Turn off
    Alexa will send to the hub:
    {on: true}

After this sequence of commands the device will be in the following state:
on: false
color: red
brightness: 50%

If you say at this point "turn on" the state of the device will be:
on: true
color: red
brightness: 50%

So, the color and brightness are not cleared after the device is turned off.

Example 2:

Device state is:
on: false
brightness: 100%

  • Command: Set brightness to 50%
    Alexa will send to the hub:
    {on: true}
    {"bri":128}

I cannot control what Alexa is sending to the hub, I can override if I have to, but the described examples are the default Alexa behavior

I hope this answer your question.

from node-red-contrib-amazon-echo.

Barabba11 avatar Barabba11 commented on September 16, 2024

Yes, thank you guys, I just needed to hear "yes I tried myself and you are right, the two ouptus are equal and there is no way to distinguist them'
to distinguist I just asked if there is some filter to the Alexa output, or the object we see in node red is the exact dump of what alexa sent, without cuts. Thank you!

from node-red-contrib-amazon-echo.

wongnam avatar wongnam commented on September 16, 2024

You can base on Colormode:ct , Colormode:hs to filter it.

from node-red-contrib-amazon-echo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.