[SOLVED]Complex Toggle Behavior

Posted on
Sat Jan 26, 2019 7:00 am
msageryd offline
Posts: 23
Joined: Jan 24, 2019

[SOLVED]Complex Toggle Behavior

I ended up here trying to solve my toggling issue. What solution should I use in Indigo 7.2? Is the more automatic way implemented yet?

Actually, I'm a bit confused. What should I use for my task?
- action groups?
- virtual on/off?
- virtual device group?

My task:
I have 8 lights which I would like to toggle with a single Fibaro button like this:

* single click: If any of the 8 light is on then turn them all off
* single click: If all lights are off then turn 4 of them on
* double click: Always turn all 8 lights on

I can control the above scenes via the following three action groups, but I can't toggle them.
1. Less light (turn 4 lights on)
2. More light (turn all 8 lights on)
3. Lights off (turn all 8 lights off)

I tried to define a variable which I set in the action groups. But this variable cannot be used in the trigger condition because it seems to be set directly so the opposite condition will be met as well.

Example:
Trigger 1
- trigger: listen for single click from button
- condition: only execute if lightVariable=false
- actions: Less light (turn on 4 lights)

Trigger 2
- trigger: listen for single click from button
- condition: only execute if lightVariable=true
- action: Lights off (turn off all 8 lights

When I single click on the button Trigger 1 executes. Directly after this Trigger 2 also executes. Trigger 2's condition will be met because the action from Trigger 1 set the lightVariable=true

Posted on
Sat Jan 26, 2019 11:46 am
jay (support) offline
Site Admin
User avatar
Posts: 18219
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Complex Toggle Behavior

[MODERATOR NOTE] I split this post off from the topic it was originally posted under because while it's tangental, it's worth its own topic since the other one was marked closed and doesn't really ask the same question.

So, clearly this is complex toggle behavior that's quite scenario specific but that's not to say it can't be done. I can think of two approaches off the top of my head: first, a custom script as the action associated with the single click (double click is easy since it always turns them all on). The script would look at the status of the 8 lights and determine what action should actually be executed.

However, I think there is a second non-scriptable way to approach it: create a Device Group with all 8 lights in it defined as an "any" group. This will have the group be ON if any one of the devices is on (your first condition) or OFF (your second condition). Then you can create two triggers that fire on the single click event, the condition on the first would be if the device group is ON (turn them all off), the condition on the second would be if the group is OFF (turn on the 4). Again, double-click is straight-forward so doesn't need any additional logic in that trigger.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Mar 05, 2019 12:02 pm
msageryd offline
Posts: 23
Joined: Jan 24, 2019

Re: Complex Toggle Behavior

A little late, but anyways..
Thank you Jay. This worked perfectly.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests