float switch besides ato for outlet control

dmsc2fs

Active Member
View Badges
Joined
Dec 29, 2021
Messages
449
Reaction score
543
Location
Charleston
Rating - 0%
0   0   0
This worked good; however, I had to make a few changes.

The 1st issue I ran into is that I don't believe touch will create a directory. The 2nd issue is that swatchdog does not appear to start without something in the config. I tested a number of times and this should solve that problem. I just entered 'time server' since anyone that follows the reef-pi instructions should have a time server running and I wanted to move on. I think you could just watchfor / / (nothing?) and it might work. I wanted to move on and once swatchdog would start I didn't look back.

Screenshot 2023-05-01 070148.png


The last thing I noted is that it appears that a float sensor and an optical sensor may not report the same?


Screenshot 2023-05-01 070516.png


The 'ATO water leve'l is an optical sensor. note that it reports usage not state. Also a few extra spaces in the syslog entry.


Screenshot 2023-05-01 070422.png


This is great stuff and I think it can fill a gap with how I wish to use reef-pi.
 
OP
OP
bishoptf

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,345
Reaction score
1,722
Location
Missouri
Rating - 0%
0   0   0
This worked good; however, I had to make a few changes.

The 1st issue I ran into is that I don't believe touch will create a directory. The 2nd issue is that swatchdog does not appear to start without something in the config. I tested a number of times and this should solve that problem. I just entered 'time server' since anyone that follows the reef-pi instructions should have a time server running and I wanted to move on. I think you could just watchfor / / (nothing?) and it might work. I wanted to move on and once swatchdog would start I didn't look back.

Screenshot 2023-05-01 070148.png


The last thing I noted is that it appears that a float sensor and an optical sensor may not report the same?


Screenshot 2023-05-01 070516.png


The 'ATO water leve'l is an optical sensor. note that it reports usage not state. Also a few extra spaces in the syslog entry.


Screenshot 2023-05-01 070422.png


This is great stuff and I think it can fill a gap with how I wish to use reef-pi.
Yeah I do not think I ever tried starting without an expression, they may check for that etc...Sorry I meant to post part 2 last night but one of the businesses I support, well I made some changes and was unable to vpn back in and so I got wrapped around the axle .

I've never played with optical sensors, so I've never seen the log output. I read at one time they were even less reliable than floats so I have only played with floats. I guess whats important is if there is something found in the logs swatchdog can take whatever action you would like and thats pretty powerful.

I will post part 2 so we at least have a rough how to...
 
OP
OP
bishoptf

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,345
Reaction score
1,722
Location
Missouri
Rating - 0%
0   0   0
Part 2 for SwatchDog Automation, now that we have Swatchdog installed and looking for certain expressions real time in the log we can do many things, we can log stuff, execute commands, send email and LOTS more.

For my use case I want to turn an outlet off and send an email notification so lets look and see how we would do that. @Ranjib as usual has done a great job on the coding side and has provided a restful api integration, basically everything that you can do via the web interface can be done through the api, so lets dive into that. I don't think many realize the power they have if they need it to do something outside the UI and it may be over many head but if your comfortable on cli interface it allows you to leverage your reef-pi in many ways.

Here is the first site that will get you going - https://reef-pi.github.io/additional-documentation/open-api/ I actually do not know if this is the latest api documentation but its a good place to start. Here is the full api documentation for reef-pi - https://reef-pi.github.io/api.html

As the first site describes, using the api requires authentication like you logging into the web interface and that requires a session cookie/token. Once you have that session token you need to guard it and ensure you keep it somewhere that only your userid and root has access to since with that token anyone can also do stuff to your reef-pi instance, lol.

Lets brake down getting that session cookie:

Code:
curl -X POST -c cookie.txt -d '{"user":"reef-pi", "password":"reef-pi"}' http://reef-pi.local/auth/signin

I think most is self explanatory, you need to provide your username and password and the other is you need to provide the destination IP or hostname (reef-pi.local). Now that command will work if you are not using TLS (SSL) for your instance, if you are using TLS then that command will fail due to the self signed cert, to bypass the cert here is the command:

Code:
curl -X POST -c cookie.txt -d '{"user":"reef-pi", "password":"reef-pi"}' -k https://reef-pi.local/auth/signin

Once you have completed that command that should download/create your session cookie in the directory that the command was issued from, again note the permissions on the file and make sure world cannot access that file. something like this etc

Code:
chmod 640 cookie.txt

That will remove the world permissions, yeah it's being paranoid but still should do it. :)

Now that you have the session cookie the world is your oyster via the reef-pi api, the second example shows how to get the output of all the equipment defined:

Code:
curl -b cookie.txt http://reef-pi.local/api/equipment

Here is the output of that command for me:

Screenshot at 2023-05-01 08-20-37.png


Looks messy but if you look closely you will see the details and the individual sections for each piece of equipment that you have defined, for instance for me I name my outlets (I am using a dj power strip so I name them dj1, dj2...plus a name. So here are the details for one of my outlets:

Code:
{"id":"10","name":"dj1","outlet":"10","on":false,"stay_off_on_boot":true}

That controls my dj outlet 1, its reef-pi id is 10 and currently its off (on:false) and its configured to stay off on boot. pretty cool stuff. Now that you know what id you want to do stuff you can go to that second api documentation and do anything that you want - https://reef-pi.github.io/api.html#operation/equipmentControl for me I want to control a piece of equipment so to turn it off/on I can issue this command:


Code:
curl -b /home/bishop/reefpi-api/cookie.txt -d '{"on":false}' -k https://atollpi/api/equipment/15/control

Keep in mind when testing to use an outlet that your not currently not open, I put in a night light that i could turn on/off so I could see results. This is basically different from the initial command, you provide the path to the cookie but to control things you need to pass more statements with the -d option. With that option you can control or cahnge any of the parameters for that piece of the equipment, again all of the options are detailed in the api documentation. For my example that would turn the outlet off, if I issued this command it would turn it on:

Code:
curl -b /home/bishop/reefpi-api/cookie.txt -d '{"on":true}' -k https://atollpi/api/equipment/17/control

That pretty much is the primer for the api, its really powerful and allows you to do anything from the cli that you could do with the web interface, part three will be putting it together with swatchdog and allowing you to control equipment etc that way...:)
 

dmsc2fs

Active Member
View Badges
Joined
Dec 29, 2021
Messages
449
Reaction score
543
Location
Charleston
Rating - 0%
0   0   0
The 'ATO water leve'l is an optical sensor. note that it reports usage not state. Also a few extra spaces in the syslog entry.
I need to amend my previous comments. I would guess usage is tracking "usage" to monitor for graphs, total time used to trigger the extended use off, and other such things. The optical sensor is the same as a float and has both a usage and state. ATO = Float sensor ATO water level = Optical sensor.

Code:
May  2 05:04:35 newboots reef-pi[19829]: 2023/05/02 05:04:35 ato-subsystem: sensor: ATO water level state: 1
May  2 05:04:35 newboots reef-pi[19829]: 2023/05/02 05:04:35 ato-subsystem: sensor: ATO water level  usage: 0
May  2 05:04:37 newboots reef-pi[19829]: 2023/05/02 05:04:37 ato-subsystem: sensor: ATO state: 1
May  2 05:04:38 newboots reef-pi[19829]: 2023/05/02 05:04:38 ato-subsystem: sensor: ATO  usage: 0
~
 

dmsc2fs

Active Member
View Badges
Joined
Dec 29, 2021
Messages
449
Reaction score
543
Location
Charleston
Rating - 0%
0   0   0
I was able to get a bit further.

swatchdog-patterns.cfg
Code:
#First Entry
watchfor /time server/



watchfor /ATO water level state: 1/
           exec curl -b /home/dm/auto-pi/cookie.txt -d '{"off":true}' -k http://newboots/api/equipment/26/control
watchfor /ATO water level state: 0/
           exec curl -b /home/dm/auto-pi/cookie.txt -d '{"on":true}' -k http://newboots/api/equipment/26/control

Now I'm stuck on the telemetry and sending an email.
 
Last edited:

dmsc2fs

