Indigo Control4 driver: change Indigo vars from director

Posted on
Thu May 30, 2013 12:46 am
CT1 offline
Posts: 22
Joined: Dec 27, 2012

Indigo Control4 driver: change Indigo vars from director

I don't know if there are any other people out there using Control4 with indigo, but here's a basic driver if you are. :)

I find the C4 automation to be totally superior to anything else for AV control, and Indigo to be superior for lighting (at about 1/3 the price). I wanted Indigo to know when the TV in a specific room is on, the source, if paused, etc. Here's a simple driver I wrote that allows this to work. It simply allows a control4 director (home controller) to change Indigo variables using IWS. It requires Control4 2.3+. It takes a little work, but you can do some cool stuff. Note, you must not have authentication on in IWS for this to work. Since I couldn't attach .c4i files or .zip files, here is the plaintext driver inline. Just save it to a .c4i file and load it in composer.

Code: Select all
<devicedata>
  <copyright>Copyright 2008 CT. All rights reserved.</copyright>
  <creator>CT</creator>
  <manufacturer>Perceptive Automation</manufacturer>
  <name>Set Indigo variables driver</name>
  <model>Indigo IWS</model>
  <created>01/04/2008 12:30 PM</created>
  <modified>05/27/2013 11:31 AM</modified>
  <version>1</version>
  <top>
  </top>
  <bottom>
  </bottom>
  <front>
  </front>
  <back>
  </back>
  <left>
  </left>
  <right>
  </right>
  <control>lua_gen</control>
  <controlmethod>other</controlmethod>
  <driver>DriverWorks</driver>
  <states />
  <combo>True</combo>
  <OnlineCategory>others</OnlineCategory>
  <proxies qty="1">
    <proxy>Indigo_IWS</proxy>
  </proxies>
  <config>
    <power_management_method>AlwaysOn</power_management_method>
    <power_command_delay>0</power_command_delay>
    <power_delay>0</power_delay>
    <power_command_needed>False</power_command_needed>
    <documentation>
Driver to set variables on Indigo IWS from C4 events \n\n

1) Add driver to project \n
2) Enter the IP Address and port of your IWS server \n
3) Enter the Indigo variable name you want to change\n
4) In composer programming, execute Set Indigo Variable from any event\n
5) In Set Indigo Variable, set the variable as needed.  (Note that you'll need to re-drag the command if you want to chagne the value).\n
6) When event fires, Indigo variable will be set from C4 director (via IWS)\n
/n
NOTES: \n
- You cannot have a password on your IWS server \n
- No invalid chars (spaces) in value \n
\n
Version 1 = Driver Release \n
TODO: \n
- User / pass \n
- don't send blank variables

</documentation>
    <script><![CDATA[--------------- Driver Functions --------------


-------------- Called by Director -------------

function ExecuteCommand(strCommand, tParams)
   
   if (strCommand == "Set Indigo Variables") then
   
      for ParamName, ParamValue in pairs(tParams) do
         GenerateURL ("Indigo Variable", ParamValue)
         print("Sending URL: " .. URL)
         C4:urlGet(URL)
      end
     end
 
   if strCommand == "LUA_ACTION" then
      
      if (tParams.ACTION == "GENERATE_URL") then
         GenerateURL("Indigo Variable", "TestValue")
         print("Sending URL: " .. URL)
         C4:urlGet(URL)
      end
   end
end

---------------- Utility -----------------

function GenerateURL (IndigoVarName, IndigoVarValue )
   URL = "http://" .. Properties["IWS IP Address"] .. ":" .. Properties["IWS Port"] .. "/variables/" ..Properties[IndigoVarName] .. "?_method=put&value=" .. IndigoVarValue
end



-------------- Init --------------

URL = ""

-------------- End Init ----------


-------------- Unused ------------

function ListParams()
   if (tParams ~= nil) then
      for ParamName, ParamValue in pairs(tParams) do
         print("Variables:" .. ParamName, ParamValue)
      end
   end
end]]></script>
    <actions>
      <action>
        <name>Generate Test URL</name>
        <command>GENERATE_URL</command>
      </action>
    </actions>
    <commands>
      <command>
        <name>Set Indigo Variables</name>
        <description>Set variables in indigo</description>
        <params>
          <param>
            <name>Variable 1</name>
            <type>STRING</type>
            <readonly>False</readonly>
            <default>
            </default>
          </param>
        </params>
      </command>
    </commands>
    <properties>
      <property>
        <name>IWS IP Address</name>
        <type>STRING</type>
        <readonly>False</readonly>
        <default>192.168.1.1</default>
      </property>
      <property>
        <name>IWS Port</name>
        <type>STRING</type>
        <readonly>False</readonly>
        <default>8176</default>
      </property>
      <property>
        <name>Indigo Variable</name>
        <type>STRING</type>
        <readonly>False</readonly>
        <default>C4RoomStatus</default>
      </property>
    </properties>
  </config>
</devicedata>


Let me know if there are any issues.

Next on my list is a virtual lightswitch driver for control4 that will allow you to instantiate lights in C4 that are actually controlled by Indigo. Getting C4 to know state when they are changed in indigo or locally is a little challenging, but I think it's possible.

Posted on
Thu May 30, 2013 9:22 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Indigo Control4 driver: change Indigo vars from director

Thanks for the contribution - it's nice to know that Indigo compares favorably for lighting control with the big guys.

If you want to contribute a zip file then you can submit it to the File Library - we try to focus user contributions there (where we have a chance to check out uploads before posting them to the general public).

Next on my list is a virtual lightswitch driver for control4 that will allow you to instantiate lights in C4 that are actually controlled by Indigo. Getting C4 to know state when they are changed in indigo or locally is a little challenging, but I think it's possible.


Is there some API that allows one to push information into C4? If so, you could write a server plugin that subscribes to device updates and then pushes those to C4 via their API. That's basically what the SQL Logger plugin does - subscribes to all object changes and writes those to a SQL database. Just a thought...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu May 30, 2013 9:54 pm
CT1 offline
Posts: 22
Joined: Dec 27, 2012

Re: Indigo Control4 driver: change Indigo vars from director

Thanks Jay.

The "programming" you can do in composer (the standard config tool) is drag and drop. It's pretty simple but powerful because of the complexity it hides. I can send a single C4 event (Office -> DirecTV) that turns on a a DirecTV box, Plasma and receiver, then correctly switches those + a KVM and a 4x4 HDMI matrix in the middle. I didn't specify any of that, I just told it what was connected to what and it figured out what to do. Then, when you pick up a remote or an iPad, it's already connected and ready to control the DirecTV box. Pretty amazing.

If you're writing a LUA driver, the full C4 API set is available and it is very robust. Deep to the point that you can hang a controller if you create a bunch of timers and don't destroy them. You can enumerate, subscribe to and control just about anything from a driver. But, AFAIK you cannot create / load other drivers from a driver. So to create a virtual light switch in C4, you'd need to install and configure a driver for each device.

Getting events from C4 -> Indigo is easy using IWS, just setup events to be fired in composer and the C4 driver hits a URL in IWS. There are several ways of getting events from Indigo -> C4 driver, some simple but will require programming triggers in Indigo, others harder that will do that control from a plug-in. Today I'm sending IR from Indigo to the C4 box to fire C4 events, but that will move to IP as soon as I get to it. I'll start with triggers in Indigo hitting URLs on a C4 box to fire C4 events and go up from there.

It wouldn't be that hard for a pro developer to create a C4 driver <-> Indigo plugin pair that is almost fully automatic, but I'm pretty sure that's beyond my abilities (and time available). I may try it, though.

Bottom line, C4 and Indigo make a really amazing pair. C4 does my AV and Indigo does everything else. And now they are talking to each other.

Posted on
Tue Apr 07, 2015 8:54 pm
Brendan offline
Posts: 20
Joined: Dec 02, 2013

Re: Indigo Control4 driver: change Indigo vars from director

I'm very interested in this subject, CT1! I just installed Control4 a few months ago. Overall, I like it a lot. But there are some things Indigo does a lot better and somethings Control4 *can't* do that Indigo can. The further I've gone down the Control4 path, the more I've realized I just need to tie the two systems together.

Have you made any more progress since this post two years back? If so, I'd love to chat about what you've been able to accomplish and where the pitfalls are.

Brendan

Posted on
Tue Apr 07, 2015 10:32 pm
CT1 offline
Posts: 22
Joined: Dec 27, 2012

Re: Indigo Control4 driver: change Indigo vars from director

Sorry, I did not. I abandoned it and went full in on Control4.

Best,

CT1

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests