Author Topic: Any Philips Hue users here?  (Read 29666 times)

0 Members and 1 Guest are viewing this topic.

Casmo

  • $upporter
  • Contributor
  • *****
  • Posts: 85
  • Karma: 0
    • View Profile
Any Philips Hue users here?
« on: March 06, 2014, 09:00:13 AM »
Hi all,

 I realise no official plugin for hue is being developed (understandably so being a niche and expensive product) but im just wondering if anyone here is a hue user and has found a way to get vox commando talking to it?
I did come across this http://www.everyhue.com/vanilla/discussion/161/winhue-windows-application/p1 and hoped I could use cmd line arguments to control my lights but I cant seem to get it working and the project doed not appear to be very active.



jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Any Philips Hue users here?
« Reply #1 on: March 07, 2014, 12:10:53 PM »
Did you make any progress?   From looking at the project website, it looks like others have had some success with this program.  It also looks like there is active discussion taking place.

Casmo

  • $upporter
  • Contributor
  • *****
  • Posts: 85
  • Karma: 0
    • View Profile
Re: Any Philips Hue users here?
« Reply #2 on: March 11, 2014, 05:11:32 PM »
Hi,

 Some progress made! Using this http://bahamas10.github.com/hue-cli/ I can send commands to the lights from the command window. What I'm not sure of is how to call this from an action. As in if I add a 'hidden launch', I'm not what to put as path & arguments.. I'm sure it's very simple, I'm just not a scripter..

would hugely appreciate some pointers as I'm close...

Thanks in advance

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Any Philips Hue users here?
« Reply #3 on: March 11, 2014, 05:49:54 PM »
I'm a bit confused because what you linked to does not look like a Windows command line interface.

But assuming you are able to issue commands from a windows command prompt, just tell us what you are typing into the command line.

If using the Launch command, it is extremely simple.  You don't need to be a scripter (whatever that means).

If you add a "Launch.Hidden" action to a VC command it accepts two parameters (These are clearly indicated within the LCB and if you watch any of the tutorials on building commands in VC, or if you read the wiki you will already know how to create actions and how to figure out what the parameters are for an action).  Here is a view of the Launch.Hidden from the action selection tree:

1st parameter is path (path to application) which is going to be something like c:\somefolder\myhueproggy.exe
2nd parameter is the command line params to send to the application.  I don't know what these are.

here is action info for Launch on our wiki: http://voxcommando.com/mediawiki/index.php?title=Actions#Launch

Casmo

  • $upporter
  • Contributor
  • *****
  • Posts: 85
  • Karma: 0
    • View Profile
Re: Any Philips Hue users here?
« Reply #4 on: March 11, 2014, 06:06:41 PM »
Thanks for the reply. Pardon my ignorance, my terminology is probably all wrong.
The command line interface I installed allows me to open the cmd window, type 'hue lights 1 off' and the command is sent to the bridge. The exe is installed 'globally' (not sure what this means) so I'm not clear as to what the path is.

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Any Philips Hue users here?
« Reply #5 on: March 11, 2014, 06:21:22 PM »
Quote
The command line interface I installed...
Can you explain what the "commandline interface" is (maybe the hue programm?).

Quote
...allows me to open the cmd window,
Do you mean the CMD.exe from windows?

Is it possible to post a screenshot?
***********  get excited and make things  **********

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Any Philips Hue users here?
« Reply #6 on: March 11, 2014, 06:35:13 PM »
Hi Casmo,

It's definitely confusing for those of us not familiar with how these things might work.

Can I assume that you followed the instructions on that site, downloaded the node.js and then followed their instructions by entering "npm install -g hue-cli" in the command prompt window?

The question is where you ran that installer, because that's the file path you'll need.

For me, the path is c:\users\[myusername]

If you can figure that out, then place the batch file I've attached here into that directory. Then you create your Vox commands according to the examples they give. You won't be able to access results, but you should be able to *send* commands.

[EDIT FOR FUTURE READERS: *** Later we figured out that the hue-cli commands are executable globally, so you can put the attached test.bat file directly in your VC directory, and then no filepath is needed in the first parameter, just the filename "test.bat". ***]

Here is a command group with 2 sample commands, based on the command examples provided at your link. I can't test them, obviously:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<commandGroup open="True" name="hue" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="271" name="turn on hue lights on or off" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Launch.RawParam</cmdType>
      <cmdString>c:\users\[yourusername]\test.bat&amp;&amp;lights {1}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>turn hue lights</phrase>
    <payloadList>on, off</payloadList>
  </command>
  <command id="292" name="change light colour" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="{1} refers to the light number&#xD;&#xA;{2} to the colour">
    <action>
      <cmdType>Launch.RawParam</cmdType>
      <cmdString>c:\users\[yourusername]\test.bat&amp;&amp;lights {1} {2}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>turn hue light</phrase>
    <payloadRange>1,10</payloadRange>
    <phrase>to</phrase>
    <payloadList>red, green, blue</payloadList>
  </command>
</commandGroup>

Try selecting and copying all of the above, pasting into your tree, and then you will have to put the attached batch file in the proper directory and change the file path I have used in my commands to the correct path for your installation.

I hope this helps you to get started.

Note that if/when you have your commands working, you can change from RawParam to Launch.Hidden so that the command prompt window no longer appears.

« Last Edit: March 18, 2014, 06:40:32 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Any Philips Hue users here?
« Reply #7 on: March 11, 2014, 06:38:53 PM »
The above 2 commands use the command line examples:

Code: [Select]
hue lights on
and

Code: [Select]
hue lights 1 red
The batch file already has the "hue" in it so we are just adding the "lights x y z" parameters in our VC command.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Any Philips Hue users here?
« Reply #8 on: March 11, 2014, 09:08:00 PM »
We have never used node.js so we are all a bit ignorant.  :D

If you can run hue in a command window regardless of what directory you are in, then the simplest is probably to but the batch file directly in your VC folder.  Then you can call it using Launch.rawparams -- test.bat  -- params

In our tests this works, but since we don't have a bridge to test with all we can do is test using the params: search
This keeps the window open for a few seconds, then it returns "0 stations found"  and then the window closes immediately.

So I think this method should work for you.

The reason you need to use a batch file, is that VC looks for a file to execute and can't find a file by the name of hue, so it throws an error.  It can find the batch file though, and the batch file doesn't mind calling a file that isn't there, apparently.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Any Philips Hue users here?
« Reply #9 on: March 11, 2014, 09:19:41 PM »
Using this api directly seems like it would be much easier / and much better.

http://developers.meethue.com/index.html

Is there some reason why you can't use this?  You should be able to test the basic function by entering the correct URL into the address bar of your web browser.

Are you able to control your hue through this api?  It seems like you just need to find the IP address of your bridge, and know your username and then you can enter URLs like this example which returns a list of lights:

192.168.xxx.xxx/api/YOURUSERNAMEHERE/lights

I don't know what steps you might need to take on the hue itself to enable this functionality.  If this works it would be much much better than trying to do it through a (pseudo) command line interface.
« Last Edit: March 11, 2014, 09:28:42 PM by jitterjames »

Casmo

  • $upporter
  • Contributor
  • *****
  • Posts: 85
  • Karma: 0
    • View Profile
Re: Any Philips Hue users here?
« Reply #10 on: March 12, 2014, 08:01:37 AM »
Excellent, thanks a lot for the imput guys. Really appreciate it.

I wasnt even aware of that API. If it works as described, thats definately the way to go. I'll do some experimenting tonight and let you know.

Thanks again

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Any Philips Hue users here?
« Reply #11 on: March 12, 2014, 08:37:41 AM »
For starters, just try to get the "get" api methods working with the "Scrape" action in VC, or in your web browser.

The "put" and "post" methods probably won't work.  I will be adding Scrape.Put and Scrape.Post actions to the next VC2 release.

Casmo

  • $upporter
  • Contributor
  • *****
  • Posts: 85
  • Karma: 0
    • View Profile
Re: Any Philips Hue users here?
« Reply #12 on: March 12, 2014, 01:35:06 PM »
Am i right in thinking that scape is only required to return the output of the command i.e. if I send a comaand to turn on light 1, VC can then TTS "light 1 turned on"?


Also, what kind of vc action do I need to use to call "ip address /api/<username>/lights/<id>/state" (e.g. 10.1.0.1/api/computer/light/1/on)?  If I use Launch.OpenURL, will that not open a webpage?

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Any Philips Hue users here?
« Reply #13 on: March 12, 2014, 02:01:51 PM »
I can't help but feel that you did not read my last post very carefully.

The scrape action performs an http get as if you entered an URL into your browser, and returns whatever the server returns.  You don't have to use what is returned though, if you don't want to.  Most servers (eg: VC, XMBC, iTach, Halx etc.) will allow you to perform actions using http get calls by passing data on an URL.  but HUE requires us to use PUT for some methods.

Quote
Also, what kind of vc action do I need to use to call "ip address /api/<username>/lights/<id>/state" (e.g. 10.1.0.1/api/computer/light/1/on)?  If I use Launch.OpenURL, will that not open a webpage?
That is a put method.  As I mentioned in my last post, you will need Scrape.Put which does not exist yet.  That is why I said:
Quote
The "put" and "post" methods probably won't work.  I will be adding Scrape.Put and Scrape.Post actions to the next VC2 release.

If you use Launch it will be the same as using scrape except that it will open a window and you won't get anything back in LastResult.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Any Philips Hue users here?
« Reply #14 on: March 12, 2014, 02:02:07 PM »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)