Active Member
View Badges
Joined
Dec 29, 2021
Messages
449
Reaction score
543
Location
Charleston
Rating - 0%
0   0   0
I ran out of time for the day but I was able to get postfix working for mail, now I just need to figure out how to disable the ATO after a message so that swatchguard doesn't spam my inbox. This didn't work.

Code:
watchfor /ATO water level state: 1/
           exec curl -b /home/dm/auto-pi/cookie.txt -d '{"off":true}' -k http://newboots/api/equipment/26/control
#           [email protected],subject="Fill ATO Container"
#          exec curl -b /home/dm/auto-pi/cookie.txt -d '{"enable":false}' -k http://newboots/api/atos/13/control
 
OP
OP
bishoptf

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,345
Reaction score
1,722
Location
Missouri
Rating - 0%
0   0   0
I ran out of time for the day but I was able to get postfix working for mail, now I just need to figure out how to disable the ATO after a message so that swatchguard doesn't spam my inbox. This didn't work.

Code:
watchfor /ATO water level state: 1/
           exec curl -b /home/dm/auto-pi/cookie.txt -d '{"off":true}' -k http://newboots/api/equipment/26/control
#           [email protected],subject="Fill ATO Container"
#          exec curl -b /home/dm/auto-pi/cookie.txt -d '{"enable":false}' -k http://newboots/api/atos/13/control
Ha, I haven't made it that far but I think what you want to look at is thresholds, used to be called throttle but I think that is how you accomplish that. Guess I really do not have to do part three since you have it working. :)

I didnt use postfix, to much work, I used ssmtp instead, either way you can get mail working.

Here is the snippet from the man page:
Code:
threshold track_by=key, type=<limit|threshold|both, count=number, seconds=number>
Thresholding can be done for the complete watchfor block and/or for individual actions. Add "threshold=on" as an option along with the other threshold options when thresholding an individual action.
track_by
The value of this should be something that is unique to the watchfor regular expression. Tip: enclose unique parts of the regular expression in parentheses, then use the sub matches as part of the value (e.g. track_by="$2:$4").
type
There are three types of thresholding. They are as follows:
limit
Perform action(s) for the first "count" matches during the time interval specified by "seconds", then ignore events for the rest of the time interval (kind of like throttle)
threshold
Perform action(s) on each match for up to count matches during the time interval specified by seconds
both
Perform actions(s) once per time interval after "count" matches occur, then ignore additional matches during the time interval specified by "seconds"

Example: threshold track_by="foo",type=limit,count=1,seconds=900

Here is the Swatchdog Github site - https://github.com/ToddAtkins/swatchdog and one more thing, it appears that its not actively being maintained so if you find a bug etc, it probably will never be fixed. So far from what I have seen it appears to do what I am wanting to do.
 
Last edited:

dmsc2fs

Active Member
View Badges
Joined
Dec 29, 2021
Messages
449
Reaction score
543
Location
Charleston
Rating - 0%
0   0   0
Ha, I haven't made it that far but I think what you want to look at is thresholds, used to be called throttle but I think that is how you accomplish that. Guess I really do not have to do part three since you have it working. :)

I didnt use postfix, to much work, I used ssmtp instead, either way you can get mail working.

Here is the snippet from the man page:
Code:
threshold track_by=key, type=<limit|threshold|both, count=number, seconds=number>
Thresholding can be done for the complete watchfor block and/or for individual actions. Add "threshold=on" as an option along with the other threshold options when thresholding an individual action.
track_by
The value of this should be something that is unique to the watchfor regular expression. Tip: enclose unique parts of the regular expression in parentheses, then use the sub matches as part of the value (e.g. track_by="$2:$4").
type
There are three types of thresholding. They are as follows:
limit
Perform action(s) for the first "count" matches during the time interval specified by "seconds", then ignore events for the rest of the time interval (kind of like throttle)
threshold
Perform action(s) on each match for up to count matches during the time interval specified by seconds
both
Perform actions(s) once per time interval after "count" matches occur, then ignore additional matches during the time interval specified by "seconds"

Example: threshold track_by="foo",type=limit,count=1,seconds=900

