[ANSWERED]Stuck in a square circle

Posted on
Thu Apr 10, 2014 8:32 pm
jltnol offline
Posts: 997
Joined: Oct 15, 2013

[ANSWERED]Stuck in a square circle

So I have 2 Action Groups, one for when I leave the house when it's daylight, and one for when I leave and it's dark. I trigger either one of these two groups depending on what time it is when I leave the house, but I'd like to combine these so that I just press one button, and then depending on the Condition of Daylight or Dark, the right Action Group activates.

But I can't really figure out how to make that happen. Conditions are only available in Triggers and Schedules. I could set up two Triggers, one for day and one for night, but don't see a way to activate both from a Trigger. I could set up a day schedule and night schedule, but likewise don't see a way to have a Trigger fire off a schedule.

Since only one set of Conditions apply to all Actions in both Triggers and Schedules, I'm stuck... I just can't figure out the logical steps to make this happen with the tools I have.


Any suggestions ??

Posted on
Fri Apr 11, 2014 8:08 am
Chompy offline
User avatar
Posts: 84
Joined: Sep 07, 2009
Location: Seattle, WA

Re: Stuck in a square circle

Perhaps placing an AppleScript like this within a trigger will help:

Code: Select all
tell application "IndigoServer"
   if value of variable "isDaylight" is "true" then
      execute group "Your Action Group Day"
   else
      execute group "Your Action Group Night"
   end if
end tell

Posted on
Fri Apr 11, 2014 11:08 am
jay (support) offline
Site Admin
User avatar
Posts: 18255
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Stuck in a square circle

There are quite a few different ways to approach this. The script is a good choice. Another non-script option is to create two triggers which fire when the button is pressed - one with each condition (If dark and If daylight) which executes the appropriate action group. So when you press the button both triggers fire, but only the right set of actions get executed.

By the way, here's the Python version of the script for completeness:

Code: Select all
if indigo.variables["isDaylight"].value == "true":
    indigo.actionGroup.execute(DAYLIGHTACTIONGROUPID)
else:
    indigo.actionGroup.execute(DARKACTIONGROUPID)


You'll want to use the IDs of the action groups so if you rename them the script will continue to work.

Before anyone jumps in here, I usually encourage people to use the ID of the object rather than the name - but in the case of the isDaylight variable, it's a readonly variable that's always there (the server creates and maintains it) and it's unlikely we'll ever change the name of it (famous last words).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Apr 11, 2014 10:09 pm
jltnol offline
Posts: 997
Joined: Oct 15, 2013

Re: Stuck in a square circle

Thanks for the tips..... I'm just now realizing that the one button - two trigger option is possible... this is an 8 button Keypad... and I'm not sure why I never thought of this before... I guess I was stuck on one button-one trigger mentality, but can see now that it doesn't have to be that way.

I'm only know enough about Apple Script to get me in trouble, but when someone writes one for me, (thanks), it's hard not to plug it in, and mess around to get it to work, which looks like it should be a piece of cake.

Thanks to both ideas...

JT

Posted on
Sat Apr 12, 2014 1:15 am
BassMint offline
Posts: 105
Joined: Dec 24, 2013

Re: Stuck in a square circle

jay (support) wrote:
You'll want to use the IDs of the action groups so if you rename them the script will continue to work.



how do you that in applescript?

Posted on
Sat Apr 12, 2014 7:49 am
jay (support) offline
Site Admin
User avatar
Posts: 18255
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Stuck in a square circle

BassMint wrote:
how do you that in applescript?


You can't. AppleScript can't (and will never) use device IDs. Trust me - you wanna switch to Python.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Apr 12, 2014 2:34 pm
BassMint offline
Posts: 105
Joined: Dec 24, 2013

Re: Stuck in a square circle

jay (support) wrote:
BassMint wrote:
how do you that in applescript?


You can't. AppleScript can't (and will never) use device IDs. Trust me - you wanna switch to Python.


advice taken
learning to convert over to python.

can't get this to work embedded in Indigo

Code: Select all
import subprocess
theValues = subprocess.check_output('hwmonitor -f -tv', shell=True)


get
embedde script: 'module' object has no attribue 'check_output'

Posted on
Sat Apr 12, 2014 8:01 pm
BassMint offline
Posts: 105
Joined: Dec 24, 2013

Re: [ANSWERED]Stuck in a square circle

figured it out…

needed to use Popen for 2.5

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests

cron