[ANSWERED]accessing buttons on multi button switches

Posted on
Sat Oct 25, 2014 9:36 pm
timrowledge offline
Posts: 41
Joined: May 14, 2011

[ANSWERED]accessing buttons on multi button switches

I haven't been able to find any explanation of how I can access particular buttons on a multi button switch within a script.

I have a simple need, and I must be searching for help with poorly chosen terms because it seems like something that would be fairly commonly used - I have two switches to control a fan and when both switches are off I want a delay before the fan is switched off. If either switch is turned on, then the delay should be cancelled. (I have one large inline fan ventilating two bathrooms)
In this particular case one of the switches is multibutton (hence wanting to know how to access one of the buttons) and the other is a simple switch that is directly connected to the fan.

Currently I have both switches triggering an action group that just executes a scene and so if one switch turns on the fan the other can turn it off , which is a bit of a pain if the first switch still wants it on. And there is no delay either.

My thought was to use a variable, change its state when either switch was turned on or off and use that to trigger a script that cheeks the state of the two switches to decide whether to turn on the fan, cancel a running delay, start a delayed turn-off or make toast. Something like
Code: Select all
if ((on state of device "switch X button 3") or (on state of device "switch Y")  <--- how do we actually do the "switch X button 3"?
    then
           send instead group instTurnOn using name "BFan"
          remove delayed actions for device "BFan" <--- I think that's right; found it elsewhere on this forum
    else
          {trigger a trigger with a 5 minute delay to actually turn off the fan but I haven't got that far yet}

But I'll happily take advice on any decent way to get the end result; I'm not wedded to any other aspect.

Part of my problem in doing this is a complete lack of any experience in doing anything with AppleScript, but mostly its just that once I got Indigo set up two or three years ago I haven't had to do anything or even think about it, so one forgets anything learned.

Posted on
Mon Oct 27, 2014 9:34 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: accessing buttons on multi button switches

So, you want to trigger based on button X of a KeypadLinc and also a SwitchLinc - is that right? Is the button you're testing on the KeypadLinc not the load? It will make a difference in the solution.

AppleScript isn't what you want to use here - it doesn't have access to the individual button states. Python does, and it's the better option anyway for a variety of other reasons. However, depending on the answer to the question above, you might not need a script at all - if it's the load on the KeypadLinc then there's a good non-script solution.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Oct 28, 2014 7:52 pm
timrowledge offline
Posts: 41
Joined: May 14, 2011

Re: accessing buttons on multi button switches

So, you want to trigger based on button X of a KeypadLinc and also a SwitchLinc - is that right?

That's what I was thinking but I'm absolutely open to doing it any other way that will work.

Right now I have a switch with the shared bathroom fan as its load. Upstairs I have a keypad where button 3 triggers an inline relay to turn on the shower/bath lighting and turns on the switch to fire up the fan.
Turning the switch off obviously turns off the fan (and shouldn't - it should trigger the delay and 'turn back on' which clearly might be something of a confusion to guest, so maybe I'd be better off getting another inline relay for the actual fan) and the keypad button currently turns off the switch.

I'd like to end up with the fan running for X minutes after we get to a state where neither switch nor keypad button is on. I'll do it with python, applescript, direct dialogue usage, whatever it takes. I feel sure it's going to be facepalmingly simple in the end but I just don't have the mental model for how indigo works and find it very hard to work out.

Posted on
Wed Oct 29, 2014 8:39 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: accessing buttons on multi button switches

If you want the switch to not actually directly control the fan but rather have Indigo control it with the logic you describe, then you probably do want to put the fan on an inline/micro relay. I'm not sure what would be more confusing to a guest: having the fan go off then immediately back on when they hit the off button, or having the fan not go off when the off button was pressed. Both are likely to be somewhat confusing.

If I were going for this behavior, I think I'd just put the SwitchLinc on the light in the room and put the inline relay on the fan. Then in Indigo I'd create a trigger that turns the fan on when the SwitchLinc goes on and performs the X minute delay when the SwitchLinc goes off. You can then directly link the KeypadLinc button to the SwitchLinc and the behavior will be the same. It's not exactly what you describe since it couples the fan to the light, but I think it would be less confusing for guests (something that I've had to work on over the years).

My question was more about which button on the KeypadLinc you were using. KeypadLinc buttons that aren't the load don't look like individual on/off devices as a KeypadLinc load button/SwitchLinc does to Indigo (yet). If it was the load button(s), it would have been easier because you could use a Device Group and trigger on the Device Group going off because you can configure a device group to go off when all devices in the group go off.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Oct 29, 2014 7:07 pm
timrowledge offline
Posts: 41
Joined: May 14, 2011

Re: accessing buttons on multi button switches

I can certainly get another relay to actually control the fan; confusion because a switch turns itself on after you turn it off might be amusing to watch the first time but not so much after. And actually, thinking about it, how would we tell if it was turned back on to keep the fan running during the delay or by a user actually wanting it back on? So, relay to buy.

I can't link the keypad button directly since this is two separate bathrooms and having the over-shower lights turn on in the ensuite when someone in the guest bathroom turns on the fan would be pretty annoying.

To try to answer your Q about the buttons used -
ensuite
keypad with
load -> main lights
button 3 -> over-shower lights by relay and trigger fan

guest
switch with
load -> fan
separate switch for lights

Posted on
Thu Oct 30, 2014 11:23 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: accessing buttons on multi button switches

Ok, now I'm really confused - looking at your two descriptions above, I'm not at all understanding how you have 2 different switches controlling the same fan...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Oct 30, 2014 3:50 pm
timrowledge offline
Posts: 41
Joined: May 14, 2011

Re: accessing buttons on multi button switches

Let's see if I can explain clearly.

Two bathrooms share a single large inline fan; it's very effective and much quieter than most typical bathroom fans.

The ensuite has a keypad where the load is the main lights and button 3 triggers the auxiliary lights above the shower & bath as well as the fan. The guest bathroom has two separate switches (historical reasons) and one of them has the fan as its load.

I'll try to present the setup here, wish there was a way to 'print' the state of the various device/triggers/actions for you to read.

trigger 'MBathControlMB-3 On'
type: insteon command received
from: device 'MBathControlMB'
received: ON Button/Group 3
condition: always
actions: turn on (light/appliance controls) 'MBathLightingRelay'
actions: execute action group 'Bathroom fan on'

action group 'Bathroom fan on'
type: execute insteon scene
send: scene on
scene: 9 'Bathroom Fan'
-> turns on 'GBathFanSwitch' & MBathControlMB/3

trigger 'MBathControlMB-3 Off'
-> which is exactly as per 'MBathControlMB-3 On' except for turning things off.

trigger 'GBathFanSwitch-1 On'
type: insteon command received
from: device 'GBathFanSwitch'
received: ON Main Button/Group
condition: always
actions: execute action group 'Bathroom fan on' (as per above)

trigger 'GBathFanSwitch-1 Off'
-> which is exactly as per 'GBathFanSwitch-1 On' except for turning things off.

Hope that makes sense! It actually makes more sense to me written out than via the UI...

Posted on
Fri Oct 31, 2014 8:59 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: accessing buttons on multi button switches

Ah, sorry, I missed the part about the fan being shared by both bathrooms. It makes sense now.

Ok, here's what I'd try I think:

  1. Create a Timer device that runs for X minutes (this will be used to turn off the fan).
  2. Create triggers for the fan SwitchLinc and the KeypadLinc button 3 such that when their state becomes ON, the fan turns on AND stops the timer created in step 1. You can put these two actions in an Action group and have each trigger execute the action group (so if you later need to adjust the actions you only have to do it once).
  3. Create a trigger for the SwitchLinc becoming OFF, with a condition of the KeypadLinc button 3 is off, action is to start the timer created in step 1.
  4. Create a trigger for the KeypadLinc button 3 becoming OFF, with a condition of the SwitchLinc is off, action is to start the timer created in step 1.
  5. Create a trigger for when the timer expires, turn the fan off.

So, the logic goes something like this: either the SwitchLinc or KeypadLinc button 3 becomes on and the fan goes on. This also stops the timer if it had been previously started (stopping an already stopped timer is fine). At a later time, either the SwitchLinc or KeypadLinc goes off, which first checks the other one to see if it's on, and if it's not it starts the timer. Finally, when the timer runs out, the fan goes off. If at any point during the timer running one of them becomes on, then the timer stops and the fan continues to run. The timer won't be started until both switches are off.

I think that's got it. You may need to play with it a bit but that's one pattern that should work. No scripting either, so that may be a bonus. BTW, I'd use Device State Changed triggers rather than INSTEON received - they're generally a better higher-level abstraction.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Nov 02, 2014 8:32 pm
timrowledge offline
Posts: 41
Joined: May 14, 2011

Re: [ANSWERED]accessing buttons on multi button switches

OK, thanks; that seems to make sense. Now to see if theory survives colliding with reality..

[EDIT] Small but important point - you need the timer/pester plugin enabled in order to make timer devices.

Posted on
Mon Nov 03, 2014 11:55 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: [ANSWERED]accessing buttons on multi button switches

timrowledge wrote:
Small but important point - you need the timer/pester plugin enabled in order to make timer devices.


Correct.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 13 guests