Author Topic: Philips Hue Christmas Music Effects  (Read 4099 times)

0 Members and 1 Guest are viewing this topic.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Philips Hue Christmas Music Effects
« on: December 18, 2014, 02:08:38 PM »
I've been playing with our Philips Hue lights for the holidays. This is a variation on some commands I shared a while back, in which the lights changed colour to match song data.

In my Christmas command sequence, I have the Hue lights changing to red, green, and white/silver when a Christmas song plays in MediaMonkey.

It does this by first creating a new Hue scene called VC01 (storing the previous state first).  The same command loads the python script. This happens when VC is first launched.

When a new song starts playing, I grab the song title, artist, album name, and genre and pass that to my Python script. The script evaluates whether any of the data contains one of my Xmas keywords. If so, it triggers my Xmas light scene.

Then, every 30 seconds, as long as the Xmas song keeps playing, VC will rotate the sequence of lights left (Hue.RotateLeft).

If a non-Xmas song plays, it will restore my Philips Hue lights to their original, pre-Xmas scene state.

I think this could be done with XBMC or other media players as well. If anyone is interested in adapting this for those programs and would like some feedback or advice, let me know. I'd be happy to help figure it out with you.

UPDATE: See post later in this thread for a better version -- which does *not* need the Python plugin but does the same thing.

This command group contains 5 commands. You'll need to put the attached python script in the \PY folder of your VC directory as well.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.2.8-->
<commandGroup open="True" name="XMAS music effects" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="292" name="++Colour trigger" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="Passes song title, artist name, album name, and genre of current song to Python script. Stores the current Hue state first.">
      <action>
      <cmdType>MM.currentsongdata</cmdType>
      <params>
        <param>Genre</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>PY.ExecString</cmdType>
      <params>
        <param>hueXmas("{1}","{2}","{3}","{LastResult}")</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>MM.Playing</event>
  </command>
  <command id="265" name="Load python, create Xmas light scene" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="Create Xmas Scene using 3 Hue lights. Load python script.">
    <action>
      <cmdType>Hue.Store</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Hue.Light</cmdType>
      <params>
        <param>1</param>
        <param>"on":true, "hue":65535 ,"bri":254 ,"sat":254</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Hue.Light</cmdType>
      <params>
        <param>2</param>
        <param>"on":true, "hue":24637 ,"bri":88 ,"sat":254</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Hue.Light</cmdType>
      <params>
        <param>3</param>
        <param>"on":true, "sat":80, "hue":37500</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Hue.Scene.Create</cmdType>
      <params>
        <param>VC01</param>
        <param>VC01</param>
        <param>1,2,3</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Hue.Restore</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>PY.ExecFile</cmdType>
      <params>
        <param>PY\hueXmas.py</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>VC.Loaded</event>
  </command>
  <command id="246" name="++Switch on Xmas light scene" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Hue.Scene.Load</cmdType>
      <params>
        <param>VC01</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.SetEventTimer</cmdType>
      <params>
        <param>30s</param>
        <param>rotateLights</param>
        <param>{var.nowPlaying}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>Hue.XmasLights</event>
  </command>
  <command id="248" name="Rotate lights" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>MM.currentsongdata</cmdType>
      <params>
        <param>Title</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{LastResult}&amp;&amp;{var.nowPlaying}</ifParams>
      <then>
        <action>
          <cmdType>Hue.RotateLeft</cmdType>
          <params>
            <param>1,2,3</param>
            <param>10</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.SetEventTimer</cmdType>
          <params>
            <param>30s</param>
            <param>rotateLights</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
    <event>rotateLights</event>
  </command>
  <command id="262" name="Restore previous light settings" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Hue.Restore</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>nowPlaying</param>
        <param>null</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>MM.TrackEnd</event>
    <event>MM.Stopped</event>
  </command>
</commandGroup>


Of course, you can choose your own light colours, song keywords, and how often the lights rotate. The colours are set in the command "Load python, create Xmas light scene". The keywords are defined in the Python script. The light rotation timing is determined by the VC.SetEventTimer actions, which occur in 2 different commands.

Enjoy!
« Last Edit: January 14, 2016, 02:46:37 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: Philips Hue Christmas Music Effects
« Reply #1 on: December 18, 2014, 02:39:25 PM »
Also, if anyone has suggestions of other fun holiday stuff we might want to try -- not necessarily Philips Hue related -- I'm up for a challenge!

... Well, I am until I hear what it is, anyway.  :biglaugh
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: Philips Hue Christmas Music Effects
« Reply #2 on: December 18, 2014, 04:17:04 PM »
OK, I just discovered a dumb bug in the original command group. That's now fixed in the first post.
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)

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Philips Hue Christmas Music Effects
« Reply #3 on: December 19, 2014, 05:13:19 AM »
Wow, really great idea!  ::bow 
***********  get excited and make things  **********

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Philips Hue Christmas Music Effects
« Reply #4 on: December 19, 2014, 01:42:21 PM »
Thanks Kalle.

I don't know if you have any Christmas music in your repertoire (or if you use MediaMonkey?), but you should be able to use this Python script with your Ambilights with a few adaptations in the VC commands.




« Last Edit: December 19, 2014, 04:01:39 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)

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Philips Hue Christmas Music Effects
« Reply #5 on: December 19, 2014, 04:23:37 PM »
Yes, I have a lot of them  :-[


I will give it a try, thanks for the hint.
***********  get excited and make things  **********

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Philips Hue Christmas Music Effects
« Reply #6 on: December 03, 2015, 08:12:58 PM »
For those of the Christmas persuasion -- or if you just like messin' about with various plugins and are looking for an excuse (that's me!) -- here is an updated, cleaner version of the Philips Hue Christmas Music Effects command group that does *not* use any Python. It's pure VC power, baby.

If you have any questions, suggestions, complaints -- let's hear 'em.

If you have different automated coloured lights systems other than the Hue lights, please consider creating and sharing your own fancy holiday commands. :)

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.0.9-->
<commandGroup open="True" name="XMAS music effects (no Python)" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="279" name="1. Create Xmas light scene (run this once only)" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="Creates a Xmas Scene using 3 Hue lights. You can choose your own colours and number of lights.">
    <action>
      <cmdType>Hue.Store</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Hue.Light</cmdType>
      <params>
        <param>1</param>
        <param>"on":true, "hue":65535 ,"bri":254 ,"sat":254</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Hue.Light</cmdType>
      <params>
        <param>2</param>
        <param>"on":true, "hue":24637 ,"bri":88 ,"sat":254</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Hue.Light</cmdType>
      <params>
        <param>3</param>
        <param>"on":true, "sat":80, "hue":37500</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Hue.Scene.Create</cmdType>
      <params>
        <param>VC01</param>
        <param>VC01</param>
        <param>1,2,3</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Hue.Restore</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
  </command>
  <command id="248" name="Rotate lights" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>MM.currentsongdata</cmdType>
      <params>
        <param>Title</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{LastResult}&amp;&amp;{var.nowPlaying}</ifParams>
      <then>
        <action>
          <cmdType>Hue.RotateLeft</cmdType>
          <params>
            <param>1,2,3</param>
            <param>10</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.SetEventTimer</cmdType>
          <params>
            <param>30s</param>
            <param>rotateLights</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
    <event>rotateLights</event>
  </command>
  <command id="308" name="Colour trigger" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>VC.StopEventTimer</cmdType>
      <params>
        <param>rotateLights</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>nowPlaying</param>
        <param>null</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>MM.CurrentSongData</cmdType>
      <params>
        <param>Genre</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetLastResult</cmdType>
      <params>
        <param>{1} {2} {3} {LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>(Christmas|Elves|Snow|Winter|Holiday|Magi|Sleigh|Gift|Evergreen|Tannenbaum|Tree|Stocking|Reindeer|Navidad|Santa)</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>LastActionSuccess</ifType>
      <ifParams>&amp;&amp;</ifParams>
      <then>
        <action>
          <cmdType>Hue.Scene.Load</cmdType>
          <params>
            <param>VC01</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>nowPlaying</param>
            <param>{1}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.SetEventTimer</cmdType>
          <params>
            <param>30s</param>
            <param>rotateLights</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>Hue.Restore</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <event>MM.Playing</event>
  </command>
  <command id="339" name="Store initial Hue state" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Hue.Store</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>VC.Loaded</event>
  </command>
</commandGroup>

As with the original version, this is using MediaMonkey events and actions to get info about what song is playing. It should not take much to adapt it to use Kodi events instead, if that's your preferred poison.

And I think the iTunes plugin generates events that can be used similarly. Not sure about all the other music player options, sorry.

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)