Curtain close in afternoon during summer?

pct88

Member
I am trying to set up code that cycles our curtain motor daily while keeping track of the open/closed status.  The cycling provides no feedback of position, so I have to do it with logic.
 
"It is now dark out" is an input zone connected to an outdoor daylight photocell monitor.  "Curtain Cycle U35" is a relay module that operates the motor.
 
My goal is to have the curtains close 15 minutes before calculated sunset OR when it becomes dark.  Between April 15 and Sept. 15 close the curtains at 3pm to block the afternoon sun, and DON'T cycle the motor again at sunset since they will already be closed.  Also leave closed if manually closed at another time of day.
 
I am missing something in my code-  the curtains aren't closing at 3pm.
 
Suggestions for what I did wrong?
 
Thanks
 

113. // Only cycle the curtains once per sunset, and not if overidden
114. TIMED 3:00 AM MTWTFSS
THEN It is now dark out OFF
115. TIMED 7:30 AM MTWTF--
TIMED 8:00 AM -----SS
THEN Curtain Cycle U35 ON FOR 30 SECONDS
116. TIMED 15 MINUTES BEFORE SUNSET MTWTFSS
WHEN It is now dark out ON
AND IF It is now dark out OFF
THEN Curtain Cycle U35 ON FOR 30 SECONDS
THEN It is now dark out ON
117. // April 15 to September 15 close at 3 for afternoon sun...
118. TIMED 3:00 PM MTWTFSS
AND IF It is now dark out OFF
AND IF DATE IS GREATER THAN 4/15
AND IF DATE IS LESS THAN 9/15
THEN Curtain Cycle U35 ON FOR 30 SECONDS
THEN It is now dark out ON


 
 
 
I think you are using the WHEN condtion wrong in block 116: that should be an IF.
WHEN = When that event occours do something, since you are using it in combination with a time event the 2 things would have to happen simultaneously...

Basically your are saying: 15 minutes before sunset and at the same moment dark out IS BEING TRIGGERED then do something.

Instead it should be': 15 minutes before sunset and IF dark out has been triggered before then do something.

In a related note it's a pity that HAI does not and is not willing to support the X10 extended commands for curtains, that would allow us to send commands like: set curtain to level X% to place them in a specified positions.
The Marmitek SW12 controllers support the extended commands but the OP II doesn't so I can't use that great fratture
 
You have a couple of problems.
First, in line 116, the trigger "WHEN It is now dark out ON" will NEVER trigger any action because of the conditional directly underneath "  
"AND IF It is now dark out OFF".
That requires the flag to turn ON and simultaneously be OFF for it to take any further action.  So the condition will never occur. So when the photocell goes dark, it won't trigger the curtains at all.
The trigger "TIMED 15 MINUTES BEFORE SUNSET MTWTFSS" will trigger action only when the flag "It is now dark out" is off.

At 3:00 pm it appears that line 118 should trigger correctly if "It is now dark out" is off.
Once line 118 executes, the next pass through the code the system will look at line 116 and the trigger "WHEN It is now dark out ON".
Since the flag just turned on it will examine the criteria.  Since the flag can not be off if it is on, nothing else will happen.
But if that criteria was not there, line 116 would execute based ont eh flag turning on from line 118, which would turn the relay on for another 30 seconds. (possibly reversing the curtains).
 
 
tigers said:
I think you are using the WHEN condtion wrong in block 116: that should be an IF.
WHEN = When that event occours do something, since you are using it in combination with a time event the 2 things would have to happen simultaneously...

Basically your are saying: 15 minutes before sunset and at the same moment dark out IS BEING TRIGGERED then do something.

Instead it should be': 15 minutes before sunset and IF dark out has been triggered before then do something.

In a related note it's a pity that HAI does not and is not willing to support the X10 extended commands for curtains, that would allow us to send commands like: set curtain to level X% to place them in a specified positions.
The Marmitek SW12 controllers support the extended commands but the OP II doesn't so I can't use that great fratture
Stacked triggers act like OR lines.
If either one of the trigger conditions occurs, the block below the triggers will execute.
 
In this case the block will trigger 15 min before sunset OR when the flag turns ON.
When either of those occur, all of the conditional underneath will be evaluated and if satisfied the actions will execute.
 
This is a means to perform identical functions based on different conditions. 
It saves programming lines because you do not have to repeat the execute blocks of code.
 
113. // Only cycle the curtains once per sunset, and not if overidden
114. TIMED 3:00 AM MTWTFSS
THEN It is now dark out OFF
115. TIMED 7:30 AM MTWTF--
TIMED 8:00 AM -----SS
THEN Curtain Cycle U35 ON FOR 30 SECONDS
116. TIMED 15 MINUTES BEFORE SUNSET MTWTFSS
WHEN It is now dark out ON
AND IF It is now dark out OFF
THEN Curtain Cycle U35 ON FOR 30 SECONDS
THEN It is now dark out ON
117. // April 15 to September 15 close at 3 for afternoon sun...
118.TIMED 3:00 PM MTWTFSS
AND IF DATE IS GREATER THAN 4/15
AND IF DATE IS LESS THAN 9/15
AND IF It is now dark out OFF
THEN Curtain Cycle U35 ON FOR 30 SECONDS
THEN It is now dark out ON


Hi Cocooner... interesting problem.  Here's some feedback...

Problem 1:
If "It is now dark out" is a Zone monitor, then why are you setting its state - doesn't that set its own state?... then I wouldn't attempt to set its state (I don't think this is possible anyway). Forgive... I have limited experience in the full scope of zones, and have not yet dealt with one where I can programmatically set its state... so for now I am going to treat the photovoltaic sensor as an "auxiliary" zone type that is issuing output... Perhaps later you can be more specific about exactly how its installed in terms of how Omni sees it.)

Problem 2:
118 and 116 create a loop (not good)... so "It is now dark out" gets triggered in 118 at the same time "Curtain Cycle U35 ON FOR 30 SECONDS" gets called, THEN calls 116 and "Curtain Cycle U35 ON FOR 30 SECONDS" is called again.

Problem 3:
    WHEN It is now dark out ON
        AND IF It is now dark out OFF
...this simply does not work ...if/when "It is now dark out ON" triggers, "AND IF It is now dark out OFF" does not allow an action.

Just briefly I started working the logic from this angle (but it needs a bit more work)....
 

116. TIMED 15 MINUTES BEFORE SUNSET MTWTFSS
a WHEN It is now dark out SECURE <<--if it gets dark
b AND AfternoonTriggerFlag IS OFF <<--if curtains not cycled at 3pm
c THEN Set RunCurtainFlag 1 <<--run 'em

117. // April 15 to September 15 close at 3 for afternoon sun...
118. TIMED 3:00 PM MTWTFSS
d AND IF DATE IS GREATER THAN 4/15
e AND IF DATE IS LESS THAN 9/15
f AND IF It is now dark out NOT READY <<-- only if its light out
g THEN Set AfterNoonTriggeredFlag TO 1 FOR 8 Hours <<-- auto-reset in late eve
h THEN Set RunCurtainFlag TO 1

1xx. WHEN RunCurtainFlag ON
i THEN Curtain Cycle U35 ON FOR 30 SECONDS
j THEN RunCurtainFlag OFF

 
Some of the syntax is slightly off... I didn't check it, but its good enough for discussion....

At 3p during allowable season, "RunCurtainFlag" will trigger the curtain action.  AfterNoonTriggerFlag will place a hold on Macro 116, and reset itself at night.

Triggers at Macro 116 for Curtain operation will only be allowed if the AfterNoonTriggerFlag is Off ..WHEN any of the folowing occur.... darkness or nearing sunset.

Problems...
 - if its light out in morning, and then before 3pm it gets dark, the curtains will trigger and close.  What then at 3pm? If its not dark, the curtains will open!
 - if lighting changes between 3pm and evening, we have more fish to fry ;^)

So additional logic is needed to deal with that... I won't get into that because first I need to understand what you mean by Dark, and also that "zone input" sensor... if it clouds over heavily, then that's dark, and I don't understand if you want the curtains to then close??

Lastly... if the photovoltaic sensor is set up as a proper aux zone, you can trigger off of Secure / Not Ready states for changes in light; however, I don't think this allows for light levels, only a trigger point you have the device set for "toggling".  Really would help to understand more about the deployment aspects of this sensor.

 
 
Thanks for all of the suggestions and corrections to my programming logic.  The photocell is a simple on/off style that is connected to my Axis IR illuminator power supply.  I have a relay in parallel with the IR power supply that tells the OPII that it is light/dark through the input called "It is now dark out".  The sensor is facing east.  I also have an Ocelot tied to the OPII via RS232; it has a light sensor connected which I believe can actually look at light levels, but it stopped working reliably some years ago, so I just changef over to the relay above. 
 
The reason for the photocell control of the curtains is that this is a large bay window facing the street.  It is like a fish bowl when the lights are on and it becomes dark earlier than the calculated "night" closing time-  such as when there are heavy clouds.  I only need the curtains to close once per day-  if it becomes really dark, then the sun comes out again it is OK if the curtains remain closed until the following morning.  I also have a Button programmed to open/close them if we want to force them open again.
 
Sorry, I am not a pro, and perhaps am overlooking something obvious... AFAIK "input" could mean anything.
 
What exactly, meaning the technical designation, means
"input called "It is now dark out""
 
... is 'input' designation in th eOPII as a zone, a device, etc, and then what "kind" is it set as.
 
For instance, how is it seen in Dealer PC Access, assuming you use that.
 
No matter, if "it is now dark out" is a so-called "input" from a sensor, then you aren't setting it in your code, the light is setting the device state when dark/light happens, so it appears the logic I laid out should be suitable for what you describe.
 
Let us know.
 
I think you spotted the underlying problem:
 
"It is now dark out" is a flag.  "Secure when dark" is a zone input connected to a relay+EOL resistor with the relay controlled by a photocell.
 
I am using the flag only, but I meant to be using BOTH the flag AND the zone.  I need to go through this setup again.
 
Thanks!
 
Back
Top