How to code complex triggers?

Posted on
Fri Oct 09, 2015 7:17 am
RageDoctor offline
Posts: 72
Joined: Oct 03, 2015
Location: Wiesbaden, Germany

How to code complex triggers?

Hey Folks,

I am just playing around with Indigo. As I have gained some experience in how to trigger events I am going increrasingly into depth.

How can I code/program with Python complex triggers and not just conditions?

Here is the point:

In case I would like to controll 15 roller shutter depending on many varriables (e.g., time, temperature, luminous intensity) including many exceptions/shutter (e.g., do not close shutter 3 when the door at shutter 3 is open, but close all other shutters etc.), isn't it easier to code this instead of triggering every single shutter with the trigger function in Indigo?

Any ideas? Would be much apreciated :)

Regards,
Marcus

Every beginning is hard...
Software: Indigo 6.1.4
Controller: Z-Stick Gen 5
Devices: Fibaro Wall Plug, Motion Sensor and Door/Window Sensor, Aeon Labs MultiSensor 6, more to come...

Posted on
Fri Oct 09, 2015 8:00 am
FlyingDiver offline
User avatar
Posts: 7247
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: How to code complex triggers?

It could very well be easier to put that in a Python script rather than explicit conditions. Depends on how comfortable you are with Python programming. In any case, you're going to need a trigger for every external event that you want to effect the shutters. Like time of day, keypad button press, etc. Then you could write a script for that trigger that has all the logic in it rather than use the Indigo built in conditions and actions. Trying to share the logic code across multiple triggers might be tricky, I've never tried to do anything like that.

So, the short answer to your question is that you create a trigger, don't use any conditions, and do it all in your Python script. Here's the intro to scripting in Indigo:

http://wiki.indigodomo.com/doku.php?id= ... g_tutorial

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

Posted on
Sat Oct 10, 2015 3:29 am
RageDoctor offline
Posts: 72
Joined: Oct 03, 2015
Location: Wiesbaden, Germany

Re: How to code complex triggers?

Thanks FlyingDiver! So, doing it in Python can also address actions/devices? How do I reference to a Python script file? Also under conditions?

Every beginning is hard...
Software: Indigo 6.1.4
Controller: Z-Stick Gen 5
Devices: Fibaro Wall Plug, Motion Sensor and Door/Window Sensor, Aeon Labs MultiSensor 6, more to come...

Posted on
Sat Oct 10, 2015 4:50 am
DaveL17 offline
User avatar
Posts: 6781
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: How to code complex triggers?

Hi Marcus - you can run scripts within Indigo in (basically) one of two ways. Both are found on the Actions tab of a Trigger or Schedule, and under Type for Actions. Look for: Server Actions ---> Script and File Actions ---> Execute Script. The scripts can be Python or Apple Script; for various reasons that we don't need to get into right now, Python is the preferred approach.

Approach 1: Run an "embedded script". What this means is, typing the script directly into the code window of the Script Action Type.
Approach 2: Save the script into a plain text file and then link to it from the Indigo UI.

See the attached image for a very simple example. (Bear in mind that in my example, the script is where all of the logic would happen. The Trigger is what causes the script to be executed. I.e., "If t becomes dark, run this script.")

Python scripting is an incredibly powerful tool.
Dave
Attachments
Screen Shot 2015-10-10 at 5.46.22 AM.png
Screen Shot 2015-10-10 at 5.46.22 AM.png (103.41 KiB) Viewed 2071 times

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Oct 10, 2015 6:13 am
RageDoctor offline
Posts: 72
Joined: Oct 03, 2015
Location: Wiesbaden, Germany

Re: How to code complex triggers?

Thanks for opening my eyes :D Will give it a try...

Every beginning is hard...
Software: Indigo 6.1.4
Controller: Z-Stick Gen 5
Devices: Fibaro Wall Plug, Motion Sensor and Door/Window Sensor, Aeon Labs MultiSensor 6, more to come...

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests