KPL Python Scripting

Posted on
Thu Jul 28, 2016 6:43 pm
Dlucas10 offline
Posts: 29
Joined: Jun 22, 2014

KPL Python Scripting

Hello!

I'm dabbing with Python, and I have it working well and the way I want for the most part. Oe thing that I would like, is to only run the python when a insteon command is NOT received from a KPL. Meaning, if I push the button on the KPL then I don't want it to run the python script.

Not sure how this might be accomplished :?:

Dave

Posted on
Thu Jul 28, 2016 6:55 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: KPL Python Scripting

From a logic point of view:
You need another "event" to decide if the python pgm should run
Or it continuously runs and the Insteon event will stop it.

So what do you want to actually do?


Sent from my iPhone using Tapatalk

Posted on
Thu Jul 28, 2016 7:01 pm
Dlucas10 offline
Posts: 29
Joined: Jun 22, 2014

Re: KPL Python Scripting

I have a fanlinc, and wrote pgm to update the KPL based on what state it's in. So, if I press a button I don't want it to run but if I use my phone to set the fan, then I want it to update the KPL. I was using triggers to do this, but it's easier to do python if I can figure this little thing out. :D

Posted on
Thu Jul 28, 2016 8:44 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: KPL Python Scripting

what does the KPL do? do you use it just for the LEDs?
if you press a button, what should happen: nothing?

if its is iPhone --> fanlinc, --> led, you could just do
iPhone --> fanfic
iPhone --> KPL LEDs
in one action group with 2 actions.

if I understand you correctly

Karl

Posted on
Thu Jul 28, 2016 9:00 pm
Dlucas10 offline
Posts: 29
Joined: Jun 22, 2014

Re: KPL Python Scripting

Thanks for helping me through this.

The way the KPL is setup right now is that when you press a button, it's linked to the fanlinc. So, if you press the "High" it's mapped to the high setting on the fanlinc. Works great.

Now, what I was trying to accomplish is if I use my iPhone, and i turn the fan on the corresponding LED is not updated and stays on the last setting. To illustrate how you did it'd be:

KPL (push button) -> fanlinc changes (Works perfect)
iPhone -> fanlinc ---- LEDs don't update.

I created a trigger that when the fanlinc changes it runs the python pgm. Again, works great... just don't want it to run when someone pushes a button on the KPL. It'd be great that in the trigger we could do a condition that excludes if a insteon command is received from the KPL.

Dave

Posted on
Thu Jul 28, 2016 9:02 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: KPL Python Scripting

Dlucas10 wrote:
I have a fanlinc, and wrote pgm to update the KPL based on what state it's in. So, if I press a button I don't want it to run but if I use my phone to set the fan, then I want it to update the KPL. I was using triggers to do this, but it's easier to do python if I can figure this little thing out. :D


I do something quite similar in my setup. I have a number of KPL's around the house and toggle their lit button state depending on other stuff that happens. In the case of this example I have other KPL's that need to have their buttons lit up or darkened based on what happened on another KPL or device.

While not identical to yours, my setup is like this;
  • I have a trigger that listens for ANY Insteon command from the device in question (i.e., your Fanlinc)
  • The action is a script to determine the status of that device and then turn on/off the KPL buttons as needed

So:
Screen Shot 2016-07-28 at 8.55.55 PM.png
Screen Shot 2016-07-28 at 8.55.55 PM.png (43.24 KiB) Viewed 1471 times


Does this (still in old Applescript, I've not gotten around to changing the stuff that works yet - tells you how long I've been running THIS trigger :)):
Code: Select all
if ((on state of device "Greatroom Sectional")) then
   send insteon group instnTurnOn using name "Master BR KPL LED 4"
else
   send insteon group instnTurnOff using name "Master BR KPL LED 4"
end if


It would be a simple matter to translate that into Python code. If this sounds like it's close to what you are trying to achieve I could probably fix it up for Python for you. Now this also required that I defined my KPL buttons properly in "Manage Insteon PowerLinc Links" under the Interfaces->Insteon menu:
Screen Shot 2016-07-28 at 9.01.38 PM.png
Screen Shot 2016-07-28 at 9.01.38 PM.png (43.13 KiB) Viewed 1471 times


But's that may not be as important now that Python has some built in functions to toggle KPL buttons.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests

cron