DualBandAid Posted September 18, 2013 Posted September 18, 2013 Hi there, I've found in several instances I like to create an "alt" functionality in a SwitchLinc using a down-press when the light is already off. I'll give you one example. My baby's room. The light switch turns the light off (duh). But once it is off, I programmed it so that a down-click WHEN THE LIGHT SWITCH IS OFF will turn on or off the baby noise machine (that is connected to an ApplianceLinc). The alt functioning only works if the light-switch is off -- which is fine because that's the only time I ever need this "alt" function. So here's how it works. I turn the light off. Then I off-click the light again - and the noise machine turns on. This is the program I use: If Status 'MASTER - Fan Light' is Off And Control 'MASTER - Fan Light' is switched Off And Status 'BABY - White Noise' is Off Then Set 'BABY - White Noise' On Else - No Actions - (To add one, press 'Action') Then if I want to turn the noise machine off, I use a SECOND program that looks like this: If Status 'MASTER - Fan Light' is Off And Control 'MASTER - Fan Light' is switched Off And Status 'BABY - White Noise' is On Then Set 'BABY - White Noise' Off Else - No Actions - (To add one, press 'Action') It works like a charm. The thing is, I would LOVE to able to do all this in one single program, but I can't seem to figure it out. Using the ELSE function doesn't seem like it would work. What would work maybe is a "then" function that "toggles" the switch... Toggle 'BABY - White Noise' ...except there isn't any function like that. The problem here is, I have about a dozen of these alt functions in my house (and love them) but they require twice as many programs. I have program-bloat. And also, if I make a change, I have to make it twice. It's just one more thing... Any ideas?
Michel Kohanim Posted September 19, 2013 Posted September 19, 2013 Hi DualBandAid, Unfortunately that's the only way currently. The reason is that anything that evaluates to "False" causes the Else to run and that may include conditions that you do not wish to have included. With kind regards, Michel
BobH Posted September 19, 2013 Posted September 19, 2013 You should be able to do this with a single program and a variable. Set up a variable like noise_machine_state and use the variable in place of the appliancelinc state in the if test. This will allow you to use the then and else clauses to turn on or off the machine, If and Noise_machine_state is 0 then turn on noise machine noise_machine_state = 1 else turn off noise machine noise_machine_state = 0
LeeG Posted September 19, 2013 Posted September 19, 2013 BobH All the conditions have to be True for the Then clause to run as one would want. If any of the conditions are False the Else clause runs. That generally results in the Else clause running when not desired.
apostolakisl Posted September 19, 2013 Posted September 19, 2013 You should be able to do this with a single program and a variable. Set up a variable like noise_machine_state and use the variable in place of the appliancelinc state in the if test. This will allow you to use the then and else clauses to turn on or off the machine, If and Noise_machine_state is 0 then turn on noise machine noise_machine_state = 1 else turn off noise machine noise_machine_state = 0 This wouldn't work for his program because the "other tests" would need to be: Status 'MASTER - Fan Light' is Off And Control 'MASTER - Fan Light' is switched Off The first line "status master light is off" would be a trigger every time the light changed status which would result in the "else" clause running a whole lot of times you didn't want it. Also, it would require that this program be the only way you turn the noise machine on/off. If you turned the noise machine on or off otherwise, the variable would be out of sync, and you would need another program to track the status of the noise machine. . . which defeats the whole purpose of trying to turn 2 programs into 1. The real answer to this problem has been discussed at length in the past, and that would be for ISY to allow you to select which conditions may act as triggers. Like a check box after each line or something.
oberkc Posted September 19, 2013 Posted September 19, 2013 I have program-bloat. Program folders are really nice method to keep things organized.
Xathros Posted September 19, 2013 Posted September 19, 2013 I'm hopeful that the next firmware update with expanded variable support will allow me to reduce my program count significantly while greatly improving the ISY's capabilities. -Xathros
apnar Posted September 19, 2013 Posted September 19, 2013 (I'm new to ISY programing so someone with more experience please correct me if I'm off base with this suggestion) It won't reduce the number of programs but you could try a different split which may help make things more manageable. You could create a disabled dedicated toggle program: If Status 'BABY - White Noise' is Off Then Set 'BABY - White Noise' On Else Set 'BABY - White Noise' Off Then make a single enabled program that calls it to do what you want: If Status 'MASTER - Fan Light' is Off And Control 'MASTER - Fan Light' is switched Off Then Run Program 'Toggle BABY - White Noise' (If) Else - No Actions - (To add one, press 'Action') That way you can hide away all your simple Toggle programs in a folder that you'll likely never need to touch and keep your single program with logic. Might even get to cut down on a few programs if you can reuse a Toggle program or two.
apostolakisl Posted September 19, 2013 Posted September 19, 2013 Your logic is sound. Probably this would be a more easily organized way to do it, especially as you mentioned, if you have lots of toggle programs. You could just disable the whole folder with an if clause that is never true.
DualBandAid Posted September 23, 2013 Author Posted September 23, 2013 Thank you, everyone. And thank you apnar. But I will have to wait for either the baby itself to be asleep to get enough head space to see if that will help things. EDIT: One follow-up question, apnar. Wouldn't I need to have a disable program command at the end the "then" and "else" sections of the baby toggle, or else it will loop?
apnar Posted September 23, 2013 Posted September 23, 2013 EDIT: One follow-up question, apnar. Wouldn't I need to have a disable program command at the end the "then" and "else" sections of the baby toggle, or else it will loop? I don't think so. With the toggle program being disabled it should only run if it's explicitly called. I am new at this though, so I'd test it out when the baby isn't sleeping
apostolakisl Posted September 23, 2013 Posted September 23, 2013 Thank you, everyone. And thank you apnar. But I will have to wait for either the baby itself to be asleep to get enough head space to see if that will help things. EDIT: One follow-up question, apnar. Wouldn't I need to have a disable program command at the end the "then" and "else" sections of the baby toggle, or else it will loop? No, you wouldn't. The program is always disabled (assuming you set it as disabled). Calling a program via "run if/then/else" does not re-enable it. The "enable" and "disable" only serves to stop the program from SELF triggering (or in other words, by a condition in the "if" clause causing the "if" to trigger). Any other program or a manual action on a user's part can still force run the if/then/else even while disabled.
Recommended Posts