Apex code question

BriansBrain

Active Member
View Badges
Joined
Jul 31, 2014
Messages
362
Reaction score
365
Location
Ohio
Rating - 0%
0   0   0
Pretty simple I just want my skimmer to run from 09:00 to 21:00 and off from 21:00 to 09:00. The outlet does not turn on at 09:00 unless you manually run it on and set in auto. I’m pretty sure it shuts off at 21:00 while in auto.
0BA2E5E0-3B4E-4E1A-A6C1-4BF44CAF9366.png
 

vetteguy53081

Well known Member and monster tank lover
View Badges
Joined
Aug 11, 2013
Messages
91,874
Reaction score
202,916
Location
Wisconsin -
Rating - 100%
13   0   0
I simply name the outlet as skimmer and on time 9a and off time 9p(2100) and save it
 

jassermd

Well-Known Member
View Badges
Joined
Oct 22, 2020
Messages
573
Reaction score
810
Location
Southlake
Rating - 0%
0   0   0
One other thing:
Fallback OFF
Set OFF
If you don't set it to off, the on statements are useless.

And you have 2 defer statements. You only need one.
Otherwise, it looks good.
 

rhostam

Well-Known Member
View Badges
Joined
Oct 12, 2020
Messages
808
Reaction score
1,048
Location
Aurora
Rating - 0%
0   0   0
Have you tried removing the DEFER statements to test?

You have multiple DEFER statements defined.

You can only use one per program per state (ON/OFF) if I am not mistaken. As defined, the DEFERs would only run for the ON conditions that evaluate as true.

For instance:
Code:
If Time 09:00 to 21:00 Then ON
DEFER 180:00 Then ON
Would work together.

Until line 7 overrides line 5:
Code:
DEFER 030:00 Then ON

The way I read the code node, provided all feed, probe, and sensor states are FALSE:
  1. If time is between 09:00 to 21:00 then turn ON
  2. But first wait 30 minutes, then turn ON.
I would also suggest you create a few virtual outlets to clean up the code. It also allows you an easy way to determine state of each condition (via outlet state).

Code:
-- Virtual Outlet SKIM_TIME
If Time 09:00 to 21:00 Then ON
DEFER 180:00 Then ON

-- Virtual Outlet FEEDTIME
If FeedB 000 Then ON
If FeedC 000 Then ON

-- Virtual Outlet COR_ON
Set ON
If Output Cor20 = OFF Then OFF

-- Virtual Outlet PH_HIGH
Set OFF
If pH > 8.5 Then ON

-- Then in the program use these virtual outlets:
If Outlet COR_ON = OFF Then OFF
If Outlet PH_HIGH = ON Then OFF
If Outlet FEEDTIME = ON Then OFF
If Outlet SKIM_TIME = ON Then ON

You can view the outlet states and reuse them in other programs, too.
 
OP
OP
BriansBrain

BriansBrain

Active Member
View Badges
Joined
Jul 31, 2014
Messages
362
Reaction score
365
Location
Ohio
Rating - 0%
0   0   0
Thanks all! It is the defer that was keeping it from turning on. I also deleted the the 180 minute defer because I had that for a feed mode but it’s unimportant and unread anyway. I didn’t know you could have only 1 defer.

The 30 minute defer I had for when the COR pump turns on to wait 30 minutes for the skimmer to turn on.

I cleaned up the coding. So with keeping the 30 minute defer in, should I set:

If Time 08:30 to 21:00 Then ON. To get the skimmer to come at 09:00?
8E2CA688-EC01-4D3F-9275-BBB3F5DB93A3.png
 

jassermd

Well-Known Member
View Badges
Joined
Oct 22, 2020
Messages
573
Reaction score
810
Location
Southlake
Rating - 0%
0   0   0
Yes sir.
The defer will be triggered when you set the outlet to “auto” so 8:30 is correct.
You could bypass the “defer” if you ever needed to by turning the outlet “on” and then putting it back to “auto” afterward.
 

Creating a strong bulwark: Did you consider floor support for your reef tank?

  • I put a major focus on floor support.

    Votes: 60 39.7%
  • I put minimal focus on floor support.

    Votes: 34 22.5%
  • I put no focus on floor support.

    Votes: 51 33.8%
  • Other.

    Votes: 6 4.0%
Back
Top