larryllix Posted August 15, 2020 Posted August 15, 2020 Strange as it sounds for my reputation, I would not prefer the variable usage style in this case. I would likely have the first program wait an hour or so and enable the second program to run the following night. The second program would then self-disable as a last line again. @oberkc has a nice method above. The second program may be a little hard to understand some time later, but with appropriate explanation comments inside.......it's an odd style timing request.
asbril Posted August 15, 2020 Posted August 15, 2020 3 hours ago, oberkc said: I may not have followed all the variations of the various programs, but I reference this particular condition (variable removed): This condition would be true every night at sunset+15 that is not a special google calendar night. Correct? You are absolutely right !!!! I seem to have lost track of my own comments and therefore lead you on the wrong path. My apologies !!! The Google Calendar NS has 2 nodes for each 'event'; Tomorrow and Today. What I in fact did (but forgot to mention here) is using the Tomorrow node to start the event (program A) and the Today event to stop the event (program B, AND yes in both cases the IF is True (not False). I kept the variable that you suggested so right now the two programs are : A IF GH Special Day Tomorrow is True And From Sunset - 10 mins to 11:59 pm THEN Set Light X to ON $I.XXX=1 B IF GH Special Day Today is True And From Sunset + 10 mins to 11:59 pm AND $I.XXX = not 0 THEN Set Light X to OFF $I.XXX=0 As such, would this work the same way without the variable ? What is important to know is that in my event, the time cycle runs from sunset to sunset, not from 12 am to 12 am.
larryllix Posted August 15, 2020 Posted August 15, 2020 14 minutes ago, asbril said: You are absolutely right !!!! I seem to have lost track of my own comments and therefore lead you on the wrong path. My apologies !!! The Google Calendar NS has 2 nodes for each 'event'; Tomorrow and Today. What I in fact did (but forgot to mention here) is using the Tomorrow node to start the event (program A) and the Today event to stop the event (program B, AND yes in both cases the IF is True (not False). I kept the variable that you suggested so right now the two programs are : A IF GH Special Day Tomorrow is True And From Sunset - 10 mins to 11:59 pm THEN Set Light X to ON $I.XXX=1 B IF GH Special Day Today is True And From Sunset + 10 mins to 11:59 pm AND $I.XXX = not 0 THEN Set Light X to OFF $I.XXX=0 As such, would this work the same way without the variable ? What is important to know is that in my event, the time cycle runs from sunset to sunset, not from 12 am to 12 am. Yes! A IF GH Special Day Tomorrow is True at Sunset - 10 mins THEN Set Light X to ON $I.XXX=1 B IF GH Special Day Today is True at Sunset + 10 mins AND $I.XXX = not 0 THEN Set Light X to OFF $I.XXX=0 Today and tomorrow look switched!!
asbril Posted August 15, 2020 Posted August 15, 2020 1 minute ago, larryllix said: Yes! A IF GH Special Day Tomorrow is True at Sunset - 10 mins THEN Set Light X to ON $I.XXX=1 B IF GH Special Day Today is True at Sunset + 10 mins AND $I.XXX = not 0 THEN Set Light X to OFF $I.XXX=0 Thanks, right now I am keeping the variable to foster my {stubborn lack of} knowledge of variables.
larryllix Posted August 15, 2020 Posted August 15, 2020 2 minutes ago, asbril said: Thanks, right now I am keeping the variable to foster my {stubborn lack of} knowledge of variables. Give the variable a decent name like $LightIsOn so you know WTF it is doing there next year.
asbril Posted August 15, 2020 Posted August 15, 2020 Just now, larryllix said: Give the variable a decent name like $LightIsOn so you know WTF it is doing there next year. I did !!!!!
jfai Posted August 15, 2020 Posted August 15, 2020 @asbril You don't need the variable. GH calendar covers both days, so you're good. As I stated before using a time interval rather than a specific point in time covers certain unforeseen special circumstances. On the topic of testing time-related programs: Variables are very useful for this. Rather than waiting for the date/time to see if your programs work, you could use a state variable (it's a variable that can trigger programs) instead of the time condition. The state variable is modified in a separate program. Program C sets the state variable based on some time/date condition. Program A and B use the state variable instead of the time/date condition. Now you can use the admin console to modify the state variable and test programs A and B at any time.
asbril Posted August 15, 2020 Posted August 15, 2020 19 minutes ago, jfai said: @asbril You don't need the variable. GH calendar covers both days, so you're good. As I stated before using a time interval rather than a specific point in time covers certain unforeseen special circumstances. On the topic of testing time-related programs: Variables are very useful for this. Rather than waiting for the date/time to see if your programs work, you could use a state variable (it's a variable that can trigger programs) instead of the time condition. The state variable is modified in a separate program. Program C sets the state variable based on some time/date condition. Program A and B use the state variable instead of the time/date condition. Now you can use the admin console to modify the state variable and test programs A and B at any time. would you mind showing what A.B and C would look like ?
jfai Posted August 15, 2020 Posted August 15, 2020 For your use case, you don't need extra programs to set the state variable, assuming that you can easily trigger at will the GH calendar condition, e.g. by adding today's date as special day for testing purposes. Define a state variable sSpecialDayTime (default value and init value are 0). Value 1 shall mean "From Sunset - 10 mins to 11:59 pm" Value 2 shall mean "From Sunset + 10 mins to 11:59 pm" Program A2: If GH Special Day Tomorrow is True And ( From Sunset - 10 mins to 11:59 pm Or $sSpecialDayTime = 1 ) Then Set 'Light X' On Program B2: If GH Special Day Today is True And ( From Sunset + 10 mins to 11:59 pm Or $sSpecialDayTime = 2 ) Then Set 'Light X' Off Use the admin console to set the value of variable sSpecialDayTime to simulate the two time-of-day conditions. Modify your GH special day calendar for testing purposes. Don't forget to set the variable back to 0 once you're done testing ?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.