ryanmead83 Posted September 9, 2015 Posted September 9, 2015 I couldn't think of anything good for a subject sorry! Just a question, I have this working but wondering if this is the best way. I have a program that turns the front porch light on to 30% if we are home, and 50% if away (based on the variable set by my alarm, 0 for home, 1 for armed away), and if someone comes home while it is in away mode and then turn it off, it goes to 30% and so on. So at first I did: Program 1 IF Time is from Sunset to Sunrise and Alarm_Armed = 0 THEN Front Porch = 30% ELSE Front Porch = Off Program 2 IF Time is from Sunset to Sunrise and Alarm_Armed = 1 THEN Front Porch = 50% ELSE Front Porch = Off If program 2 is running because the alarm is armed, so light is at 50%, and someone comes home and turns it off, setting the Alarm_Armed variable to = and running program 1, the problem is that the light goes immediately to 30%, but then the "ELSE" portion of program 1 runs and turns the light off. So to solve it I did them like: Program 1 IF Time is from Sunset to Sunrise and Alarm_Armed = 0 THEN Stop Program 'Program 2', Front Porch = 30% ELSE Wait 10 seconds, Front Porch = Off Program 2 IF Time is from Sunset to Sunrise and Alarm_Armed = 1 THEN Stop Program 'Program 1', Front Porch = 50% ELSE Wait 10 seconds, Front Porch = Off This solved the problem and works fine, but I'm just trying to improve my own skill and am wondering if this is how others would do this ,or if there's a better more efficient way? The issue I find is that it works, but if there's ever more than just 2 overlapping programs, then there would be a lot of code to stop all of them and keep watching them for updates and so on. Thanks!
MWareman Posted September 9, 2015 Posted September 9, 2015 (edited) I'd clear out both 'Else' branches in your first example and create a third program triggering on 'Sunrise' to handle turning off the light... Edited September 9, 2015 by MWareman
ryanmead83 Posted September 9, 2015 Author Posted September 9, 2015 That's actually how I had it originally! But was reading the ISY994i's user manual and they showed programs like this the way I did it above, with a time set from 1 time to another vs one program to turn the lights on and another to turn them off. The reason I found this way better was because if I use 2 programs, how can the ISY catch up in a power failure? Like if I have "If time is from sunset to 11pm" and an hour before sunset the power goes out and comes back on at 10pm, doing it the above way turns the light on when power is restored at 10pm. If I have 2 programs, how would I do it so that in a power failure the system knows the light is supposed to be on or not type thing since a "If the time is sunset turn the light on" wouldn't retrigger. Thanks!
Recommended Posts