Page 1 of 1

Need code samples

PostPosted: Mon Jun 05, 2017 3:31 pm
by CraigM
Could someone please help me write some Python code from the following rough examples:

Code: Select all
if (indigo.variable[123456].value == home):
indigo.sendSceneOn(20)
else
indigo.sendSceneOff(20)


Code: Select all
if (indigo.variable[123456].value == home):
indigo.sendSceneOn(20)
else
if (indigo.variable[123456].value == away):
indigo.sendSceneOn(30)
else
if (indigo.variable[123456].value == vacation):
indigo.sendSceneOn(40)


Also, what is the proper wording to replace the above sendScene with:
- execute action group
- execute trigger

And, what is the proper wording to replace the above ON and OFF with:
- instant ON
- instant OFF

Should it read = or ==

Re: Need code samples

PostPosted: Mon Jun 05, 2017 3:48 pm
by jay (support)
Code: Select all
if indigo.variables[123456].value == "home":
    indigo.insteon.sendSceneOn(20)
else:
    indigo.insteon.sendSceneOff(20)


Code: Select all
if indigo.variables[123456].value == "home":
    indigo.insteon.sendSceneOn(20)
elif indigo.variables[123456].value == "away":
    indigo.insteon.sendSceneOn(30)
elif indigo.variables[123456].value == "vacation":
    indigo.insteon.sendSceneOn(40)


Indents are important in Python - they indicate blocks of code.

CraigM wrote:
Also, what is the proper wording to replace the above sendScene with:
- execute action group
- execute trigger


indigo.actionGroup.execute
indigo.trigger.execute

CraigM wrote:
And, what is the proper wording to replace the above ON and OFF with:
- instant ON
- instant OFF


indigo.insteon.sendSceneFastOn
indigo.insteon.sendSceneFastOff

Re: Need code samples

PostPosted: Mon Jun 05, 2017 4:01 pm
by CraigM
Thanks Jay,

I will assume your first example is missing a "

on the:
indigo.actionGroup.execute
indigo.trigger.execute

I assume they are followed by the ID in some sort of brackets [ ] ( )

Re: Need code samples

PostPosted: Mon Jun 05, 2017 4:09 pm
by jay (support)
There are examples on the links provided.

And, yes, missing quote which I'll fix.

Re: Need code samples

PostPosted: Mon Jun 05, 2017 4:11 pm
by CraigM
Got it, thanks again!

Re: Need code samples

PostPosted: Tue Jun 06, 2017 4:48 pm
by CraigM
What is the difference between:

indigo.variable[123456]
indigo.variables[123456]

indigo.actionGroup.execute[123456]
indigo.actionGroups.execute[123456]

indigo.trigger[123456]
indigo.triggers[123456]

Are both correct for different uses? Or is only one correct always?

Re: Need code samples

PostPosted: Tue Jun 06, 2017 6:35 pm
by jay (support)
Incorrect:

CraigM wrote:
indigo.variable[123456]
indigo.actionGroups.execute[123456]
indigo.trigger[123456]


Correct:

CraigM wrote:
indigo.variables[123456]
indigo.actionGroup.execute[123456]
indigo.triggers[123456]


You really need to read the Introduction section of the IOM docs - it explains the difference between the two name spaces. Briefly, the plural version (indigo.devices, etc) represents a dictionary of those types of objects which uses the ID as the key. The singular version (indigo.device) is the command namespace - so that's where all the commands that operate on those types reside.