Condition on Actions *in* Action Groups

Posted on
Fri Sep 18, 2020 6:23 am
vitaprimo offline
User avatar
Posts: 37
Joined: Jul 12, 2016
Location: La Paz, Baja California Sur. MX.

Condition on Actions *in* Action Groups

That's pretty much is. Can conditions such as first check X variable before going on be applied to individual actions in action groups?

Doing it with triggers adds way too many steps to the program and would need to split the sequence of events into way to many. Is there like a plugin for this maybe?

Thanks.

I'll bet you think this post is about you. Don't you. ♪

Posted on
Fri Sep 18, 2020 9:26 am
matt (support) offline
Site Admin
User avatar
Posts: 21416
Joined: Jan 27, 2003
Location: Texas

Re: Condition on Actions *in* Action Groups

Thanks for the feedback. This one was already on the feature request list. I don't know of a plugin that currently does this.

Image

Posted on
Fri Sep 18, 2020 2:37 pm
colin_d offline
Posts: 34
Joined: Nov 08, 2014
Location: East Sussex

Re: Condition on Actions *in* Action Groups

+1
I was thinking exactly the same last night.
Would open up a lot of possibilities.

Posted on
Wed Sep 23, 2020 7:05 am
vitaprimo offline
User avatar
Posts: 37
Joined: Jul 12, 2016
Location: La Paz, Baja California Sur. MX.

Re: Condition on Actions *in* Action Groups

Inspiration hit and I sort of worked around it rethinking a few things: I created monitors on variables so they become triggers so they become conditionable without adding too many steps and using the IF-THEN-ELSE plugin that does require an extra actionGroup per condition but it's better than nothing I suppose. I have one last action that requires twice the logic but although while the plugin has the option to specify several conditions, allegedly, in reality the minute I check another box the previous one gets deselected. A trial run didn't quite work either, so I might have to start over unless I find the problem. :(

I saw some posts of people complaining about Apple--this--Apple--that (pretty much Apple users' status quo nowadays) which made me think perhaps the plugins woks but not in the OS I'm using; Mojave. If everything fails, I'll try moving to High Sierra. I lost trust in Apple before long before I caved and I traded the fix of Spotlight's deep linking in Mojave for my integrity but I kept my suspicions at an all-time high rejecting updates and keeping the installers and NetI2nstall images of previous OSes. Oh well...

If I manage to do it I'll make sure to post it here because docu doesn't cover this. :x

I'll bet you think this post is about you. Don't you. ♪

Posted on
Fri Oct 02, 2020 6:10 am
vitaprimo offline
User avatar
Posts: 37
Joined: Jul 12, 2016
Location: La Paz, Baja California Sur. MX.

Re: Condition on Actions *in* Action Groups

I think I finished!

Now, keep in mind I don't know how to code, if it appears like I attempted to do it, I didn't, I simply chose a language to get the pretty colors in Visual Studio Code that helped me read more easily. :)
At some point I f**ked VSCode up by installing some extension and panicked bc I lost the pretty colors but I got them back. :) Visio was getting me nowhere, so putting it textual was way faster.

I tweaked it a little to make it more generic, paste on VSCode or other IDE and select Python--IT'S NOT!
Image


Code: Select all
#!/sheBangs/sheBangs♫ -o hBaby | when she && mv ./es♫
\ READ FORWARD, BUILD BACKWARDS (IN SECTION BOTTOM->TOP)

## VIRTUAL DEVICE DEF
def norte_aircon:
  virtualDevice "norte_aircon_vent"
    exec.off"actionGroup_norte_aircon_kickstart_on_vent"
    exec.on"actionGroup_norte_aircon_kickstart_on_kill"
    print.status"norte_aircon_on_vent"
  virtualDevice "norte_aircon_cool"
    exec.on"actionGroup_norte_aircon_kickstart_on_vent"
    exec.off"actionGroup_norte_aircon_kickstart_on_kill"
    print.status"norte_aircon_on_cool"

## KEYPAD/BUTTON CONTROL -- DEVICE-INITIATED TRIGGERS DEF
trigger ("if norte:kpad-bttn2 sends insteonON turnOFF aircon-norte")
  trig.type = insteon command received
  trig.from = device.keypadLincNorte
  trig.received = on.buttonGroup2
    eval:
      always:
        is: True
      exec 1:
        action1.delay: 00:00:00
        action1.type: exec actionGroup
        action1.group: actionGroup_norte_aircon_kickstart_on_kill
    else:
      exec 1:
        else.type: doNothing
trigger ("if norte:kpad-bttn4 sends insteonON turnON aircon-norte @vent")
  trig.type = insteon command received
  trig.from = device.keypadLincNorte
  trig.received = on.buttonGroup4
    eval:
      always:
        is: True
      exec 1:
        action1.delay: 00:00:00
        action1.type: exec actionGroup
        action1.group: actionGroup_norte_aircon_kickstart_on_vent
    else:
      exec 1:
        else.type: doNothing
trigger ("if norte:kpad-bttn6 sends insteonON turnON aircon-norte @cool")
  trig.type = insteon command received
  trig.from = device.keypadLincNorte
  trig.received = on.buttonGroup6
    eval:
      always:
        is: True
      exec 1:
        action1.delay: 00:00:00
        action1.type: exec actionGroup
        action1.group: actionGroup_norte_aircon_kickstart_on_cool
    else:
      exec 1:
        else.type: doNothing

## KICKSTARTERS DEF
def actionGroup_norte_aircon_kickstart_on_kill
  exec 1:
    action1.delay: 00:00:00
    action1.type: modify variable
    action1.variable: "norte_aircon_kickstart_on_kill"
    action1.value: +=1
def actionGroup_norte_aircon_kickstart_on_vent
  exec 1:
    action1.delay: 00:00:00
    action1.type: modify variable
    action1.variable: "norte_aircon_kickstart_on_vent"
    action1.value: +=1
def actionGroup_norte_aircon_kickstart_on_cool
  exec 1:
    action1.delay: 00:00:00
    action1.type: modify variable
    action1.variable: "norte_aircon_kickstart_on_cool"
    action1.value: +=1

## KICKSTARTED CONTROL -- CONDITION-MATCHED TRIGGERS
trigger ("norte_aircon_kickstart_on_kill detection")
  trig.type = variable changed
  trig.variable = norte_aircon_kickstart_on_kill
  trig.value = changes
    eval:
      always:
        is: True
      exec 1:
        action1.delay: 00:00:00
        action1.type: exec actionGroup
        action1.group: "actionGroup_norte_aircon_on_kill"
      exec 2:
        action2.delay: 00:00:01
        action2.type: enable schedule
        action2.disable: "norte_aircon_on_kill_runtime"
    else:
      exec 1:
        else.type: doNothing
trigger ("norte_aircon_kickstart_on_vent detection")
  trig.type = variable changed
  trig.variable = norte_aircon_kickstart_on_vent
  trig.value = changes
    eval:
      always:
        is: True
      exec 1:
        action1.delay: 00:00:00
        action1.type: exec actionGroup
        action1.group: "actionGroup_norte_aircon_on_vent"
      exec 2:
        action2.delay: 00:00:01
        action2.type: enable schedule
        action2.disable: "norte_aircon_on_vent_runtime"
    else:
      exec 1:
        else.type: doNothing
trigger ("norte_aircon_kickstart_on_cool detection")
  trig.type = variable changed
  trig.variable = norte_aircon_kickstart_on_cool
  trig.value = changes
    eval:
      if:
        cond1.type: systemVariable
        cond1.dark: True
      or:
        cond2.type: device
        cond2.device: "insteon wireless thermostat, non-climate controlled area"
        cond2.property: zone1temperature
        cond2.value: > 34
      or:
        cond3.type: variable
        cond3.variable: norte_aircon_enabled
        cond3.value: True
      or:
        cond4.type: variable
        cond4.variable: norte_aircon_enabled_override
        cond4.value: True
      exec 1:
        action1.delay: 00:00:00
        action1.type: exec actionGroup
        action1.group: "actionGroup_norte_aircon_on_cool"
      exec 2:
        action2.delay: 00:00:01
        action2.type: enable schedule
        action2.disable: "norte_aircon_on_cool_runtime"
      else: # not input anywhere, just for reference
        exec:
          else.type: doNothing

## L0 ACTIONGROUPS DEF
def actionGroup_norte_aircon_on_kill
  exec 1:
    action1.delay: 00:00:00
    action1.type: modify variable
    action1.variable: "norte_aircon_on_vent"
    action1.value: False
  exec 2:
    action2.delay: 00:00:01
    action2.type: modify variable
    action2.variable: "norte_aircon_on_cool"
    action2.value: False
  exec 3:
    action3.delay: 00:00:02
    action1.type: disable schedule
    action1.disable: "norte_aircon_on_vent_runtime"
  exec 4:
    action4.delay: 00:00:03
    action4.type: disable schedule
    action4.disable: "norte_aircon_on_cool_runtime"
  exec 5:
    action5.delay: 00:00:04
    action5.type: modify variable
    action5.variable: "norte_aircon_on"
    action5.value: False
  exec 6:
    action6.delay: 00:00:05
    action6.type: send device specific command (harmony hub actions)
    action6.device: "harmonyHub"
      harmonyHub.device: airconnorte
      harmonyHub.commandGroup: home
      harmonyHub.command: powerOFF
def actionGroup_norte_aircon_on_vent
  exec 1:
    action1.delay: 00:00:00
    action1.type: modify variable
    action1.variable: "norte_aircon_on_cool"
    action1.value: False
  exec 2:
    action2.delay: 00:00:01
    action2.type: disable schedule
    action2.disable: "norte_aircon_on_kill_runtime"
  exec 3:
    action3.delay: 00:00:02
    action3.type: disable schedule
    action3.disable: "norte_aircon_on_cool_runtime"
  exec 4:
    action4.delay: 00:00:03
    action4.type: exec actionGroup
    action4.group: "actionGroup_norte_aircon_on_L2"
  exec 5:
    action5.delay: 00:00:04
    action5.type: modify variable
    action5.variable: "norte_aircon_on_vent"
    action5.value: True
  exec 6:
    action6.delay: 00:00:06
    action6.type: send device specific command (harmony hub actions)
    action6.device: "harmonyHub"
      harmonyHub.device: airconnorte
      harmonyHub.commandGroup: miscellaneous
      harmonyHub.command: fanOnly
def actionGroup_norte_aircon_on_cool
  exec 1:
    action1.delay: 00:00:00
    action1.type: modify variable
    action1.variable: "norte_aircon_on_vent"
    action1.value: False
  exec 2:
    action2.delay: 00:00:01
    action2.type: disable schedule
    action2.disable: "norte_aircon_on_kill_runtime"
  exec 3:
    action3.delay: 00:00:02
    action3.type: disable schedule
    action3.disable: "norte_aircon_on_vent_runtime"
  exec 4:
    action4.delay: 00:00:03
    action4.type: exec actionGroup
    action4.group: "actionGroup_norte_aircon_on_L2"
  exec 5:
    action5.delay: 00:00:04
    action5.type: modify variable
    action5.variable: "norte_aircon_on_cool"
    action5.value: True
  exec 6:
    action6.delay: 00:00:06
    action6.type: send device specific command (harmony hub actions)
    action6.device: "harmonyHub"
      harmonyHub.device: airconnorte
      harmonyHub.commandGroup: miscellaneous
      harmonyHub.command: 28

## L2 ACTIONGROUPS DEF
#  "actionGroup_norte_aircon_on_L2" & "norte_aircon_poweron_runtime" can be swapped
#  in the actionsGroups above therefore, there's no need to define both.
\def actionGroup_norte_aircon_on_L2:
\  exec 1:
\    action1.delay: 00:00:00
\    action1.type: conditional_eps_super_conditions
\      conditional.conditions: variable value
\      conditional.variable: norte_aircon_on
\      conditional.value: == False
\        exec 1.1:
\          action1.type: exec actionGroup
\          action1.group: "actionGroup_norte_aircon_on_L3"
\      conditional.else:
\        exec 1.2:
\          action2.type: doNothing

## L3 ACTIONGROUPS DEF
def actionGroup_norte_aircon_on_L3:
  exec 1:
    action1.delay: 00:00:00
    action1.device: "harmonyHub"
      harmonyHub.device: airconnorte
      harmonyHub.commandGroup: home
      harmonyHub.command: powerON
  exec 2:
    action2.delay: 00:00:01
    action2.type: modify variable
    action2.variable: norte_aircon_on
    action2.value: True

## SCHEDULES DEF
# Create schedules without actions so they can be added right away.
# Adding no actions to them allows to duplicate actionGroups to finish quicker,
# Indigo doesn't notice when a component in a program is updated, therefore
# adding the action at a later stage forces Indigo to notice things changed.
schedule("norte_aircon_on_kill_runtime") interval 300 # seconds
    exec actionGroup_norte_aircon_on_kill
schedule("norte_aircon_on_vent_runtime") interval 600 # seconds
    exec actionGroup_norte_aircon_on_vent
schedule("norte_aircon_on_cool_runtime") interval 600 # seconds
    exec actionGroup_norte_aircon_on_cool_L0

\schedule "norte_aircon_poweron_runtime" interval 1 # seconds
\  !print(ExecutionInEventLog) # way too many at ^^^^^^^ interval!
\  eval:
\    if:
\      cond1.type: variable
\      cond1.variable: norte_aircon_on
\      cond1.value: True
\      exec 1:
\        action1.delay: 00:00:00
\        action1.type: exec actionGroup
\        action1.group: "actionGroup_norte_aircon_on_L3"
\    else:
\      exec 1:
\        else.type: doNothing

schedule (norte_aircon_enable) interval .at!Sunset
    exec 1:
      action1.type: modify variable
      action1.variable: norte_aircon_enabled
      action1.modify: True
schedule (norte_aircon_disable) interval .at!Sunrise
    exec 1:
      action1.type: modify variable
      action1.variable: norte_aircon_enabled
      action1.modify: False
    exec 2:
      action2.type: modify variable
      action2.variable: norte_aircon_kickstart_kill
      action2.modify: increment1

## VARIABLES DEF
norte_aircon_kickstart_kill = 356
norte_aircon_kickstart_vent = 356
norte_aircon_kickstart_cool = 357
norte_aircon_on = True|False
norte_aircon_on_vent = True|False
norte_aircon_on_cool = True|False
norte_aircon_enabled = True|False
norte_aircon_enabled_override = 1|0
daytime = True|False

# This is meant for devices that don't report status back to automation controllers,
# like ductless (mini split) AC units, the example here, hence all the repetition.
# Repetition also avoids manual override appliance-mounted buttons.
  SCHEDULE "norte_aircon_poweron_runtime" IS A WORKAROUND FOR THE SUPERCONDITIONS PLUGIN,
  IE; THE PLUGIN IS NOT DESIRED/COMPATIBLE/DISCONTINUED/ETC. THE DOWNSIDE IS THAT IT REPEATS CRAZY
  FAST SO IT WOULD FKUP THE NEXT SCHEDULE READOUT BY HAVING IT ALWAYS BEING RIGHT NOW.
Last edited by vitaprimo on Mon Oct 05, 2020 2:07 am, edited 1 time in total.

I'll bet you think this post is about you. Don't you. ♪

Posted on
Fri Oct 02, 2020 6:17 am
vitaprimo offline
User avatar
Posts: 37
Joined: Jul 12, 2016
Location: La Paz, Baja California Sur. MX.

Re: Condition on Actions *in* Action Groups


I'll bet you think this post is about you. Don't you. ♪

Posted on
Fri Oct 02, 2020 8:24 am
matt (support) offline
Site Admin
User avatar
Posts: 21416
Joined: Jan 27, 2003
Location: Texas

Re: Condition on Actions *in* Action Groups

I fixed it for you. You just have to surround the code chunk with the [code] [/code] tags. 8)

Image

Posted on
Sat Oct 03, 2020 10:23 pm
vitaprimo offline
User avatar
Posts: 37
Joined: Jul 12, 2016
Location: La Paz, Baja California Sur. MX.

Re: Condition on Actions *in* Action Groups

Whoa--thanks!

It never crossed my mind since it's not actual code. :P

I deployed it and it actually worked I was in disbelief for a moment and right after I fell asleep exhausted. A few errors easily spottable if anyone were to follow, escaped me but I updated the linked file as soon as I noticed each. It was just things missed from copy/paste so many lines of…non-code.

