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
What state or country do you live in
Kansas
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.
 
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"
 
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
 
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.
 
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.
 
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?
 
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.
 
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.
 
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
 
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
 
And it did, thank you for your help. I'm not good with scripting and programming, ha!
 

IF YOU HAD TO TAKE A REEFING EXAM, WOULD YOU PASS?

  • Yes!

    Votes: 32 45.7%
  • Not yet, but I have one that I want to buy in mind!

    Votes: 9 12.9%
  • No.

    Votes: 26 37.1%
  • Other (please explain).

    Votes: 3 4.3%

New Posts

Back
Top