Reef-pi + Home Assistant Build

Discussion in 'Do It Yourself (DIY)' started by sfgabe, Dec 16, 2018.

  1. sfgabe

    sfgabe Member

    Joined:
    Sep 7, 2018
    Messages:
    52
    Likes Received:
    103
    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: Dec 16, 2018
    Mendeln, Bigtrout, crusso1993 and 5 others like this.

  2. Diamond1

    Diamond1 Valuable Member Build Thread Contributor

    Joined:
    Oct 17, 2013
    Messages:
    1,370
    Likes Received:
    1,863
    Location:
    Cleveland Ohio
    Very cool.
     
    Ranjib and sfgabe like this.
  3. sfgabe

    sfgabe Member

    Joined:
    Sep 7, 2018
    Messages:
    52
    Likes Received:
    103
    Some photos of the actual reef tank... It's an Aqueon 15 gal column with a custom sump enclosure and a vertical rock armature.

    IMG_20181216_220944.jpg

    IMG_20180414_154037.jpg

    IMG_20180417_010011.jpg

    IMG_20180417_005916.jpg
     
    Ranjib likes this.
  4. Ranjib

    Ranjib Valuable Member R2R Supporter R2R Excellence Award Reef Squad Build Thread Contributor

    Joined:
    Apr 16, 2016
    Messages:
    5,880
    Likes Received:
    9,713
    Location:
    Palo Alto, Bay Area
    Very cool.
    On a side note , that 15g tank could use some extra light , like kessil a160 ..
     
    sfgabe likes this.
  5. sfgabe

    sfgabe Member

    Joined:
    Sep 7, 2018
    Messages:
    52
    Likes Received:
    103
    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.
     
    Ranjib likes this.
  6. sfgabe

    sfgabe Member

    Joined:
    Sep 7, 2018
    Messages:
    52
    Likes Received:
    103
    That said, if anyone has a a Kessil A160 they would like to donate... :)
     
    Ranjib likes this.
  7. Mikeneedsahobby

    Mikeneedsahobby Active Member

    Joined:
    Sep 16, 2018
    Messages:
    183
    Likes Received:
    394
    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?
     
    sfgabe, Ranjib and Bigtrout like this.
  8. Bigtrout

    Bigtrout Active Member R2R Supporter R2R Excellence Award

    Joined:
    Dec 16, 2018
    Messages:
    448
    Likes Received:
    1,170
    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
     
    sfgabe and Ranjib like this.
  9. sfgabe

    sfgabe Member

    Joined:
    Sep 7, 2018
    Messages:
    52
    Likes Received:
    103
    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.
     
    Ranjib and Bigtrout like this.
  10. sfgabe

    sfgabe Member

    Joined:
    Sep 7, 2018
    Messages:
    52
    Likes Received:
    103
    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 and Ranjib like this.
  11. Bigtrout

    Bigtrout Active Member R2R Supporter R2R Excellence Award

    Joined:
    Dec 16, 2018
    Messages:
    448
    Likes Received:
    1,170
    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!?!
     
    Ranjib and sfgabe like this.
  12. sfgabe

    sfgabe Member

    Joined:
    Sep 7, 2018
    Messages:
    52
    Likes Received:
    103
    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 and Ranjib like this.
  13. Bigtrout

    Bigtrout Active Member R2R Supporter R2R Excellence Award

    Joined:
    Dec 16, 2018
    Messages:
    448
    Likes Received:
    1,170
    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.
     
    Mikeneedsahobby, Ranjib and sfgabe like this.
  14. Ranjib

    Ranjib Valuable Member R2R Supporter R2R Excellence Award Reef Squad Build Thread Contributor

    Joined:
    Apr 16, 2016
    Messages:
    5,880
    Likes Received:
    9,713
    Location:
    Palo Alto, Bay Area
    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
     
  15. sfgabe

    sfgabe Member

    Joined:
    Sep 7, 2018
    Messages:
    52
    Likes Received:
    103
    Just adding this question from the reef-pi thread...
    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
    
     
  16. Ranjib

    Ranjib Valuable Member R2R Supporter R2R Excellence Award Reef Squad Build Thread Contributor

    Joined:
    Apr 16, 2016
    Messages:
    5,880
    Likes Received:
    9,713
    Location:
    Palo Alto, Bay Area
    @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
     
    sfgabe likes this.
  17. sfgabe

    sfgabe Member

    Joined:
    Sep 7, 2018
    Messages:
    52
    Likes Received:
    103
    A year would be fantastic. Just long enough so that I forget the steps needed to change it :p
     
  18. sfgabe

    sfgabe Member

    Joined:
    Sep 7, 2018
    Messages:
    52
    Likes Received:
    103
    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
     
  19. Ranjib

    Ranjib Valuable Member R2R Supporter R2R Excellence Award Reef Squad Build Thread Contributor

    Joined:
    Apr 16, 2016
    Messages:
    5,880
    Likes Received:
    9,713
    Location:
    Palo Alto, Bay Area
    which version you are using? Can you try 2.2, there was a bug in the past ones,
     
  20. sfgabe

    sfgabe Member

    Joined:
    Sep 7, 2018
    Messages:
    52
    Likes Received:
    103
    Running 2.2 already :(
     
    Ranjib likes this.
Draft saved Draft deleted

Share This Page

Loading...