Jump to content

Can a program be set to run only during a specific time?


Recommended Posts

Should look something like this:

Ring - [ID 011D][Parent 0001]

If
        From    Sunset
        To      Sunrise (next day)
    And 'Ring NodeServer / Front Door motion' is switched Motion
 
Then
        Set 'Front / Front Patio' On
 
Else
   - No Actions - (To add one, press 'Action')

 

Link to comment
13 minutes ago, gzahar said:

Should look something like this:

Ring - [ID 011D][Parent 0001]

If
        From    Sunset
        To      Sunrise (next day)
    And 'Ring NodeServer / Front Door motion' is switched Motion
 
Then
        Set 'Front / Front Patio' On
 
Else
   - No Actions - (To add one, press 'Action')

 

Thanks!

Link to comment
  • 2 weeks later...

I created a program to switch ON a device as follows :

 

IF

From Sunset minus 10 minutes to  15 minutes after Sunset (next day)

THEN

Control Set Light X ON

However,  for mysterious reason it switches the light ON almost immediately not waiting for Sunset.

 

I changed program as follows :

 

IF

Sunset

THEN

Control Set Light X ON

I also created a secondary program to switch Light X OFF next day sunset.

That seems to work, though the test of time will be tonight at Sunset as well as tomorrow Sunset.

I just don't understand why first program does not wait till Sunset minus 10 minutes. Anyone has an idea ?

Link to comment
55 minutes ago, jfai said:

Your time period condition covers more than 24 hours. It's always true.

Thanks. I understand what you are saying,  but my logic is (was....) the IF  would start at Sunset minus 10 mins tonight and finish at 15 mins after Sunset tomorrow (next day).

Link to comment

Maybe you meant to use sunrise tomorrow instead of sunset: from sunset - 10 min to sunrise + 15 min (tomorrow).

If you leave your condition as is, it will always be true. Unless you add a date also, e.g., only on 8/9. Even then, the light will turn on immediately today, and turn off 15 minutes after sunset tomorrow, 8/10. Then it stays off until next year, 8/9.

What are you trying to achieve?

Link to comment
24 minutes ago, jfai said:

Maybe you meant to use sunrise tomorrow instead of sunset: from sunset - 10 min to sunrise + 15 min (tomorrow).

If you leave your condition as is, it will always be true. Unless you add a date also, e.g., only on 8/9. Even then, the light will turn on immediately today, and turn off 15 minutes after sunset tomorrow, 8/10. Then it stays off until next year, 8/9.

What are you trying to achieve?

It's complicated.  In fact this program is part of  3 programs and  programs 2 & 3 are activated by the Google Holidays  (GH) nodeserver. These are special events during the year (that go from sunset to sunset) and added in a dedicated calendar that is linked to the GH nodeserver.

Program 2 :  IF  selected GH calendar  Y Tomorrow is True, THEN Enable Program 1, Run Program 1 (Then).

Program 3 :  IF selected GH calendar Y Tomorrow is False, THEN Stop Program 1, Disable Program 1

Link to comment

I'm still not sure I understand what you want to achieve, but I can guess.

Let's say your GH calendar condition is true on some days of the year for the 24 hour period starting at midnight: let's use 9/1 as example for one of these dates. On 9/1 you want the light to turn on 10 minutes before sunset and stay on until the next day, 9/2, 15 minutes after sunset. The light should not be controlled by the programs on non-special days.

These two programs should work (pseudo code).

Program A:

If 

	GH calendar Y is true AND From sunset - 10 minutes to midnight
Then
	Turn on light X
	Set variable $isSpecialDay to 1

Program B:

If 

    GH calendar Y is false AND From sunset + 15 minutes to midnight AND variable $isSpecialDay is not 0
Then
    Turn off light X
    Set variable $isSpecialDay to 0

The integer variable $isSpecialDay is required so that program B is only true if the previous day was a special day.

Link to comment
3 hours ago, asbril said:

However,  for mysterious reason it switches the light ON almost immediately not waiting for Sunset.

I don't see the mystery.  This program would trigger twice: once at 10 minutes prior to sunset, and would be true, turning on the lights.  Second time would be at 15 minutes after sunset (next day!!??) and would be false.  That is the only two times this program would trigger.

Link to comment
33 minutes ago, jfai said:

I'm still not sure I understand what you want to achieve, but I can guess.

Let's say your GH calendar condition is true on some days of the year for the 24 hour period starting at midnight: let's use 9/1 as example for one of these dates. On 9/1 you want the light to turn on 10 minutes before sunset and stay on until the next day, 9/2, 15 minutes after sunset. The light should not be controlled by the programs on non-special days.

These two programs should work (pseudo code).

Program A:


If 

	GH calendar Y is true AND From sunset - 10 minutes to midnight
Then
	Turn on light X
	Set variable $isSpecialDay to 1

Program B:


If 

    GH calendar Y is false AND From sunset + 15 minutes to midnight AND variable $isSpecialDay is not 0
Then
    Turn off light X
    Set variable $isSpecialDay to 0

The integer variable $isSpecialDay is required so that program B is only true if the previous day was a special day.

Would this also work ?

If 
        GH calendar Y is true and time is sunset minus 10 mins
Then
	Turn on light X
	Set variable $isSpecialDay to 1

Program B:

If 

    GH calendar Y is false AND  time is sunset + 15 minutes  AND variable $isSpecialDay is not 0
Then
    Turn off light X
    Set variable $isSpecialDay to 0
Link to comment
3 minutes ago, asbril said:

Would this also work ?


If 
        GH calendar Y is true and time is sunset minus 10 mins
Then
	Turn on light X
	Set variable $isSpecialDay to 1

Program B:


If 

    GH calendar Y is false AND  time is sunset + 15 minutes  AND variable $isSpecialDay is not 0
Then
    Turn off light X
    Set variable $isSpecialDay to 0

Yes, it would also work. I added a time period rather than just a specific time to be a little more "fault tolerant". For example, if your GH calendar for whatever reason doesn't become true on the special day until after sunset, the light won't turn on. Or your ISY could be offline at the time sunset - 10 minutes. Having the time period also facilitates testing.

Link to comment
On 8/9/2020 at 5:02 PM, jfai said:

Yes, it would also work. I added a time period rather than just a specific time to be a little more "fault tolerant". For example, if your GH calendar for whatever reason doesn't become true on the special day until after sunset, the light won't turn on. Or your ISY could be offline at the time sunset - 10 minutes. Having the time period also facilitates testing.

Many thanks. It worked as desired !!!!

Link to comment
On 8/9/2020 at 5:02 PM, jfai said:

Yes, it would also work. I added a time period rather than just a specific time to be a little more "fault tolerant". For example, if your GH calendar for whatever reason doesn't become true on the special day until after sunset, the light won't turn on. Or your ISY could be offline at the time sunset - 10 minutes. Having the time period also facilitates testing.

In order to get a better understanding of Variables,   what difference would these programs have without the variable ?

Link to comment
6 minutes ago, larryllix said:

Most would look like this

If
    {
     light1  > 0%
    AND   light2 > 0%
     AND light3 > 0 %
     AND light4  > 0%
   '''' etc. etc. etc..
     AND light4 > 0%
   } OR {
     light6 is not On
     AND light7 is not On
   } AND {
   etc.. etc.. etc...

hmmmm...   cannot be done in most cases.

When you turn on any scene, every program would have to test every other device involved and take dozens of lines but still never be able to remember what your last setting was, without dozens and dozens of more variables, anyway.
When your ISY needs to remember a multitude of things, there is no substitute method that can do it easily...period.

When I want to turn on my Sunset light scene with slow ramping down white lights into deep orange/red lights, my program consists of this.
If
      GathRm.switchlinc is switched 'Dim'
Then
      GathRm.lights = $cSUNSET
Else
     -----

...then all kinds of ramping and colour changing occurs, and a slow ramping program starts that ramps every light down over the period two hours. The actions are divorced from the triggers and each easy to understand without any complex logic to test for other conditions.

-------------------------------------------
A vocal example
  "Alexa...turn on perimeter lights"
looks like this program:
If
 --
Then
    GathRm.lights = $cPERIMETER
Else
    --

This turns off all ceiling pot lights and sets all wall lamps and above cabinet lights in the kitchen area on to 100% white.

Larrylix, you must come to see me when you are in the neighborhood and teach me this. I offer lunch, dinner and a beer (pina colada, caipirinha or mojito).

Seriously, in this particular case for me , there is only one light to control.

Link to comment
14 minutes ago, asbril said:

Larrylix, you must come to see me when you are in the neighborhood and teach me this. I offer lunch, dinner and a beer (pina colada, caipirinha or mojito).

Seriously, in this particular case for me , there is only one light to control.

LOL! Well then I got carried away.

ISY programming difficulty, is proportional to the logarithm of the number of devices involved, times the confusion, in the mind of the poster.

 

Geeezzzz asbril..you got me good there. I thought I was answering another thread.

I have deleted my previous complicated post. I am embarrased here! LOL

Link to comment

@asbril Let's see what happens if we remove the reference to the variable in program B. 

Program A still works the same.

Program B:

  • On most days - except on special days - the GH calendar condition is false.
  • Every day at sunset + 15 min the time of day condition is true (and stays true until midnight)

Therefore, every day at exactly sunset + 15 min, the condition of program B becomes true, and the program runs the "then" branch: the light is switched off.

That may be OK with you, but if you turn the light on at the switch on any day, you may not want it to be switched off by program B. That's why I included this requirement originally: 

On 8/9/2020 at 1:17 PM, jfai said:

The light should not be controlled by the programs on non-special days.

To achieve this requirement, we need to tell the ISY when program B should be "runnable" (is eligible for execution). There are (at least) two ways to do that:

  1. Use a variable as a binary flag: "on" / "true", "off" / "false". I used value 0 for "false" and any other value (specifically 1) for "true".
  2. Ensure that program B is normally disabled and only enable it in program A. Instead of setting the variable in A, you would enable program B. And in B instead of setting the variable, you would disable program B.

 I rarely use the ISY's enable/disable program feature, and generally prefer variables. Variables allow any number of "states", not just two. You can't do that easily with enable/disable program.  In the past there have been firmware upgrades that enabled all disabled programs, which of course makes a mess of your programming. You need to look at each program and make sure it is disabled, unless it should be enabled at the time of checking.

I haven't seen a firmware upgrade that messed up my variables, as long as the "init" values of variables are managed correctly. "init" values are for another soap box story, though. Suffice to say, for each variable you need to decide what value it should have "initially" when the ISY restarts. By default, the "init" value of variables is 0, and usually that's just perfect, like in your use case of a special day light.

Hope this helps.

Link to comment
9 minutes ago, jfai said:

@asbril Let's see what happens if we remove the reference to the variable in program B. 

Program A still works the same.

Program B:

  • On most days - except on special days - the GH calendar condition is false.
  • Every day at sunset + 15 min the time of day condition is true (and stays true until midnight)

Therefore, every day at exactly sunset + 15 min, the condition of program B becomes true, and the program runs the "then" branch: the light is switched off.

That may be OK with you, but if you turn the light on at the switch on any day, you may not want it to be switched off by program B. That's why I included this requirement originally: 

To achieve this requirement, we need to tell the ISY when program B should be "runnable" (is eligible for execution). There are (at least) two ways to do that:

  1. Use a variable as a binary flag: "on" / "true", "off" / "false". I used value 0 for "false" and any other value (specifically 1) for "true".
  2. Ensure that program B is normally disabled and only enable it in program A. Instead of setting the variable in A, you would enable program B. And in B instead of setting the variable, you would disable program B.

 I rarely use the ISY's enable/disable program feature, and generally prefer variables. Variables allow any number of "states", not just two. You can't do that easily with enable/disable program.  In the past there have been firmware upgrades that enabled all disabled programs, which of course makes a mess of your programming. You need to look at each program and make sure it is disabled, unless it should be enabled at the time of checking.

I haven't seen a firmware upgrade that messed up my variables, as long as the "init" values of variables are managed correctly. "init" values are for another soap box story, though. Suffice to say, for each variable you need to decide what value it should have "initially" when the ISY restarts. By default, the "init" value of variables is 0, and usually that's just perfect, like in your use case of a special day light.

Hope this helps.

Many thanks jfai, as Larryllix knows, I have a mental blockage when it comes to variables but your explanation makes good sense. I am going to read it till I get it (that may be a while) :-)

 

Link to comment
31 minutes ago, asbril said:

Many thanks jfai, as Larryllix knows, I have a mental blockage when it comes to variables but your explanation makes good sense. I am going to read it till I get it (that may be a while) :-)

If it's only a mental blockage you are more than halfway there. :):)

Link to comment

If variables add confusion, I would argue that it is not necessary (in this case, at least).  If program A runs true, it sets "$isSpecialDay" =1.  Program B would be false.  If program B runs true, it sets "$isSpecialDay" = 0.  Program A would be false.  In other words "$isSpecialDay" = 1 = programA is true, and "$isSpecialDay" = 0 = programB is true.  The variable is redundant and you could simply use program states (is true) as a program conditions in place of the variable.

Link to comment
1 hour ago, oberkc said:

If variables add confusion, I would argue that it is not necessary (in this case, at least).  If program A runs true, it sets "$isSpecialDay" =1.  Program B would be false.  If program B runs true, it sets "$isSpecialDay" = 0.  Program A would be false.  In other words "$isSpecialDay" = 1 = programA is true, and "$isSpecialDay" = 0 = programB is true.  The variable is redundant and you could simply use program states (is true) as a program conditions in place of the variable.

oberkc, thanks. This does in fact help me. I often use 3 programs to get something done; 1 to execute an action, 2 to disable 1 when not needed and 3 to enable 1 when 2  no longer applies. I am sure that variables would be a better way, and I am frustrated not yet grasping the concept, but my way works for the time being.

Link to comment
3 hours ago, asbril said:

but my way works for the time being

Yes, probably true.  But...don't neglect the edge case mentioned by jfai....without the removed condition (whether based upon a variable, another program state, or something else), the light will turn the light off every night, whether necessary or not or whether desired or not.  This may not be something that is important 364 days of the year, but these unintended consequences often reveal themselves at inopportune times.

Link to comment
2 hours ago, oberkc said:

without the removed condition (whether based upon a variable, another program state, or something else), the light will turn the light off every night,

I would have assumed that  AND AND conditions (instead of OR) in IF would prevent that ?  Am I mistaken ?

Link to comment
8 hours ago, asbril said:

I would have assumed that  AND AND conditions (instead of OR) in IF would prevent that ?  Am I mistaken ?

I may not have followed all the variations of the various programs, but I reference this particular condition (variable removed):

 

On 8/9/2020 at 4:54 PM, asbril said:

GH calendar Y is false AND time is sunset + 15 minutes

This condition would be true every night at sunset+15 that is not a special google calendar night.  Correct?  

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...