Polling keypad LED status

Posted on
Thu Nov 21, 2019 11:57 pm
SMUSEBY offline
Posts: 511
Joined: Sep 16, 2009
Location: California

Polling keypad LED status

I would like to write a script with logic based on the status of a Lutron keypad LED.
After focusing on my Python skills as the source of the issue, I finally tested the system behavior with the following script:
Code: Select all
indigo.device.turnOn(1017239549) # turn on LED#1
led1 = indigo.devices[1017239549] # dRm kPdW LED#1
#LOG DEVICE STATUS
indigo.device.statusRequest(1017239549)
indigo.script.sleep(15)
if led1.onState:
   indigo.server.log("15 secs led1 is on")
else:
   indigo.server.log("15 secs led1 is off")


While the script turns on the LED, the value obtained in the event log is F.
What I learned was that changing the delay did not impact the result. What does impact the result is running the script a second time: while running the script a second time does not change the LED status, the value in the LOG is now T. I obtained the same result even when I commented out the sleep line.
Note: I also observed the same behavior with the status request following the sleep step.
Anyone else observe this? - any thoughts on how to deal with it?

Posted on
Fri Nov 22, 2019 3:31 am
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Polling keypad LED status

This isn’t specific to the Lutron plugin.

The status request call should not be necessary. But your call to get the led1 device needs to happen after the turn on request is completed. So putting a sleep call right after the turn on command should fix it. You’ll only need 2-3 seconds at most.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Fri Nov 22, 2019 10:28 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Polling keypad LED status

When you get a reference to an Indigo device:

Code: Select all
led1 = indigo.devices[1017239549] # dRm kPdW LED#1


you're getting a copy of the device (or any other Indigo object) as it stands at that instant (you really want to read the Introduction section of the IOM docs as this is probably the most important concept you need to know about Indigo objects). Any changes to the device on the server side won't automatically be reflected in the instance. You can, however, force the instance to update itself from it's current state on the server:

Code: Select all
led1.refreshFromServer()


So you'd want to do that directly after you sleep before using led1 in the conditional tests.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest