reef-pi :: An opensource reef tank controller based on Raspberry Pi.

drbogger

Active Member
View Badges
Joined
Apr 24, 2019
Messages
165
Reaction score
132
Location
Ballston Spa, New York
Rating - 0%
0   0   0
- The check frequency is 120 seconds.

- I tried the macro in reverse, and forward mode.

- it takes about an hour to fill, but it won't start filling unless the macro turns on the other ATO sensor (which it never does).

- how do I get the logs?

- the macro works fine if I run it manually or by using a timer. Seems to be just the ATO controller causing the issue.

- It's not a full system hang, the UI will still load, but it won't let me edit the ATO settings until I delete the Macro & ATO entirely, then I have to reload reef-pi twice (yes, twice).

The macro just never runs. It just hangs until I delete it.

@Ranjib any ideas on my ATO/Macro issue?
 

Boostable

Active Member
View Badges
Joined
May 17, 2011
Messages
227
Reaction score
154
Location
Lake Mary, FL
Rating - 0%
0   0   0
Want to talk dosing and power outages, I've got to scenarios that I am looking at and I want to make sure they are solid or as good as I can get. I have one reefpi running a dosing unit and is configured under the doser tab, runs every hour for about 15sec. I have another reefpi that is controlling BRS dosers that are controlled by a timer or a Macro. I've seen the question ask before but I want to verify that timers with an on/off scheduled behave. If I am running the BRS doser, currently I have one running for 9min, if I loose power during that time frame and it stays off for 30min etc, what will the state be when power is restored? To make sure its clear, I kick off a timer for x minutes, halfway during I loose power, power is off for 30min or more and then restored. Reefpi boots back up, will the timer that had started turn off since the time has passed?

I know if you are running a macro and you have a wait state then it would loose that state, but what about a standard timer? What happens to the state for a doser that was running when a power outage strikes?

I can think of creating a timer that runs every minute outside of your dosing timer to turn the pump back off but that seems like a lot of work, but I'd rather not have a pump that is running constantly after power returns.

Thanks :)
Tom,

I think you are correct in your thinking and unless things have changed in regards to the way states are written to the DB, it will restart in an open or active state and run your dosing pump. Scary stuff...

Really need a default state option to be sure things reset themselves. Perhaps the the timer/macro option could write to a temp table outside of the DB or a simple file while they are running and clean it up after completion.

Perhaps I am wrong but I don't recall seeing any changes to the way or when states are written.
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,349
Reaction score
1,724
Location
Missouri
Rating - 0%
0   0   0
Tom,

I think you are correct in your thinking and unless things have changed in regards to the way states are written to the DB, it will restart in an open or active state and run your dosing pump. Scary stuff...

Really need a default state option to be sure things reset themselves. Perhaps the the timer/macro option could write to a temp table outside of the DB or a simple file while they are running and clean it up after completion.

Perhaps I am wrong but I don't recall seeing any changes to the way or when states are written.
I know macro's are not the way to go but I thought that timers were different, just want to verify how they should operate if a timer kicks off and then you loose power past when the off timer would execute. Kind of wondering about the Doser routines also, the window for my dosers are much smaller since they are much faster.

Yeah automation also comes with pitfalls, just trying to figure out now how to make it as resilient as I can get it, not sure how the Apex would handle the same event. Not sure how the states are written and how it handles a state that was missed like a timer that should have gone off but was powered off. I have a spare PI and some hardware to test but sheesh so little time, lol.

I found this thread from last month and it seems to imply that timers would work properly but just wanting to verify and see how that applies to the dosing section, Timers

And to be clear I have 2 timers, one ON timer at 1200 and an OFF timer at 1209, if I loose power say at 1205 and then power comes back on at 1220, will the equipment keep running or turn off or stay off? I would like to know how that same scenario would apply to a dosing cron job.

Thanks :)
 
Last edited:

Boostable

Active Member
View Badges
Joined
May 17, 2011
Messages
227
Reaction score
154
Location
Lake Mary, FL
Rating - 0%
0   0   0
I know macro's are not the way to go but I thought that timers were different, just want to verify how they should operate if a timer kicks off and then you loose power past when the off timer would execute. Kind of wondering about the Doser routines also, the window for my dosers are much smaller since they are much faster.

Yeah automation also comes with pitfalls, just trying to figure out now how to make it as resilient as I can get it, not sure how the Apex would handle the same event. Not sure how the states are written and how it handles a state that was missed like a timer that should have gone off but was powered off. I have a spare PI and some hardware to test but sheesh so little time, lol.

I found this thread from last month and it seems to imply that timers would work properly but just wanting to verify and see how that applies to the dosing section, Timers

:)
I hear ya... I am the same, I need backups for my backups, lol I run the the Pi on a UPS and was thinking about using a simple relay to monitor power in a hold open state and tie that to an input on the pi and have it trigger a macro to change all my outlets to default states should power fail. I have not tested this yet, but seems like it should work and at least give me the proper conditions once power is restored. Thoughts?
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,349
Reaction score
1,724
Location
Missouri
Rating - 0%
0   0   0
I hear ya... I am the same, I need backups for my backups, lol I run the the Pi on a UPS and was thinking about using a simple relay to monitor power in a hold open state and tie that to an input on the pi and have it trigger a macro to change all my outlets to default states should power fail. I have not tested this yet, but seems like it should work and at least give me the proper conditions once power is restored. Thoughts?

Eh I try to keep things as simple as possible, the more complex you make things the more things can go wrong. What I would like for equipment/outlets would be to have a default state that would be read after a reboot. That way you could set the default state to how you want an outlet set after booting. I guess I can go test and see how it operates...
 

Boostable

Active Member
View Badges
Joined
May 17, 2011
Messages
227
Reaction score
154
Location
Lake Mary, FL
Rating - 0%
0   0   0
Eh I try to keep things as simple as possible, the more complex you make things the more things can go wrong. What I would like for equipment/outlets would be to have a default state that would be read after a reboot. That way you could set the default state to how you want an outlet set after booting. I guess I can go test and see how it operates...
Default state is an absolute must, but we are gonna need some additional fail-safe until then. Simple 1 or 0's right..
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,349
Reaction score
1,724
Location
Missouri
Rating - 0%
0   0   0
Default state is an absolute must, but we are gonna need some additional fail-safe until then. Simple 1 or 0's right..
Just tested the equipment control with separate timers for on and off, set the timer turn on and then had a timer set 2 min later to turn off. When the first timer fired I shutdown reefpi from the OS, and left it off past the off timer. I restored power and it initially came on when things rebooted but as in the other thread about a minute later ( I didn't time it) the outlet turned off. I was watching journalctl and it stated:
Euipment: 6 On: false
that was the outlet controlling the pump and shut it off. So it appears that it does store the default state and returns it to that state on a reboot. I do not have the dosing module set up on my frag tank so I am unable to test it, but my concern on the dosing module is it pumps out much faster and even if it ran for a minute or so that could spike my PH since I am dosing Kalk. Will be interesting to hear from @Ranjib expected behavior for the dosing module, if it works differently than the outlets I will have to purchase a couple more BRS pumps, they are slow @1.1ml/min but for my small tanks that provides more breathing room for things like this.

:)
 
Last edited:

Des Westcott

Well-Known Member
View Badges
Joined
May 29, 2018
Messages
646
Reaction score
1,035
Location
Durban - South Africa
Rating - 0%
0   0   0
Just tested the equipment control with separate timers for on and off, set the timer turn on and then had a timer set 2 min later to turn off. When the first timer fired I shutdown reefpi from the OS, and left it off past the off timer. I restored power and it initially came on when things rebooted but as in the other thread about a minute later ( I didn't time it) the outlet turned off. I was watching journalctl and it stated:

that was the outlet controlling the pump and shut it off. So it appears that it does store the default state and returns it to that state on a reboot. I do not have the dosing module set up on my frag tank so I am unable to test it, but my concern on the dosing module is it pumps out much faster and even if it ran for a minute or so that could spike my PH since I am dosing Kalk. Will be interesting to hear from @Ranjib expected behavior for the dosing module, if it works differently than the outlets I will have to purchase a couple more BRS pumps, they are slow @1.1ml/min but for my small tanks that provides more breathing room for things like this.

:)
I'm following this train of discussion with great interest. I have been thinking about this in general for some time now and been wondering how best to address it. Here in South Africa, we have regular power cuts due to power generation shortfalls. Sometimes up to 3 x sessions of 2 hours a day for up to a week. I've had pi's lose their IP address a few times. I've only recently started using the Dosing feature, but feel the risk of something going wrong while a Doser is dispensing is relatively low in my case. I dose small quantities often throughout the day. I also time the dosing so the chance of being caught in the middle of a dose is less (Our schedules run on the hour) so all my doses happen at minute 25, second 45). None of this will help during an unplanned outage of course, but I feel it's a start.

None of my timers run anything that could dose / add any thing that could cause a problem. My kalk is added through my ATO, so as long as my level is stable, that is fine. Timers control feeding / pump scheduling / certain lights.

However, I have been thinking that a UPS on just the Reef-Pi is a very good idea. Just to keep the Pi alive and stable and to not lose track of things like timers / dosers etc. I also had the idea like mentioned above to monitor the state of a relay to tell if power was on or off and take action. Currently this would have to set up as an ATO with the relay acting as a float switch and then Reef-Pi would have to run a Macro which we know it wont do at the moment. With the Alert feature in Macros you would also be able to get notification of power having gone down as well (Provided your router is still online) - Maybe a small GSM module for this?? I recently came across this sim card deal which might be ideal for this kind of thing. GSM Global Sim - Data for Life - Once-Off Fee (robotics.org.za) I'm sure there are other services like that.

Anyway, I'll be interested to see what ideas come out of this discussion and what the best solutions are, but I think the best two options are 1) keeping the Pi alive for as long as feasible and 2) Making sure Reef-Pi has the failsafes built in or configurable.

And, yes. I know making the suggestions is the easy part. I really do appreciate the people that have to take these suggestions and apply the dark art of writing the code to make it work.
 
Last edited:

Bigtrout

Valuable Member
View Badges
Joined
Dec 16, 2018
Messages
1,189
Reaction score
2,826
Rating - 0%
0   0   0
I'm following this train of discussion with great interest. I have been thinking about this in general for some time now and been wondering how best to address it. Here in South Africa, we have regular power cuts due to power generation shortfalls. Sometimes up to 3 x sessions of 2 hours a day for up to a week. I've had pi's lose their IP address a few times. I've only recently started using the Dosing feature, but feel the risk of something going wrong while a Doser is dispensing is relatively low in my case. I dose small quantities often throughout the day. I also time the dosing so the chance of being caught in the middle of a dose is less (Our schedules run on the hour) so all my doses happen at minute 25, second 45). None of this will help during an unplanned outage of course, but I feel it's a start.

None of my timers run anything that could dose / add any thing that could cause a problem. My kalk is added through my ATO, so as long as my level is stable, that is fine. Timers control feeding / pump scheduling / certain lights.

However, I have been thinking that a UPS on just the Reef-Pi is a very good idea. Just to keep the Pi alive and stable and to not lose track of things like timers / dosers etc. I also had the idea like mentioned above to monitor the state of a relay to tell if power was on or off and take action. Currently this would have to set up as an ATO with the relay acting as a float switch and then Reef-Pi would have to run a Macro which we know it wont do at the moment. With the Alert feature in Macros you would also be able to get notification of power having gone down as well (Provided your router is still online) - Maybe a small GSM module for this?? I recently came across this sim card deal which might be ideal for this kind of thing. GSM Global Sim - Data for Life - Once-Off Fee (robotics.org.za) I'm sure there are other services like that.

Anyway, I'll be interested to see what ideas come out of this discussion and what the best solutions are, but I think the best two options are 1) keeping the Pi alive for as long as feasible and 2) Making sure Reef-Pi has the failsafes built in or configurable.

And, yes. I know making the suggestions is the easy part. I really do appreciate the people that have to take these suggestions and apply the dark art of writing the code to make it work.
This is a great discussion. I take failsafes very seriously because of frequent power and or internet outtages. Some things that help right now in my case:

1. Adding a Real time clock...this allows the pi to keep time if it reboots when the internet is down.

2. Equipment outlets...i used a relay module so I have normally open and normally closed contacts on each relay. If I want something to fail in the ON position if reef pi is down, I wire the outlet to the normally closed contact. If I want it to fail in the OFF position, I wire the outlet to a normally open contact.

3. Redundancy. Dont rely on one system or sensor for very important systems. This also goes along with what i did for equipment outlets. A great example is heaters. Running a heater without a thermostat with reef pi as exclusive control is asking for trouble. I use heaters with thermostats set for 80. They plug into equipment outlets that are wired on normally closed relay contacts. If reef pi fails, heaters work as normal and keep tank at 80. If reef pi is up and running, it controls my heaters and tank runs at 79.

The problem is that some of the other systems that reef pi can control, need some type of failsafe, or ability to set a default state. Things that can be hardwired to achieve this are best served by doing it that way, thinga that can not need some type of setting for a default state.
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,349
Reaction score
1,724
Location
Missouri
Rating - 0%
0   0   0
This is a great discussion. I take failsafes very seriously because of frequent power and or internet outtages. Some things that help right now in my case:

1. Adding a Real time clock...this allows the pi to keep time if it reboots when the internet is down.

2. Equipment outlets...i used a relay module so I have normally open and normally closed contacts on each relay. If I want something to fail in the ON position if reef pi is down, I wire the outlet to the normally closed contact. If I want it to fail in the OFF position, I wire the outlet to a normally open contact.

3. Redundancy. Dont rely on one system or sensor for very important systems. This also goes along with what i did for equipment outlets. A great example is heaters. Running a heater without a thermostat with reef pi as exclusive control is asking for trouble. I use heaters with thermostats set for 80. They plug into equipment outlets that are wired on normally closed relay contacts. If reef pi fails, heaters work as normal and keep tank at 80. If reef pi is up and running, it controls my heaters and tank runs at 79.

The problem is that some of the other systems that reef pi can control, need some type of failsafe, or ability to set a default state. Things that can be hardwired to achieve this are best served by doing it that way, thinga that can not need some type of setting for a default state.
I agree with what both of you are saying and @Bigtrout I am pretty much setup the same way you are, I have 2 strips, one is normally closed and one is normally open, although I am not using a RTC. The problem I have is when outlets are triggered with a timer or the dosing module. So an outlet that is triggered and you loose power after the time has elapsed. When reef-pi comes back online the additional timer will not have fired. Timers appear to work, he must write the default state in the DB and replays them when they come back online, at least that is what my simple one test showed. However I am not sure with the dosing module if it would be the same operation, dosing pump is going, loose power, period of time elapses and power is restored. When reefpi is booted back up will the dosing module continue to dose, I don't want it to but I honestly dont know and I guess I should try and see what happens but i'd have to do it on my main tank and a little leary of doing it, but I guess I should.

:)
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,349
Reaction score
1,724
Location
Missouri
Rating - 0%
0   0   0
Just tested the doser, mine comes on every 5min after the hour, I shut down reefpi during its dosing schedule and it kept running when reefpi was shutdown, scramble to get a container to capture output. I then pulled the power to reefpi which also feeds reef-pi, doser stopped. Note to self, pull power in the future when testing, lol.

When applied power back to reef-pi and it booted up the doser module did not resume, it remained off. This is anecdotal testing and I am running v3.3 and not the latest code so take it for what its worth, will have to think about if there is anything additional that could make things more robust but in both cases, timers and dosers appear to behave on power restore.

:)
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,848
Reaction score
17,081
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Just thought Id throw this here, a raspberry pi 4b 2gb version combined with a tp-link UE300 usb3.0 to ethernet dongle makes on heck of a great router/firewall with a small footprint and low power use.
Im routing gigabit internet with sqm qos, adguard, ban IP and ddns along with wireguard VPN so I can access my network from the outside securely and it doesnt even break a sweat. Now can just use my existing wireless routers as access points and let the raspberry pi handle the routing work. So far its the best router firewall ive used short of a dedicated PF sense box.
Very nice. I’ve been using a pi 3 for ad blocking (pi hole) , and it’s been awesome
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,848
Reaction score
17,081
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Just tested the doser, mine comes on every 5min after the hour, I shut down reefpi during its dosing schedule and it kept running when reefpi was shutdown, scramble to get a container to capture output. I then pulled the power to reefpi which also feeds reef-pi, doser stopped. Note to self, pull power in the future when testing, lol.

When applied power back to reef-pi and it booted up the doser module did not resume, it remained off. This is anecdotal testing and I am running v3.3 and not the latest code so take it for what its worth, will have to think about if there is anything additional that could make things more robust but in both cases, timers and dosers appear to behave on power restore.

:)
The macro behavior is rooted in the timers. So timers will behave same. I think the outlet will stay on, since at the time of crash it was on,.

I’m thinking of a feature that will disable reef-pi to do the one time sync on boot up, and let individual module take care of things
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,848
Reaction score
17,081
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Just tested the equipment control with separate timers for on and off, set the timer turn on and then had a timer set 2 min later to turn off. When the first timer fired I shutdown reefpi from the OS, and left it off past the off timer. I restored power and it initially came on when things rebooted but as in the other thread about a minute later ( I didn't time it) the outlet turned off. I was watching journalctl and it stated:

that was the outlet controlling the pump and shut it off. So it appears that it does store the default state and returns it to that state on a reboot. I do not have the dosing module set up on my frag tank so I am unable to test it, but my concern on the dosing module is it pumps out much faster and even if it ran for a minute or so that could spike my PH since I am dosing Kalk. Will be interesting to hear from @Ranjib expected behavior for the dosing module, if it works differently than the outlets I will have to purchase a couple more BRS pumps, they are slow @1.1ml/min but for my small tanks that provides more breathing room for things like this.

:)
The behavior should be same as the timer.
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,848
Reaction score
17,081
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Just tested the doser, mine comes on every 5min after the hour, I shut down reefpi during its dosing schedule and it kept running when reefpi was shutdown, scramble to get a container to capture output. I then pulled the power to reefpi which also feeds reef-pi, doser stopped. Note to self, pull power in the future when testing, lol.

When applied power back to reef-pi and it booted up the doser module did not resume, it remained off. This is anecdotal testing and I am running v3.3 and not the latest code so take it for what its worth, will have to think about if there is anything additional that could make things more robust but in both cases, timers and dosers appear to behave on power restore.

:)
Shutdown and direct power cutoff are two different scenario. In shutdown reef-pi will execute standard life cycle hooks, including stopping timers.
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,349
Reaction score
1,724
Location
Missouri
Rating - 0%
0   0   0
The macro behavior is rooted in the timers. So timers will behave same. I think the outlet will stay on, since at the time of crash it was on,.

I’m thinking of a feature that will disable reef-pi to do the one time sync on boot up, and let individual module take care of things
I tested timers and doser and timer came back on for about a minute then shut off, the doser stayed off. I'd like to feel a little more secure about things and if you say they might not I need to figure out mitigations.
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,349
Reaction score
1,724
Location
Missouri
Rating - 0%
0   0   0
Shutdown and direct power cutoff are two different scenario. In shutdown reef-pi will execute standard life cycle hooks, including stopping timers.
Ah ok, I never just like pulling the plug, so I guess I need to do more testing but based on what you are stating timers/dosing and power outages are not a good thing, ugh.

:)
 

HAVE YOU EVER KEPT A RARE/UNCOMMON FISH, CORAL, OR INVERT? SHOW IT OFF IN THE THREAD!

  • 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%
Back
Top