Turning on and off an outlet based on sensor state

CoryZipperle

Community Member
View Badges
Joined
Feb 10, 2022
Messages
53
Reaction score
21
Location
Topeka
Rating - 0%
0   0   0
I have an optical sensor in my sump called "DISPLV." It has two states: open / closed.

Is it possible to program an outlet to turn on when the sensor is open?

I can't seem to work this one out.
 
OP
OP
CoryZipperle

CoryZipperle

Community Member
View Badges
Joined
Feb 10, 2022
Messages
53
Reaction score
21
Location
Topeka
Rating - 0%
0   0   0
In whatever outlet you want to turn on/off put this line of code:

If DISPLV = open then on

Simple as that.

Sorry, I left out some information:

When doing some testing, I created the following line:

If Output DispLv = Closed Then OFF

The text "Displv" stays gray, and if I attempt to save the config I get an error:

"//Error: line 2 - No such output name // If Output Displv = ON Then OFF"
 

homer1475

Figuring out the hobby one coral at a time.
View Badges
Joined
Apr 24, 2018
Messages
11,820
Reaction score
18,897
Location
Way upstate NY
Rating - 0%
0   0   0
There is no output command, or in apex's brain there is no outlet(output) named DispLv.

The proper syntax for a switch is just the "switch name = closed/open then off/on"

If DispLv = closed then off
 
OP
OP
CoryZipperle

CoryZipperle

Community Member
View Badges
Joined
Feb 10, 2022
Messages
53
Reaction score
21
Location
Topeka
Rating - 0%
0   0   0
I see, I was trying to treat it like an outlet. Ha!

But now, there's this:

Here's my string:

2023-02-24_15-05-50.png


Here's what Apex has to say about it:

2023-02-24_15-06-13.png


When composing the line I tried both typing CLOSED and selecting CLOSED from the dropdown that comes up in the editor.

I'm not sure what to do to correct this issue.
 

homer1475

Figuring out the hobby one coral at a time.
View Badges
Joined
Apr 24, 2018
Messages
11,820
Reaction score
18,897
Location
Way upstate NY
Rating - 0%
0   0   0
Sorry my bad, was going from memory. there is no equals sign.

Proper syntax:

If DispLv closed then off

I was thinking of an outlet that has an equals in the syntax. This is a switch, there is no equals sign.
 
OP
OP
CoryZipperle

CoryZipperle

Community Member
View Badges
Joined
Feb 10, 2022
Messages
53
Reaction score
21
Location
Topeka
Rating - 0%
0   0   0
Whats the squiggle line under the equals sign?

I was looking at that too.

The equals sign isn't anything fancy, just putting in a proper equals with my keyboard. Tried copy and paste from your reply and that squggle appears.

I created a line of invalid goop and that squiggle appears:

2023-02-24_15-20-31.png


Opening up an outlet to see what's there, I don't have a squiggle under the equals sign:

1677273776379.png


For fun, I created a line that's not valid, this is what Apex puts back:

1677273858175.png


If I put in just "=" then:

1677273887233.png


Thoughts?
 

homer1475

Figuring out the hobby one coral at a time.
View Badges
Joined
Apr 24, 2018
Messages
11,820
Reaction score
18,897
Location
Way upstate NY
Rating - 0%
0   0   0
See my post above. LOL think you missed it.

There is no = in a switch command

Proper syntax:

if DispLv closed then off


I have the older apex, and it does not do that if something in a line doesn't belong. The squiggle is telling you it doesn't belong.
 
OP
OP
CoryZipperle

CoryZipperle

Community Member
View Badges
Joined
Feb 10, 2022
Messages
53
Reaction score
21
Location
Topeka
Rating - 0%
0   0   0
See my post above. LOL think you missed it.

There is no = in a switch command

Proper syntax:

if DispLv closed then off


I have the older apex, and it does not do that if something in a line doesn't belong. The squiggle might be telling you it doesn't belong?

Ya, you caught me... wasn't obeying the rules of Apex.
 
OP
OP
CoryZipperle

CoryZipperle

Community Member
View Badges
Joined
Feb 10, 2022
Messages
53
Reaction score
21
Location
Topeka
Rating - 0%
0   0   0
So, this is what I really want to do:

If DispLv OPEN then ON - I only want it to stay ON for 60-seconds.

What's happening is that if the water level in the tank opens the optical sensor, I want to turn on an outlet for 60 seconds. So is this what I want?

Code:
Set OFF
If DispLv OPEN then ON
Defer 001:00 then OFF
 

homer1475

Figuring out the hobby one coral at a time.
View Badges
Joined
Apr 24, 2018
Messages
11,820
Reaction score
18,897
Location
Way upstate NY
Rating - 0%
0   0   0
So, this is what I really want to do:

If DispLv OPEN then ON - I only want it to stay ON for 60-seconds.

What's happening is that if the water level in the tank opens the optical sensor, I want to turn on an outlet for 60 seconds. So is this what I want?

Code:
Set OFF
If DispLv OPEN then ON
Defer 001:00 then OFF
That will work
 
Back
Top