Reef-pi + Home Assistant Build

sfgabe

Active Member
View Badges
Joined
Sep 7, 2018
Messages
174
Reaction score
265
Rating - 0%
0   0   0
I control my 2 small aquariums (one 40 gal fresh, one 15 gal nano reef) with a combination of Home Assistant (which also takes care of my apartment), Reef-Pi, and Motioneye.

I wanted the tanks to mirror specific locations as much as possible. For example, I’m querying various sites to get daily water temp, tide, and weather data. I also wanted to be able to monitor everything from outside the house, so it needed to be web accessible.

ha_bali.png
The reef tank:
  • Getting temp and ATO sensor data from reef-pi (Raspberry Pi 3B) and publishing via API, which Home Assistant installation can pick up as sensors
  • Water temperature changes daily according to NOAA data, dropping to lower averages at night, and higher at midday depending on the data coming from a reef in Bali.
  • Kessil Tuna Blue A80 fades up / down according to sunrise / sunset times, and offset by two hours so the late-waking humans can enjoy the tank.
  • High and low tides control the Jabao SW2 wavemaker on/off according to a script that increases intensity at mid-tide change for that specific location.
  • Top off and dosing from two peristaltic pumps on the reef-pi build. These are manual for now, because I'm not sure about speed and volume yet.
ha_amazon (1).jpeg
The freshwater planted tank:
  • Getting temp and ato sensor data from scripts on a Raspberry Pi Zero W, and broadcasting to Home Assistant sensors via MQTT
  • Water temp is targeted to a spot in the Amazon River. Amazon water temp data is hard to find so I had to go with monthly averages in a text file.
  • Finnex Fugeray Planted turns on / off according to sunrise / sunset times, offset by one hour, CO2 also goes on and off with the lights.
  • River high and low tides turn an extra pump on/off according to tide change for that location.
  • a pi-enabled barrel feeder, run from a script on a motioneye action button
  • a Pimoroni Octocam, which posts time lapse movies to twitter (@Octo_Cam_bot) and photos and stats for each feeding
reefpienclosure2.jpg reefpienclosure.jpg
Most simple power on/off switching is done with Tuya smart home outlets via home assistant. You can read about the hardware details of the Reef-pi controller on Thingiverse, with the enclosure files. Improvement has become a never-ending project but I think it’s pretty cool so I wanted to share. Will update the Github repository as I can.

Some other resources for aquarium control:
octocam.jpg Screen Shot 2018-12-16 at 9.18.40 PM.png
 
Last edited:
OP
OP
sfgabe

sfgabe

Active Member
View Badges
Joined
Sep 7, 2018
Messages
174
Reaction score
265
Rating - 0%
0   0   0
Very cool.
On a side note , that 15g tank could use some extra light , like kessil a160 ..
Yes, while i like the look of it, I don't think I would go for a column tank again. Trying to get light to the bottom without burning up the top is a challenge. I have a second submersible led strip on the inside rim of the tank, aimed off at an angle, which helps a bit. I might try getting one on the side as well.
 
OP
OP
sfgabe

sfgabe

Active Member
View Badges
Joined
Sep 7, 2018
Messages
174
Reaction score
265
Rating - 0%
0   0   0
Yes, while i like the look of it, I don't think I would go for a column tank again. Trying to get light to the bottom without burning up the top is a challenge. I have a second submersible led strip on the inside rim of the tank, aimed off at an angle, which helps a bit. I might try getting one on the side as well.
That said, if anyone has a a Kessil A160 they would like to donate... :)
 
OP
OP
sfgabe

sfgabe

Active Member
View Badges
Joined
Sep 7, 2018
Messages
174
Reaction score
265
Rating - 0%
0   0   0
Can you provide an outline of how you integrate reef-pi with the smart outlets? I would like reef-pi to control two outlets in my basement without running wire. Is this the solution?

Are you using the reef pi for monitoring only and using smart outlets for on off operations, im really interested in how you intergrated as well

Currently reef-pi and the smart outlets are not integrated. I think @Ranjib has that in the works for the future but it is not currently supported. Tuya smart outlets (and some others I think) are supported by HomeAssistant, while sensors to base actions on are coming from home assistant.

For example:
  1. A python script polls NOAA data for todays high and low water temperature
  2. A Home Assistant template calculates high (daytime) and low (nighttime) temperature around the average to prevent wide fluctuations.
  3. HA gets the reef-pi temp sensor info from the reef-pi API
  4. A HA 'thermostat' compares the water temp with the calculated temp and triggers the Tuya Plug for the heater if needed. I have it set for a .3 degree responsiveness and it's been very reliable.
  5. When sunset or sunrise is triggered the target temp switches to low average or high average respectively.
If reef-pi had smart outlets available that would be a much more straightforward solution, though I'd still need to do the data calculations elsewhere.
 
OP
OP
sfgabe

sfgabe

Active Member
View Badges
Joined
Sep 7, 2018
Messages
174
Reaction score
265
Rating - 0%
0   0   0
Are you using the reef pi for monitoring only and using smart outlets for on off operations, im really interested in how you intergrated as well
In full reef-pi is used for:
  • monitoring temperature
  • monitoring ATO float sensor
  • sending PWM data to the Kessil light
  • turning on/off the ato and doser pumps
The actual control of those last two elements is done by sending API calls after certain other parameters have triggered them though HA. I'd like to use it for the wavemaker once that's integrated, but for now it's just on an on/off smart outlet.
 

Bigtrout

Valuable Member
View Badges
Joined
Dec 16, 2018
Messages
1,189
Reaction score
2,826
Rating - 0%
0   0   0
Currently reef-pi and the smart outlets are not integrated. I think @Ranjib has that in the works for the future but it is not currently supported. Tuya smart outlets (and some others I think) are supported by HomeAssistant, while sensors to base actions on are coming from home assistant.

For example:
  1. A python script polls NOAA data for todays high and low water temperature
  2. A Home Assistant template calculates high (daytime) and low (nighttime) temperature around the average to prevent wide fluctuations.
  3. HA gets the reef-pi temp sensor info from the reef-pi API
  4. A HA 'thermostat' compares the water temp with the calculated temp and triggers the Tuya Plug for the heater if needed. I have it set for a .3 degree responsiveness and it's been very reliable.
  5. When sunset or sunrise is triggered the target temp switches to low average or high average respectively.
If reef-pi had smart outlets available that would be a much more straightforward solution, though I'd still need to do the data calculations elsewhere.
Very nice, and interesting because before finding reef pi, I was going to use sonoff smart outlets and their th16 temperature monitor outlet that uses a ds18b20 to control relays. They are esp8266 based with wifi and can be flashed with tasmota or espeasy and can be used with home assistant or iftt and even Alexa, but living in a rural area i would be at the mercy of internet outages unless I made my own Home Assistant server which adds more complexity(failure points) vs the reef pi solution which is more locally based.
I do like how your system matches the biotope for light and temperature, very slick!!!
Perhaps in the future there could be a way to import settings into reef pi like you are doing. Maybe this could happen in reef pi 3.0 when Ranjib implements a master pi system to run several reef pi's!?!
 
OP
OP
sfgabe

sfgabe

Active Member
View Badges
Joined
Sep 7, 2018
Messages
174
Reaction score
265
Rating - 0%
0   0   0
Very nice, and interesting because before finding reef pi, I was going to use sonoff smart outlets and their th16 temperature monitor outlet that uses a ds18b20 to control relays. They are esp8266 based with wifi and can be flashed with tasmota or espeasy and can be used with home assistant or iftt and even Alexa, but living in a rural area i would be at the mercy of internet outages unless I made my own Home Assistant server which adds more complexity(failure points) vs the reef pi solution which is more locally based.
I do like how your system matches the biotope for light and temperature, very slick!!!
Perhaps in the future there could be a way to import settings into reef pi like you are doing. Maybe this could happen in reef pi 3.0 when Ranjib implements a master pi system to run several reef pi's!?!
Thanks @Bigtrout! You're right about the internet failure points. There was a while there where I was ready to scrap the whole thing until I realised I just needed to replace my 10 year old router.
 

Bigtrout

Valuable Member
View Badges
Joined
Dec 16, 2018
Messages
1,189
Reaction score
2,826
Rating - 0%
0   0   0
I just went thru a nightmare of dropped packets...but only intermittently, cable company replaced their modem, my stuff was fine. Every time it got windy or temperature dropped...dropped packets and poor internet connection...id call and when they came and "checked" everything was ok. After 6 months of this I finally opened their cable connection box myself and found the incoming cable connection was not tightened causing the internittent issues. So far since i did this I havent had one dropped packet since.
 

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
I generally install a systemd timer unit in all of my Pi to restart network everynight, at 2AM. This address the issue of sometime them being completely disconnected from the network and me not being able to connect them in any reasonable way. Dropped packet will be even worse. I assume it will also incur significant CPU usage due to retransmission
 
OP
OP
sfgabe

sfgabe

Active Member
View Badges
Joined
Sep 7, 2018
Messages
174
Reaction score
265
Rating - 0%
0   0   0
Just adding this question from the reef-pi thread...
And thats fine...how did you integrate it with the reef pi api?
Sorry, I just saw this. I'm using the rest sensor in Home Assistant to post or get whatever I need. Currently I need to refresh the reef-pi cookie about once a week, but I think @Ranjib is working on that for future versions?

If you are familiar with Home Assistant you can see my config in my HA github, the important part looks like this
Code:
#ReefControlPi Data
- platform: rest
name: ReefControlPiSysUptime
username: !secret reefcontrolpi_username
password: !secret reefcontrolpi_password
authentication: basic
json_attributes:
- name
- ip
- uptime
- cpu_temperature
- version
resource: http://reefcontrolpi.local/api/info
headers:
Connection: keep-alive
content-type: application/json
Referer: http://reefcontrolpi.local/
Cookie: !secret reefcontrolpi_cookie
 

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
@sfgabe i had to revert the cooking amp age change since it does not work when it set it to infinite. I’ll try with some other values and let you know. If nothing I may just extend it to a year instead of two weeks
 
OP
OP
sfgabe

sfgabe

Active Member
View Badges
Joined
Sep 7, 2018
Messages
174
Reaction score
265
Rating - 0%
0   0   0
@sfgabe i had to revert the cooking amp age change since it does not work when it set it to infinite. I’ll try with some other values and let you know. If nothing I may just extend it to a year instead of two weeks
A year would be fantastic. Just long enough so that I forget the steps needed to change it :p
 
OP
OP
sfgabe

sfgabe

Active Member
View Badges
Joined
Sep 7, 2018
Messages
174
Reaction score
265
Rating - 0%
0   0   0
Since I set this all up before the dosing UI existed, I had my pumps set as pwm "lights". And to hack it into automating a top off in the evening, I had them set for "diurnal" but only from 23:28 - 23:38. This gives me about 8 minutes of 100% speed, and 2 minutes of terrible high pitched squeaking when the setting is ramping up and down but the motor is not powered enough to spin.

So today I tried to switch them over to being "Dosing pumps" in the UI, also for 8 minutes. This worked, sort of, and no squeaking. However, the problem was with duration - 480 seconds gave me just about 30 seconds of "on" time. I tried calibrating but I couldn't find any pattern. 48000 seconds gave me only about 5 seconds of run time, while 240 seconds gave me 14.

Am I missing something @Ranjib ?

Screen Shot 2019-02-17 at 12.31.01 AM.png
 

TOP 10 Trending Threads

WHAT IS YOUR FAVORITE CHRISTMASSY REEF INHABITANT?

  • Christmas Tree Worm!

    Votes: 21 29.2%
  • Starfish!

    Votes: 4 5.6%
  • Peppermint Shrimp!

    Votes: 12 16.7%
  • Candy Cane Coral!

    Votes: 12 16.7%
  • Snowflake Eel!

    Votes: 7 9.7%
  • Christmas Wrasse!

    Votes: 12 16.7%
  • Other (Please explain)!

    Votes: 4 5.6%
Back
Top