Need code samples

Posted on
Mon Jun 05, 2017 3:31 pm
CraigM offline
Posts: 534
Joined: Oct 28, 2007

Need code samples

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 ==

Posted on
Mon Jun 05, 2017 3:48 pm
jay (support) offline
Site Admin
User avatar
Posts: 15866
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Need code samples

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

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Jun 05, 2017 4:01 pm
CraigM offline
Posts: 534
Joined: Oct 28, 2007

Re: Need code samples

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 [ ] ( )

Posted on
Mon Jun 05, 2017 4:09 pm
jay (support) offline
Site Admin
User avatar
Posts: 15866
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Need code samples

There are examples on the links provided.

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

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Jun 05, 2017 4:11 pm
CraigM offline
Posts: 534
Joined: Oct 28, 2007

Re: Need code samples

Got it, thanks again!

Posted on
Tue Jun 06, 2017 4:48 pm
CraigM offline
Posts: 534
Joined: Oct 28, 2007

Re: Need code samples

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?

Posted on
Tue Jun 06, 2017 6:35 pm
jay (support) offline
Site Admin
User avatar
Posts: 15866
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Need code samples

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.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest

cron