Scripting a dimmer control

Posted on
Wed Sep 11, 2013 1:07 pm
noefresh offline
Posts: 119
Joined: Sep 10, 2013

Scripting a dimmer control

I've trying to integrate a Lutron Radio RA2. Basically it will accept commands over telnet. So I've got an Applescript that connects to it via Terminal and then sends a dimmer device id and dimmer value from 0-100%. Works fine as a script.

Question is- how can I connect this to a slider UI pop-up/dimmer control in Indigo so that when I drag on the slider on a control page, whatever value it ends on will be a variable I can then pass onto my script. (I looked into making a plugin for this purpose but it's a little beyond my skillset.) Any suggestions greatly appreciated.

Thanks,
Noah

Posted on
Wed Sep 11, 2013 2:44 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Scripting a dimmer control

Unfortunately, you'll need to implement a Server Plugin to do that. The plugin would create dimmer devices in Indigo which would function exactly like any other dimmer device.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Sep 11, 2013 2:48 pm
noefresh offline
Posts: 119
Joined: Sep 10, 2013

Re: Scripting a dimmer control

jay (support) wrote:
Unfortunately, you'll need to implement a Server Plugin to do that. The plugin would create dimmer devices in Indigo which would function exactly like any other dimmer device.


Thanks for the reply, Jay. Ok I can learn. Just to understand- so you're saying I could conceivably make a plugin which would be able to send telnet login/commands based in dimmer slider input in Indigo?

Posted on
Wed Sep 11, 2013 3:31 pm
durosity offline
User avatar
Posts: 4320
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: Scripting a dimmer control

In case it’s of any use someone did create a Lutron RA plugin a while back which is available on this thread: viewtopic.php?f=11&t=8378&p=59562&hilit=Lutron+RA#p59562 I’m not sure how different that is from the RA2 but if it’s not massively different perhaps you could collaborate with the original author to upgrade their existing one?

Computer says no.

Posted on
Wed Sep 11, 2013 3:47 pm
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: Scripting a dimmer control

Another possibility (one that's a lot more "hackish") might be to create a generic X10 dimmer device in Indigo then create a device brightness change trigger whose action is to execute a shell command using the brightness value of the X10 device. This would require that 1) you have an X10 interface such as the 2413U PowerLinc Modem (the main INSTEON one supported by Indigo), and 2) you don't have a lot of X10 devices already on your network (so that you'll have a free X10 house code and device number).

An example AppleScript you could embed in that trigger action would be

Code: Select all
set theBrightness to brightness of device "My X10 Dummy Dimmer"
do shell script "<shell command with any flags needed to set brightness>" & theBrightness

Response time wouldn't be as quick as a plugin and you wouldn't be able to query the Lutron for current brightness, but it would allow you to use a dimmer control in Indigo Touch to set the brightness.

Posted on
Thu Sep 12, 2013 9:36 am
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Scripting a dimmer control

noefresh wrote:
Thanks for the reply, Jay. Ok I can learn. Just to understand- so you're saying I could conceivably make a plugin which would be able to send telnet login/commands based in dimmer slider input in Indigo?


Exactly. Check out the developer docs at the bottom of the documentation page for details. In fact, the server plugin API was created exactly for this purpose - to make it easy (and easier for us) to add new protocols and integrations - like Radio RA2. Users will interact with your dimmer, on/off, thermostats, etc., just like any of the built-in devices of those types.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Sep 14, 2013 3:45 am
noefresh offline
Posts: 119
Joined: Sep 10, 2013

Re: Scripting a dimmer control

nsheldon wrote:
Another possibility (one that's a lot more "hackish") might be to create a generic X10 dimmer device in Indigo then create a device brightness change trigger whose action is to execute a shell command using the brightness value of the X10 device. This would require that 1) you have an X10 interface such as the 2413U PowerLinc Modem (the main INSTEON one supported by Indigo), and 2) you don't have a lot of X10 devices already on your network (so that you'll have a free X10 house code and device number).


Thanks for the suggestion- that sounds a lot more like something I can personally accomplish. I will report my findings once I get something together. Appreciate the help folks!

EDIT- and here is the code for anyone reading this and looking for a similar very easy (though hackish) solution:

Code: Select all
--Choose Indigo Generic Device and also Lutron device.
set IndigoDevice to "Kitchen Light_L"
set LutronDevice to 5 --Kitchen

tell application "IndigoServer"
   set theBrightness to brightness of device IndigoDevice
end tell


--Set brightness level from Indigo X10 value
set LutronLevel to theBrightness


--Login to Lutron via Telnet
tell application "System Events"
   if "Terminal" is not in name of processes then launch application "Terminal"
   tell process "Terminal"
      set frontmost to true
      if (count windows) is 0 then
         tell application "Terminal"
            set newTab to do script -- create a new window with no initial command
            delay 0.1
            do script "telnet 10.0.1.201" in front window
            delay 0.1
            do script "USERNAME" in front window
            delay 0.1
            do script "USERPASSWORD" in front window
         end tell
      end if
   end tell
end tell


--Call Subroutine to set value
SetLutron(LutronDevice, LutronLevel)


--Close Terminal Window out
delay 2
tell application "Terminal"
   quit
end tell


--Subroutine to login to Lutron Radio RA2 and set device and level.
on SetLutron(device, level)
   tell application "Terminal"
      do script "#OUTPUT," & device & ",1," & level in front window
      --quit
   end tell
end SetLutron


I only changed the actual username and password- though these are listed right in the RadioRA2 installer's manual. Ping me directly if you're trying to do this and need help finding them.

The one thing I notice is that these devices are now marked in RED in the DEVICES list, even though they technically function as expected. Anything I could/should do to avoid this?

-Noah

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 20 guests