Hi, I am trying to execute nodejs script from ha-bridge and getting errors, I set command type to "Execute Script/Program" and my command is
[{"item":"nodejs ~/Downloads/ha-bridge/scripts/led.js 2 on", "type":"cmdDevice"}]
The command nodejs ~/Downloads/ha-bridge/scripts/led.js 2 on runs fine in terminal. But running in ha-bridge I am getting error:
Request Error, Please look in your habridge log: error {"type":6,"address":"/lights/2","description":"Error on calling out to device","parameter":"/lights/2state"}
Looking into debug log I see
Decode Json for url items: [{"item":"[{\"item\":\"nodejs ~/Downloads/ha-nridge/scripts/led.js 2 on\"}]","type":"cmdDevice"}]
Exec Request called with url: [{"item":"nodejs ~/Downloads/ha-nridge/scripts/led.js 2 on"}]
Executing request: [{"item":"nodejs ~/Downloads/ha-nridge/scripts/led.js 2 on"}] com.bwssystems.HABridge.plugins.exec.CommandHome
Could not execute request: [{"item":"nodejs ~/Downloads/ha-nridge/scripts/led.js 2 on"}]
Any idea what's wrong?
Thanks!
So the first thing I see is you are using a relative path to your script. Fully qaulify that. Also, I'm not sure if a cmd shell is needed for nodejs to run on windows, if it does, you'll need to use cmd.exe to execute it.
Thanks for the prompt reply. Tried full paths to both Node and the script:
[{"item":"/usr/bin/nodejs /home/ygalanter/ha-bridge/scripts/led.js 2 off"}]
This is Ubuntu, am I missing something?
Thanks,
Yuriy.
From: BWS Systems
Sent: Friday, February 24, 2017 1:52 PM
To: bwssytems/ha-bridge
Cc: ygalanter ; Author
Subject: Re: [bwssytems/ha-bridge] Cannot run external script. (#496)
So the first thing I see is you are using a relative path to your script. Fully qaulify that. Also, I'm not sure if a cmd shell is needed for nodejs to run on windows, if it does, you'll need to use cmd.exe to execute it.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
try putting /bin/sh in front of that to see if it needs a console
Unfortunately same thing is happening, I am at a loss.
From: BWS Systems
Sent: Friday, February 24, 2017 1:59 PM
To: bwssytems/ha-bridge
Cc: ygalanter ; Author
Subject: Re: [bwssytems/ha-bridge] Cannot run external script. (#496)
try putting /bin/sh in front of that to see if it needs a console
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
Alrighty, Put that command into a shell script then call the shell script form the bridge.
Am I doing this right? I created script that works from terminal if I call it:
/home/ygalanter/ha-bridge/scripts/led.sh 2 on
and use it in bridge command:
[{"item":"/home/ygalanter/ha-bridge/scripts/led.sh 2 on"}]
And still getting same error :(
From: BWS Systems
Sent: Friday, February 24, 2017 2:31 PM
To: bwssytems/ha-bridge
Cc: ygalanter ; Author
Subject: Re: [bwssytems/ha-bridge] Cannot run external script. (#496)
Alrighty, Put that command into a shell script then call the shell script form the bridge.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
You will need to have the whole command in the script:
/usr/bin/nodejs /home/ygalanter/ha-bridge/scripts/led.js 2 off
Yes, this is content of the led.sh (I am passing params to it):
/usr/bin/nodejs /home/ygalanter/ha-bridge/scripts/led.js $1 $2
if I call it from terminal as
/usr/bin/nodejs /home/ygalanter/ha-bridge/scripts/led.js 2 off
it works. But bridge stirll throws
Request Error, Pleae look in your habridge log: error {"type":6,"address":"/lights/2","description":"Error on calling out to device","parameter":"/lights/2state"}
From: BWS Systems
Sent: Friday, February 24, 2017 2:56 PM
To: bwssytems/ha-bridge
Cc: ygalanter ; Author
Subject: Re: [bwssytems/ha-bridge] Cannot run external script. (#496)
You will need to have the whole command in the script:
/usr/bin/nodejs /home/ygalanter/ha-bridge/scripts/led.js 2 off
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
So for fun, put the parameters in the script and do not pass them... this is just a test
That didn't work, but I found if instead of JSON I enter in Target Item
field raw command "nodejs /home/ygalanter/ha-bridge/scripts/led.js 2 on" -
it works and command is executed successfully.
The only strange thing I found if I pass 2 parameter - it work. But if I
try 3, e.g. "nodejs /home/ygalanter/ha-bridge/scripts/led.js 2 dim 10" - it
works, but bridge throws error at the end. That make Echo execute command,
but at the end say "Device not found"
Any idea why this is happening?
On Fri, Feb 24, 2017 at 4:33 PM, BWS Systems notifications@github.com
wrote:
So for fun, put the parameters in the script and do not pass them... this
is just a test—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/bwssytems/ha-bridge/issues/496#issuecomment-282410336,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHhqwGo8YXA0qvGd-2xV2BcfmguyUF-Hks5rf0y0gaJpZM4MLitI
.
Never mind, deleted and re-added the device and it's is working now. Here's
final commands:
ON: nodejs /home/ygalanter/ha-bridge/scripts/led.js 2 on
DIM: nodejs /home/ygalanter/ha-bridge/scripts/led.js 2 dim
${intensity.percent}
OFF: nodejs /home/ygalanter/ha-bridge/scripts/led.js 2 off
btw, I am using https://github.com/mwittig/node-milight-promise module,
which is a very nice wrapper for Milight v6. Maybe others can use it too.
Thanks for your help!
Yuriy.
On Fri, Feb 24, 2017 at 3:02 PM, yuri@galanter.net wrote:
Yes, this is content of the led.sh (I am passing params to it):
#!/bin/sh
/usr/bin/nodejs /home/ygalanter/ha-bridge/scripts/led.js $1 $2if I call it from terminal as
/usr/bin/nodejs /home/ygalanter/ha-bridge/scripts/led.js 2 off
it works. But bridge stirll throws
Request Error, Pleae look in your habridge log: error
{"type":6,"address":"/lights/2","description":"Error on calling out to
device","parameter":"/lights/2state"}From: BWS Systems notifications@github.com
Sent: Friday, February 24, 2017 2:56 PM
To: bwssytems/ha-bridge ha-bridge@noreply.github.com
Cc: ygalanter yuri@galanter.net ; Author author@noreply.github.com
Subject: Re: [bwssytems/ha-bridge] Cannot run external script. (#496)You will need to have the whole command in the script:
/usr/bin/nodejs /home/ygalanter/ha-bridge/scripts/led.js 2 off
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/bwssytems/ha-bridge/issues/496#issuecomment-282389034,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHhqwD0tqLj7RYK6wxv86tNViu40i2xrks5rfzXugaJpZM4MLitI
.
It's working out beautifully. I put together a small blog post:
http://codecorner.galanter.net/2017/02/24/full-control-of-your-limitless-ledmilight-v6-bulbs-from-amazon-echo/
maybe will be useful to others struggling with Milight v6.
Thanks,
Yuriy.
On Fri, Feb 24, 2017 at 8:45 PM, Yuriy Galanter yuri@galanter.net wrote:
Never mind, deleted and re-added the device and it's is working now.
Here's final commands:ON: nodejs /home/ygalanter/ha-bridge/scripts/led.js 2 on
DIM: nodejs /home/ygalanter/ha-bridge/scripts/led.js 2 dim
${intensity.percent}
OFF: nodejs /home/ygalanter/ha-bridge/scripts/led.js 2 offbtw, I am using https://github.com/mwittig/node-milight-promise module,
which is a very nice wrapper for Milight v6. Maybe others can use it too.Thanks for your help!
Yuriy.
On Fri, Feb 24, 2017 at 3:02 PM, yuri@galanter.net wrote:
Yes, this is content of the led.sh (I am passing params to it):
#!/bin/sh
/usr/bin/nodejs /home/ygalanter/ha-bridge/scripts/led.js $1 $2if I call it from terminal as
/usr/bin/nodejs /home/ygalanter/ha-bridge/scripts/led.js 2 off
it works. But bridge stirll throws
Request Error, Pleae look in your habridge log: error
{"type":6,"address":"/lights/2","description":"Error on calling out to
device","parameter":"/lights/2state"}From: BWS Systems notifications@github.com
Sent: Friday, February 24, 2017 2:56 PM
To: bwssytems/ha-bridge ha-bridge@noreply.github.com
Cc: ygalanter yuri@galanter.net ; Author author@noreply.github.com
Subject: Re: [bwssytems/ha-bridge] Cannot run external script. (#496)You will need to have the whole command in the script:
/usr/bin/nodejs /home/ygalanter/ha-bridge/scripts/led.js 2 off
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/bwssytems/ha-bridge/issues/496#issuecomment-282389034,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHhqwD0tqLj7RYK6wxv86tNViu40i2xrks5rfzXugaJpZM4MLitI
.
Hello everyone,
I had a problem that may be related to this. I tried some of the formats in the
documentation, but it seems that none of them work correctly. Like @ygalanter mentioned above, it only started working when I entered the raw command (or prefixed with exec://), but not when using the JSON.
In fact, when I entered the command [{"item":"exec://touch /root/testietest","type":"cmdDevice"}], this created a file called testietest\"\,\"type\"\:\"cmdDevice\"\}\], which is clearly not the desired behaviour. Additionally, when I left out the exec, nothing worked, as @kennyhq already remarked in #373 (towards the end).
So, we should at least change the documentation. But maybe there is a bigger underlying problem?
(Am I right in thinking the problem is somewhere in the file HABridge/plugins/exec/CommandHome.java? If you think this is not just my stupidity, I could take a look and try to find out what the problem is.)
That is very interesting, I'll take a look
@Nielius I have tried this on my Pi and it creates just the file "testietest"
Did you use the UI? And if so the only thing that goes in the target item field is "exec://touch /root/testietest"
Yes, I did actually use the UI. Thanks for looking into it.
As I mentioned, just enter the line in target item as "exec://something". The UI handles the JSON format for you underneath.
I know this old topic is there a way to call this line up in windows? what would the path be?? Or is this lose cause.. Im using my only pi for my Octiprint and don't want to buy another pi right now. Is there a way to call the script within windows. Thanks
You can execute windows commands as well by using cmd.exe as your first argument.
@bwssytems - Not sure if you're able to help, but I'm fairly new to this and set up node-milight-promise and habridge on my raspberrypi. I can get the Echo to see the bridge device and can terminal command: nodejs /home/pi/ha-bridge/scripts/led.js 1 on and the sort in order successfully toggle the lights.
The issue is when I add use "nodejs /home/pi/ha-bridge/scripts/led.js 1 on" with the "Execute command" on any of the actions within HA bridge. I get an error saying:
Request Error, Please look in your habridge log: error {"type":6,"address":"/lights/5","description":"Error on calling out to device","parameter":"/lights/5state"}
and the log says:
"Could not execute request: nodejs /home/pi/ha-bridge/scripts/led.js 1 on with message: Cannot run program "nodejs": error=2, No such file or directory"
I'm inexperienced with these tools and have been trying to figure out for hours why I can run the command in terminal and trying various syntax in HA Bridge to get this to run. Why is it saying replying with "no such file or directory" and how can I fix this?
If I add anything before the string (sh/bash/sudo) it does not return any errors but it does not run the command either.
Did you try /usr/bin/nodejs instead of nodejs? Or /usr/bin/node?
I have and it generates the same error:
"/usr/bin/nodejs": error=2, No such file or directory
This same code does work in terminal when I SSH into my pi with the path as well.
To test I even tried creating a test.sh with a "mkdir" command and using "/home/pi/ha-bridge/scripts/test.sh" returns
Could not execute request: /home/pi/ha-bridge/scripts/test.sh with message: Cannot run program "/home/pi/ha-bridge/scripts/test.sh": error=2, No such file or directory
I also tried using: exec://(script path) with the same error.
Is it looking in a different directory or something? what am I doing wrong?
So it looks like the issue is that I was actually running it out of docker which is why it was not working.
It is all good now!!!
Most helpful comment
It's working out beautifully. I put together a small blog post:
http://codecorner.galanter.net/2017/02/24/full-control-of-your-limitless-ledmilight-v6-bulbs-from-amazon-echo/
maybe will be useful to others struggling with Milight v6.
Thanks,
Yuriy.
On Fri, Feb 24, 2017 at 8:45 PM, Yuriy Galanter yuri@galanter.net wrote: