[ANSWERED]: Keypad Dimmer button Led's Apple Script Commands

Posted on
Fri Dec 27, 2013 6:24 am
lindauer offline
Posts: 10
Joined: Jan 23, 2012

[ANSWERED]: Keypad Dimmer button Led's Apple Script Commands

I run a few Apple Scripts to check status and turn off/on lights. I am having trouble finding the commands for the Keypad Dimmers button leds, led 2 status request, led 2 on, led 2 off. How do I refferece the Keypad led's with Apple script?

Posted on
Fri Dec 27, 2013 11:56 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Keypad Dimmer button Led's Apple Script Commands

The LED states aren't available from AppleScript but are from Python:

Code: Select all
dev = indigo.devices[1037032239]    # My "Office KeypadLinc"

# Example that turns ON button #4's LED if it is currently OFF:
if not dev.ledStates[3]:
   indigo.relay.setLedState(dev, 3, True)

# Example that turns OFF button #4's LED if it is currently ON:
if dev.ledStates[4]:
   indigo.relay.setLedState(dev, 4, False)


Note the index is 0 based, so 0 is button 1, 1 is button 2, 2 is button 3, etc.

Image

Posted on
Sun Jun 29, 2014 6:36 pm
jltnol offline
Posts: 994
Joined: Oct 15, 2013

Re: Keypad Dimmer button Led's Apple Script Commands

I'm trying to do the opposite.... have AppleScript turn ON (or off) a KPL LED. Don't need the status monitored...

I'm guessing its' something like.... but don't see how to tell it to turn on a particular LED .....

Possible?

Code: Select all
tell application "IndigoServer"
   if value of variable "BedroomDenon" is "PWON" then
      turn on "Master Bedroom-Main Light"
   else
      turn off "Master Bedroom-Main Light"
   end if
end tell



OR a simply Python script to turn on a particular LED.....

Posted on
Sun Jun 29, 2014 8:33 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Keypad Dimmer button Led's Apple Script Commands

Turning the LEDS on/off isn't available from AppleScript, but the script I posted above shows how to do it in python (it shows both how to read the state as well as how to set an LED on/off). Or maybe I'm not understanding what you need?

Image

Posted on
Mon Jun 30, 2014 3:00 pm
jltnol offline
Posts: 994
Joined: Oct 15, 2013

Re: [ANSWERED]: Keypad Dimmer button Led's Apple Script Comm

Hey Matt


Kind of figured out about Applescript with subsequent reading.... I had looked at the script you've posted, but didn't see where/how to insert the variable "condition" so to speak.. ..and on top of that... there are 2 variable strings involved.... one which would turn the KPL on, and a different one that would turn it off..

Kind of like..

if variable xxx = XYZ, then turn on this KPL LED
if variable xxx = ABC, then turn off the KPL LED.

(easy logic, impossible for me to script)

I ended up with the same thing where a trigger looks for at the variable for the right string to turn it ON... and a 2nd trigger looks at the same variable for the right string to turn it OFF. This is the 'code' I used to turn it on, although obviously could have done that thru the GUI as well.

Code: Select all
indigo.dimmer.setLedState(675337121, index = 7, value = True)


(as a side note, is something this simple more efficient to do with Python as opposed to the GUI? or are they about the same...)

Because you guys have given Indigo such a rich feature set, I can almost always find a work around thru the GUI that works....

No doubt not as "pretty" as the right Python script would have been, but it got the job done... :D

Posted on
Thu Jul 17, 2014 11:04 am
jltnol offline
Posts: 994
Joined: Oct 15, 2013

Re: [ANSWERED]: Keypad Dimmer button Led's Apple Script Comm

Ok Matt

One more low key Python question...

I'm basically trying to converge 2 triggers into 1. Where one trigger works with a KPL ON, and one trigger with a KPL OFF, I was hoping to combine them into one Python script that looks for changes, and acts accordingly... I've got the Trigger set to "Has Any Change", but don't know how to get the script to look for a change in a particular LED...


I was using this line as the basis of how to insert the index part...

Code: Select all
indigo.dimmer.setLedState(220572655, index = 1, value = True)


but it doesn't work like this in the first line......This won't compile, but is there a way to do this in python ?

Code: Select all
if (indigo.devices[1353496914, index = 2].onState == True): # Test "myNewDevice" state...

      indigo.insteon.sendSceneOn(51)
else:
        indigo.insteon.sendSceneOff(51)

Posted on
Fri Jul 18, 2014 9:06 am
jay (support) offline
Site Admin
User avatar
Posts: 18224
Joined: Mar 19, 2008
Location: Austin, Texas

Re: [ANSWERED]: Keypad Dimmer button Led's Apple Script Comm

There are a couple of ways to check the state of a KeypadLinc LED. First, you can check the dev.ledStates property:

Code: Select all
dev = indigo.devices[1435361545] # "KeypadLinc"
if dev.ledStates[2]:
    # button 3 is on - the ledStates array is a Python array which is 0-based


The other option is to look directly at the LED states:

Code: Select all
dev = indigo.devices[1435361545] # "KeypadLinc"
if dev.states["keypadButtonLed3"]:
    # button 3 is on

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Jul 20, 2014 5:01 pm
jltnol offline
Posts: 994
Joined: Oct 15, 2013

Re: [ANSWERED]: Keypad Dimmer button Led's Apple Script Comm

These little pieces of code are very helpful.... at least for me...

THANKS

Posted on
Thu Jul 31, 2014 8:56 pm
jltnol offline
Posts: 994
Joined: Oct 15, 2013

Re: [ANSWERED]: Keypad Dimmer button Led's Apple Script Comm

Ok folks... while I did have a small problem with Jay's solution, it got me on the road, and pointed in the right direction.

For anyone else who needs this little snippet of Python, here it is.

The number in brackets is the KPL in question, and the number in parenthesis is the particular LED you'd like to check... and as always, they are numbered 0-7 in Python, not 1-8

Elementary stuff for sure, but someone may need just this much one day!

Code: Select all
dev = indigo.devices[1353496914] # "KeypadLinc"
if (dev.ledStates[3] == True):
    # button 3 is on - the ledStates array is a Python array which is 0-based
      indigo.insteon.sendSceneOn(51)
else:
      indigo.insteon.sendSceneOff(51)

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 24 guests