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

0 Members and 1 Guest are viewing this topic.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Any Philips Hue users here?
« Reply #15 on: March 12, 2014, 05:01:31 PM »
Without wishing to complicate matters, it seems like for now it should be possible to combine the two separate methods described above to control your Hue lights, assuming you do actually have that command line program working properly.

1. Use the scrape command to get status information about your lights.

So, if you were able to get the IP address etc. as per the instructions in the HUE REST API documentation, then you could get information about whether or not lights are on or off -- anything that is listed as a "get" command. If you have the ID numbers for your lights and know the proper URL, you can try the following to get feedback about whether a specific light is on or off:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="266" name="Get status of light {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="{1} = id number for the light. (Later you can make a payload xml file that associates ID numbers with friendly names, so that instead of saying the number of the light, you can say &quot;bedroom light&quot; or whatever.)&#xD;&#xA;&#xD;&#xA;The first &amp; second OSD.ShowText actions can be deleted. I've put them here just to show you what information is being returned. If you want to see the complete information that is being scraped from a given URL, change the 1st OSD.ShowText from 0 to 1. It should look like the documentation that they include on the Hue website (http://developers.meethue.com/1_lightsapi.html).">
  <action>
    <cmdType>Scrape</cmdType>
    <cmdString>http://&lt;bridge ip address&gt;/api/&lt;username&gt;/lights/{1}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <cmdString>{LastResult}</cmdString>
    <cmdRepeat>0</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <cmdString>"on": (.*?),</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <cmdString>The results scraped from this URL say that "on" is "{Match.1}". Therefore:</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>{Match.1}&amp;&amp;true</ifParams>
    <then>
      <action>
        <cmdType>OSD.AddText</cmdType>
        <cmdString>Light {1} is on.</cmdString>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>TTS.SpeakSync</cmdType>
        <cmdString>Light {1} is on.</cmdString>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>OSD.AddText</cmdType>
        <cmdString>Light {1} is off.</cmdString>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>TTS.SpeakSync</cmdType>
        <cmdString>Light {1} is off.</cmdString>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <phrase>Get status of light</phrase>
  <payloadRange>1,10</payloadRange>
</command>

2. Use your command line utility to try to change the state of your lights, as per the examples we provided earlier in the thread using the batch file etc.

Those commands assume that you have already successfully used the command line interface thingee (without VC) to change the state of your lights. If that isn't working, then obviously adding VC to the mix is not going to help.

There are no guarantees, but in theory these solutions should work. That is the extent of the information or assistance that we can provide, since we don't have the hardware.  :bonk  It's all hypothetical, based on the documentation that those sites have posted.

No doubt some experimentation, problem solving, and learning will be involved on your end. Hopefully you'll eventually have some fun results to share with other Hue owners here on the forum!
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)

Casmo

  • $upporter
  • Contributor
  • *****
  • Posts: 85
  • Karma: 0
    • View Profile
Re: Any Philips Hue users here?
« Reply #16 on: March 13, 2014, 07:07:55 AM »
Hi All,

 Quick update. I had another look at using .bat files with the Hue-cli interace and its working perfectly. "all light on" " all lights red" etc. working flawlessly. I didnt have a lot of time so I need to create some more bat files for individual lights, scenes etc but im very happy with the results so far.
The downside is needing to create a new action and file for each light /colour combination rather than using payloads which would be a lot cleaner. I will have another look at the official api when I get some time.
In reality though, I only need maybe 6-10 commands to cover the most used functions.

Really cool stuff.

*now what will I get voxcommando to do next*


Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Any Philips Hue users here?
« Reply #17 on: March 13, 2014, 07:14:29 AM »
Hi Casmo, can you please post a example of a .bat file. Thanks

Looks like the content of the bat file in this way?

hue %1 %2 %3 %4 %5 %6
« Last Edit: March 13, 2014, 07:18:42 AM by Kalle »
***********  get excited and make things  **********

Casmo

  • $upporter
  • Contributor
  • *****
  • Posts: 85
  • Karma: 0
    • View Profile
Re: Any Philips Hue users here?
« Reply #18 on: March 13, 2014, 07:45:00 AM »
Sure. So, turn on kitchen light is;

hue lights 2 on

All off is;

hue lights all off

A "sci fi" scheme

hue lights 2 blue
hue lights 1 mediumturquoise
hue lights 3 dodgerblue   

etc etc. Simple as that. Ive saved the .bats to vc folder so its the action is just OpenBat all off.bat etc.

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Any Philips Hue users here?
« Reply #19 on: March 13, 2014, 08:35:00 AM »
Yeah, that is it  ;D
So I can show you a way, in which you need only one batch file for all your commands and this batch is created automatically by VoxCommando.  ;)

Give me some minutes to create a "Test" group for you and let us know if it works.
« Last Edit: March 13, 2014, 08:39:49 AM by Kalle »
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Any Philips Hue users here?
« Reply #20 on: March 13, 2014, 09:16:36 AM »
Nime5ter already gave you a sample showing you how to to all commands with payloads all with a single batch file.  ::club

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Any Philips Hue users here?
« Reply #21 on: March 13, 2014, 09:19:43 AM »
OK, here we go: This commands create the "huetest.bat" with the value for your Hue in VC Mainfolder and execute it. The file will be overwritten for every new command  ;)
1. Save the hueID.xml, huecolor.xml and hueScene.xml in the VC payload folder.
2. Drag and drop the followed code to your VC command tree.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<commandGroup open="True" name="hue test" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="690" name="change hue colours" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>File.Write</cmdType>
      <cmdString>{Path.VC}\huetest.bat&amp;&amp;{1} {2}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Launch.OpenBat</cmdType>
      <cmdString>{Path.VC}\huetest.bat</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <cmdString>I have set the {1} to colour {2}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>switch, put, turn</phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\hueID.xml</payloadFromXML>
    <phrase optional="true">to</phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\huecolor.xml</payloadFromXML>
  </command>
  <command id="691" name="hue scenes" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>File.Write</cmdType>
      <cmdString>{Path.VC}\huetest.bat&amp;&amp;{1}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Launch.OpenBat</cmdType>
      <cmdString>{Path.VC}\huetest.bat</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <cmdString>I have set the hue to {PF.1} scheme</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>hue scheme</phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\hueScene.xml</payloadFromXML>
  </command>
</commandGroup>

Have fun!
***********  get excited and make things  **********

Casmo

  • $upporter
  • Contributor
  • *****
  • Posts: 85
  • Karma: 0
    • View Profile
Re: Any Philips Hue users here?
« Reply #22 on: March 13, 2014, 09:40:37 AM »
Excellent, I look forward to trying this later.

Many thanks All

Casmo

  • $upporter
  • Contributor
  • *****
  • Posts: 85
  • Karma: 0
    • View Profile
Re: Any Philips Hue users here?
« Reply #23 on: March 13, 2014, 10:04:59 AM »
Oh just one other thing. I created .bats for lights up/down

hue lights all +20   

hue lights all -20

The 20 of course is another variable.

How would i best incorporate this into the script/xmls?

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Any Philips Hue users here?
« Reply #24 on: March 13, 2014, 10:21:13 AM »
sigh.

You only need one batch file, and you don't need to do anything fancy with generating new batch files etc.

Everything you need is here: http://voxcommando.com/forum/index.php?topic=1436.msg12519#msg12519

just read it.

Using this simple method you can do lights up with this command, and you don't need any more batch files.  Just the one.
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="292" name="lights up" 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>test.bat&amp;&amp;lights all +20   </cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>lights up</phrase>
</command>
« Last Edit: March 13, 2014, 10:26:55 AM by jitterjames »

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Any Philips Hue users here?
« Reply #25 on: March 13, 2014, 10:24:55 AM »
Yes, James is right, I have tested nime5ter's command group and it works also perfect!
You can use both ways! I think nime5ster's is easier to understand.

If you still want to do it my way you can use the following:

Drag and drop this command in the "hue test group" - so you can say: "dim {hueID} {down/up} to {X} percent. The curly brackets represent the payloads - to and percent is marked as optional phrases.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="704" name="dim Hue" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>File.Write</cmdType>
    <cmdString>{Path.VC}\huetest.bat&amp;&amp;{1} {3}{2}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Launch.OpenBat</cmdType>
    <cmdString>{Path.VC}\huetest.bat</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.Speak</cmdType>
    <cmdString>I have dim {1} to {2} percent</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>dim</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\hueID.xml</payloadFromXML>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\huecolor.xml</payloadFromXML>
  <phrase optional="true">to</phrase>
  <payloadRange>1,100</payloadRange>
  <phrase optional="true">percent</phrase>
</command>
« Last Edit: March 13, 2014, 11:00:30 AM by jitterjames »
***********  get excited and make things  **********

Casmo

  • $upporter
  • Contributor
  • *****
  • Posts: 85
  • Karma: 0
    • View Profile
Re: Any Philips Hue users here?
« Reply #26 on: March 13, 2014, 12:09:28 PM »
Thanks a lot folks.


To clarify James, I understand that only one batch file is required. I was referring to how I was doing lights up/down previously and how to achieve this in the xml script.
Im honeslty not trying to test your patience, im genuinely trying to understand this stuff as a total novice..

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Any Philips Hue users here?
« Reply #27 on: March 13, 2014, 12:42:55 PM »
I think at this point, rather than trying to figure out every command for the Hue, what's missing is an understanding of how VC works.

So, what might make the most sense is to take the first 2 commands that were provided as examples and just explore those: poke around. Try to understand the elements.

By dissecting those two initial commands within VoxCommando's command tree and the Logical Command Builder (the macro editor), you are more likely to have the tools you need to create all the other commands that you're now trying to build. If we keep posting more and more xml, I think it will only confuse matters.

Break those two commands and then fix them. Turn off the individual actions within a command and turn them back on, etc. Figure out how the command "sentence structure" is composed, develop more of an understanding of what payloads are and the different options you have for those.

I think at this point we are all only confusing matters by posting more and more examples and options of how things can be done.
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 #28 on: March 13, 2014, 12:59:21 PM »
In case you haven't seen this yet: http://voxcommando.com/mediawiki/index.php?title=Payloads

There are some video tutorials regarding building commands and payloads and the like as well.

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)

Casmo

  • $upporter
  • Contributor
  • *****
  • Posts: 85
  • Karma: 0
    • View Profile
Re: Any Philips Hue users here?
« Reply #29 on: March 15, 2014, 11:03:03 AM »
Hi,

 So the change color command as post by kalle is working perfectly,very impressive.
On the change scene one, its appears to be only changing the first light e.g. light 3 below

hue lights 2 blue{CR}hue lights 1 mediumturquoise{CR}hue lights 3 dodgerblue

I've checked that the below work in a bat file so im not sure what the problem is with the above

hue lights 2 blue
hue lights 1 mediumturquoise
hue lights 3 dodgerblue

The dim command doesnt appear to be working correctly either. I've been working through how the commands
are built, on this one im not sure why the huecolors xml is being called. When executed the TTS is saying for example "kitchen light dimmed by blue %" (though it doesnt actually dim)