Here is the Swatchdog Github site - https://github.com/ToddAtkins/swatchdog
oh, I think you are right. i didn't think of looking at controlling swatchdog. This will allow for keeping the ATO enabled and will also enable follow up email when you keep ignoring them and don't fill your ATO!
 
OP
OP
bishoptf

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,345
Reaction score
1,722
Location
Missouri
Rating - 0%
0   0   0
oh, I think you are right. i didn't think of looking at controlling swatchdog. This will allow for keeping the ATO enabled and will also enable follow up email when you keep ignoring them and don't fill your ATO!

The manpage lists also:
threshold
Perform action(s) on each match for up to count matches during the time
interval specified by seconds
Thats similar to what @Ranjib does in the reef-pi code, allows you to throttle the emails to 1 or 2 per hour etc...
 

dmsc2fs

Active Member
View Badges
Joined
Dec 29, 2021
Messages
449
Reaction score
543
Location
Charleston
Rating - 0%
0   0   0
UPDATE: BOOO!!! I thought it was done!

It looks like this isn't quite working yet.

If I pass this in at the command line it works.
Code:
curl -b /home/dm/auto-pi/cookie.txt -d '{"id":"12","is_macro":false,"inlet":"6","pump":"23","period":3,"control":true,"enable":true,"notify":{"enable":false,"max":60},"name":"ATO","disable_on_alert":true,"one_shot":false}' -k http://newboots/api/atos/12


If I try it in swatchdog it doesn't
Code:
watchfor /ATO water level state: 1/
  exec curl -b /home/dm/auto-pi/cookie.txt -d '{"id":"12","is_macro":false,"inlet":"6","pump":"23","period":3,"control":true,"enable":true,"notify":{"enable":false,"max":60},"name":"ATO","disable_on_alert":true,"one_shot":false}' -k http://newboots/api/atos/12

Code:
May  3 05:55:13 newboots systemd[1]: swatchdog.service: Succeeded.
May  3 05:55:13 newboots systemd[1]: swatchdog.service: Consumed 1.187s CPU time.
May  3 05:55:18 newboots swatchdog[11141]: sh: 1: Syntax error: Unterminated quoted string
May  3 05:55:28 newboots swatchdog[11142]: sh: 1: Syntax error: Unterminated quoted string
May  3 05:55:38 newboots swatchdog[11143]: sh: 1: Syntax error: Unterminated quoted string
May  3 05:55:48 newboots swatchdog[11144]: sh: 1: Syntax error: Unterminated quoted string


---

I think I have this knocked out. I did some testing and now it's either wait for my ATO to empty or pull some water out. One takes action, one doesn't. So I guess we will wait and see :)

This should monitor for the water level in the ATO. When my sensor triggers low it turns on a LED and starts to email me. If I ignore the email for long enough the ATO pump will turn off.

The water level sensor will turn on when I have 1 - 1.5 gallons left in my ATO so i'm not terribly concerned if it takes some time for me to disable the ATO pump. The red LED will be enough of a nag that I won't ignore it for very long when I am home.

Once the ATO if filled again the LED will turn off and the ATO will turn on.

Update: I decided I should probably turn off the ATO pump as well as the ATO. You know, just in case it happens to be running when I disable the ATO.

Code:
watchfor /ATO water level state: 1/
           threshold track_by=$3,type=limit,count=1,seconds=600
           #Turn off red LED
           exec curl -b /home/dm/auto-pi/cookie.txt -d '{"on":false}' -k http://newboots/api/equipment/26/control
           #Turn on ATO
           exec curl -b /home/dm/auto-pi/cookie.txt -d '{"id":"12","is_macro":false,"inlet":"6","pump":"23","period":3,"control":true,"enable":true,"notify":{"enable":false,"max":60},"name":"ATO","disable_on_alert":true,"one_shot":false}' -k http://newboots/api/atos/12

watchfor /ATO water level state: 0/
           threshold track_by=$1,type=limit,count=1,seconds=600
           #Turn on red LED
           exec curl -b /home/dm/auto-pi/cookie.txt -d '{"on":true}' -k http://newboots/api/equipment/26/control
           #send reminder
           [email protected],subject="Fill ATO Container"
           exec echo "nemoj me ignorisati"

watchfor /nemoj me ignorisati/
           threshold track_by=$2,type=both,count=3,seconds=3000
           #Turn on red LED
           exec curl -b /home/dm/auto-pi/cookie.txt -d '{"on":true}' -k http://newboots/api/equipment/26/control
           [email protected],subject="ATO Pump Disabled"
           #Turn off ATO
           exec curl -b /home/dm/auto-pi/cookie.txt -d '{"id":"12","is_macro":false,"inlet":"6","pump":"23","period":3,"control":true,"enable":false,"notify":{"enable":false,"max":60},"name":"ATO","disable_on_alert":true,"one_shot":false}' -k http://newboots/api/atos/12
           #Make sure the pump is not actually ON right now!
           exec curl -b /home/dm/auto-pi/cookie.txt -d '{"on:false}' -k http://newboots/api/equipment/23/control
 
Last edited:

dmsc2fs

Active Member
View Badges
Joined
Dec 29, 2021
Messages
449
Reaction score
543
Location
Charleston
Rating - 0%
0   0   0
I guess I fixed it too late to edit my post. Problem has been resolved.

Based on this knownbug

Code:
- There are 2 configuration file parsing bugs:

    1) Backticking quotes (\") in action option values causes erroneous
    script production.

    2) Commas in action option values confuses the parser.

I moved the ATO updates into variables. It appears to be working correctly this time. I updated my ATO a number of times in both direction.

Code:
root@newboots:/home/dm# vi /etc/swatchdog/swatchdog_patterns.cfg
perlcode my $ATO_on =  '\'{"id":"12","is_macro":false,"inlet":"6","pump":"23","period":3,"control":true,"enable":true,"notify":{"enable":false,"max":60},"name":"ATO","disable_on_alert":true,"one_shot":false}\'';
perlcode my $ATO_off =  '\'{"id":"12","is_macro":false,"inlet":"6","pump":"23","period":3,"control":true,"enable":false,"notify":{"enable":false,"max":60},"name":"ATO","disable_on_alert":true,"one_shot":false}\'';


# Perform action(s) after each count number of matches during the time interval specified by seconds

watchfor /ATO water level state: 1/
           #Turn off red LED
           exec curl -b /home/dm/auto-pi/cookie.txt -d '{"on":false}' -k http://newboots/api/equipment/26/control
           #Turn on ATO
           exec curl -b /home/dm/auto-pi/cookie.txt -d $ATO_on -k http://newboots/api/atos/12



watchfor /ATO water level state: 0/
           threshold track_by=$1,type=limit,count=1,seconds=600
           #Turn on red LED
           exec curl -b /home/dm/auto-pi/cookie.txt -d '{"on":true}' -k http://newboots/api/equipment/26/control
           #send reminder
           [email protected],subject="Fill ATO Container"
           exec echo "nemoj me ignorisati"

watchfor /nemoj me ignorisati/
           threshold track_by=$2,type=both,count=3,seconds=3000
           #Turn on red LED
           exec curl -b /home/dm/auto-pi/cookie.txt -d '{"on":true}' -k http://newboots/api/equipment/26/control
           [email protected],subject="ATO Pump Disabled"
           #Turn off ATO
           exec curl -b /home/dm/auto-pi/cookie.txt -d $ATO_off -k http://newboots/api/atos/12
           #Turn off ATO Pump
           exec curl -b /home/dm/auto-pi/cookie.txt -d '{"on":false}' -k http://newboots/api/equipment/23/control
 
OP
OP
bishoptf

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,345
Reaction score
1,722
Location
Missouri
Rating - 0%
0   0   0
I guess I fixed it too late to edit my post. Problem has been resolved.

Based on this knownbug

Code:
- There are 2 configuration file parsing bugs:

    1) Backticking quotes (\") in action option values causes erroneous
    script production.

    2) Commas in action option values confuses the parser.

I moved the ATO updates into variables. It appears to be working correctly this time. I updated my ATO a number of times in both direction.

Code:
root@newboots:/home/dm# vi /etc/swatchdog/swatchdog_patterns.cfg
perlcode my $ATO_on =  '\'{"id":"12","is_macro":false,"inlet":"6","pump":"23","period":3,"control":true,"enable":true,"notify":{"enable":false,"max":60},"name":"ATO","disable_on_alert":true,"one_shot":false}\'';
perlcode my $ATO_off =  '\'{"id":"12","is_macro":false,"inlet":"6","pump":"23","period":3,"control":true,"enable":false,"notify":{"enable":false,"max":60},"name":"ATO","disable_on_alert":true,"one_shot":false}\'';


# Perform action(s) after each count number of matches during the time interval specified by seconds

watchfor /ATO water level state: 1/
           #Turn off red LED
           exec curl -b /home/dm/auto-pi/cookie.txt -d '{"on":false}' -k http://newboots/api/equipment/26/control
           #Turn on ATO
           exec curl -b /home/dm/auto-pi/cookie.txt -d $ATO_on -k http://newboots/api/atos/12



watchfor /ATO water level state: 0/
           threshold track_by=$1,type=limit,count=1,seconds=600
           #Turn on red LED
           exec curl -b /home/dm/auto-pi/cookie.txt -d '{"on":true}' -k http://newboots/api/equipment/26/control
           #send reminder
           [email protected],subject="Fill ATO Container"
           exec echo "nemoj me ignorisati"

watchfor /nemoj me ignorisati/
           threshold track_by=$2,type=both,count=3,seconds=3000
           #Turn on red LED
           exec curl -b /home/dm/auto-pi/cookie.txt -d '{"on":true}' -k http://newboots/api/equipment/26/control
           [email protected],subject="ATO Pump Disabled"
           #Turn off ATO
           exec curl -b /home/dm/auto-pi/cookie.txt -d $ATO_off -k http://newboots/api/atos/12
           #Turn off ATO Pump
           exec curl -b /home/dm/auto-pi/cookie.txt -d '{"on":false}' -k http://newboots/api/equipment/23/control
Glad you were able to get it working, I know it is doing what I need for my situation. I will say I did something on one of my other tanks similar to what you are doing here. I have an ATO circuit that has a single led in it and when the float gets low it lights the led and sends me an email so that is possible without swatchdog but with swatchdog and the API there is a lot of capability here to fill in some gaps when needed.

Another bug that I believe is similar to the one you found, I was exec echo comments and had a comma in statement and it had issues with that so I just removed the commas.

One last thing, I think I covered it in my initial how to set up as a service, but be sure you enable the systemd service so it works across reboots -
Code:
sudo systemctl enable swatchdog.service (or whatever you named it)

:)

Oops one more thing to note, in your exec statements at least in your case you do not need the "-k" option for the http call, you only need the "-k" when using TLS (https) so it ignores the self signed certs. Should work fine without the "-k" but is not going to hurt anything either way, just wanted to clarify.
 
Last edited:

dmsc2fs

Active Member
View Badges
Joined
Dec 29, 2021
Messages
449
Reaction score
543
Location
Charleston
Rating - 0%
0   0   0
Glad you were able to get it working, I know it is doing what I need for my situation. I will say I did something on one of my other tanks similar to what you are doing here. I have an ATO circuit that has a single led in it and when the float gets low it lights the led and sends me an email so that is possible without swatchdog but with swatchdog and the API there is a lot of capability here to fill in some gaps when needed.

Another bug that I believe is similar to the one you found, I was exec echo comments and had a comma in statement and it had issues with that so I just removed the commas.

One last thing, I think I covered it in my initial how to set up as a service, but be sure you enable the systemd service so it works across reboots -
Code:
sudo systemctl enable swatchdog.service (or whatever you named it)

:)

Oops one more thing to note, in your exec statements at least in your case you do not need the "-k" option for the http call, you only need the "-k" when using TLS (https) so it ignores the self signed certs. Should work fine without the "-k" but is not going to hurt anything either way, just wanted to clarify.
Thank you for the feedback. I wouldn't of thought of even going down this road.
As for the code. I do it right because I do it twice.
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Another idea I had if one wanted to do it differently:
Connect your float switch signal (ideally an optical one, or a mechanical one with an additional resistor to GND) to an AnalogInput port.
That way you get the signal in the pH Tab, where you could use the „raising“ and „lowering“ mechanisms to switch the pump and notify.

@Ranjib might be an interesting idea to be able to make a normal GPIO Pin an AnalogInput. It only has two states, but a few different options for control mechanisms in the pH tab.
 
Last edited:
OP
OP
bishoptf

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,345
Reaction score
1,722
Location
Missouri
Rating - 0%
0   0   0
Another idea I had if one wanted to do it differently:
Connect your float switch signal (ideally an optical one, or a mechanical one with an additional resistor to GND) to an AnalogInput port.
That way you get the signal in the pH Tab, where you could use the „raising“ and „lowering“ mechanisms to switch the pump and notify.

@Ranjib might be an interesting idea to be able to make a normal GPIO Pin an AnalogInput. It only has two states, but a few different options for control mechanisms in the pH tab.
I actually thought about that originally but wasn't sure which driver to use but now that I think about it you would just use the raspberry pi driver. I am using several analog inputs for monitoring the energy for return and wave pumps, will see how it works.

Update, Just looked at it again and there is no driver that will allow you to select the pin number, at least not that I see. The driver needs to expose the pins and in case of the raspberry pi driver no pins are exposed. Unless there is a different driver that I should be using, I do agree though that this would work for what I am wanting to do and be much cleaner.
 
Last edited:

LJLKRL05

Active Member
View Badges
Joined
Oct 12, 2016
Messages
332
Reaction score
230
Rating - 0%
0   0   0
autotopoff.com has a float switch for an ato and a kill switch to prevent overflow. You just want the kill switch. It controls an outlet.
 
OP
OP
bishoptf

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,345
Reaction score
1,722
Location
Missouri
Rating - 0%
0   0   0
autotopoff.com has a float switch for an ato and a kill switch to prevent overflow. You just want the kill switch. It controls an outlet.
Yeah all of that stuff works well for a normal ATO defined port in reef-pi but what some of us would like to do is use a float switch and not have the pump usage tied to it, so basically we are wanting to use a float switch and just record on/off position and then do things based on that. @Sral has pointed out that the analog input would be an option if we had a way to define the gpio port that we are wanting to watch.
 

LJLKRL05

Active Member
View Badges
Joined
Oct 12, 2016
Messages
332
Reaction score
230
Rating - 0%
0   0   0
Yeah all of that stuff works well for a normal ATO defined port in reef-pi but what some of us would like to do is use a float switch and not have the pump usage tied to it, so basically we are wanting to use a float switch and just record on/off position and then do things based on that. @Sral has pointed out that the analog input would be an option if we had a way to define the gpio port that we are wanting to watch.
Ok, I understand now. Makes perfect sense.
 

BeanAnimal

2500 Club Member
View Badges
Joined
Jul 16, 2009
Messages
3,233
Reaction score
4,884
Rating - 0%
0   0   0
Maybe I'm tired but I have a new build that is an AIO and what I wanted to do was have a float switch mounted low in the return section that if the float ever was triggered it was shut the return pump off
Ignoring they notify part -

You can't do this with a single float switch without logic, be it a controller, latching relay or some other method to KEEP the return pump off once triggered.

What happens with a single float switch -

1 - Water evaporates and sump runs lows.
2 - float switch triggers
3 - pump turns off and water drains back into the sump from the display
4 - pump rises slightly and turns back on, pumping water out of sump.
5 - float drops and turns pump off
6 - water drains back from display, causing water in sump to slightly rise...

Over and over until the pump or float switch burn out or you find it cycling on and off every few seconds.

I know nothing about reef-pi but you need either two floats and latching circuit (software in reef-pi or hardware relay latch) or a one-shot type of trigger that stays "set" once triggered.
 

When to mix up fish meal: When was the last time you tried a different brand of food for your reef?

  • I regularly change the food that I feed to the tank.

    Votes: 22 29.7%
  • I occasionally change the food that I feed to the tank.

    Votes: 27 36.5%
  • I rarely change the food that I feed to the tank.

    Votes: 19 25.7%
  • I never change the food that I feed to the tank.

    Votes: 5 6.8%
  • Other.

    Votes: 1 1.4%
Back
Top