I had a little hiccup with an IR command that sends the wrong command, but that's specific to a device because I had used in on three devices an only one does that. As far as I know Indigo communicates with the Harmony Hub using the XMPP protocol that's similar to SIP, I believe--I'm about to find out. It should readable if I do a packet capture to see why it sometimes sends the wrong command.

Anyway, thanks again!

I'll bet you think this post is about you. Don't you. ♪

Posted on
Sun Oct 04, 2020 4:38 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Condition on Actions *in* Action Groups

vitaprimo wrote:
Whoa--thanks!

It never crossed my mind since it's not actual code. :P!

Erm, yes it is. :-)

And would you mind using less of the language; completely unnecessary.

Peter


Sent from my iPhone using Tapatalk Pro

Posted on
Mon Oct 05, 2020 2:05 am
vitaprimo offline
User avatar
Posts: 37
Joined: Jul 12, 2016
Location: La Paz, Baja California Sur. MX.

Re: Condition on Actions *in* Action Groups

I cleaned it up now, reordered the schedules, and added a workaround for the superconditions plugin so it all can be only with Indigo's supplied toolset, given all Apple updates break things now.

I still left the old in there though, but cleaner so it's clear it's one or the other, same link. And I promise it's not code, I tried several languages from the IDE, Python and JSON popped the most, then I started using developy words to see what would match a function/class/method, concepts I leaned looking for bright colors--I'm more like a design person. It turns out it's sort of logical, I might even learn Python some day, it wasn't as fun as the other type of Python I've touched but it was still entertaining, next is a Python snake--that outta be fun/scary.

I have a little ADHD; at some point I got distracted to create a ironic Firefox theme and jumping from Mac to Mac looking for one that'd wouldn't screw up the compressed file I needed with the stupid forks I landed on a server Mac that was like last week or so Indigo's host. As it turns out the server process was still running and though it didn't have the Insteon modem anymore it was still looping the first stages of my program and it's on the same isolated network of the other one and the Harmony Hub, this was the reason commands sometimes worked, sometimes didn't. Schedulers are sent at specific minutes, not when they are enabled--they were competing just seconds from each other! It also explains why there was nothing in the logs. :)

I'll bet you think this post is about you. Don't you. ♪

Posted on
Tue Jun 22, 2021 12:59 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Condition on Actions *in* Action Groups

I'm also looking forward to this feature. I handled it with some simple Python: (it does require an additional Action Group)

This one was designed to check to see if any of the garage doors were open and if so, close them when asked to. There is no trigger for this so it wasn't really needed until Alexa support, so my wife can ask to close the garage doors from bed. She's in a wheel chair and struggles with the used of her hands so the Alexa features are huge for my family.

Code: Select all
left_garage = indigo.variables[1470346067].value
right_garage = indigo.variables[1731578180].value

if left_garage == 'true':
   indigo.actionGroup.execute(589155825)
if right_garage == 'true':
   indigo.actionGroup.execute(1460987012)

Posted on
Sat Jan 06, 2024 11:05 am
t-star offline
Posts: 115
Joined: Oct 26, 2007

Re: Condition on Actions *in* Action Groups

This would be nice. I am looking at this for the Siri commands. when I leave the house I don't want someone turning on the fireplace etc.. Since you can't do trigger events from the Siri bridges, you end up writing a lot of code and/or doing multiple action groups to accomplish something simple.
In my case, just being able to disable an action group so that it would not work when Siri called it would be a great first step.

Posted on
Sun Jan 07, 2024 1:25 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Condition on Actions *in* Action Groups

EPS - Super Conditions? Use it a lot.

Carl

Posted on
Sun Jan 07, 2024 1:41 pm
t-star offline
Posts: 115
Joined: Oct 26, 2007

Re: Condition on Actions *in* Action Groups

is that a plugin?

Posted on
Sun Jan 07, 2024 1:46 pm
FlyingDiver offline
User avatar
Posts: 7213
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Condition on Actions *in* Action Groups

t-star wrote:
is that a plugin?


Yes, and the developer is no longer using Indigo abandoned it. And it was not updated for Python3. So not a useful resource anymore.

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

Who is online

Users browsing this forum: No registered users and 1 guest