Page 1 of 1

Seneye Fish Tank Monitor Bash Script

Posted: Friday 12 May 2017 20:55
by ben53252642
I wrote a Linux bash script for getting data from Seneye API and loading it into Domoticz,

Install requirements: apt-get install jq bc screen

Get your device ID number with this command:

Code: Select all

curl -s 'https://api.seneye.com/v1/devices?user=YOUREMAIL&pwd=YOURPASSWORD'
Enter your device ID, username and password, Domoticz IP and login details in the update.sh script.

Code: Select all

#!/bin/bash
while true; do

# Get the data
echo "Getting data from Seneye API..."
data=$(curl -s 'https://api.seneye.com/v1/devices/YOURDEVICEID?IncludeState=1&user=YOUREMAIL&pwd=YOURPASSWORD')

# Sort the data
temperature=$(echo "$data" | jq '.exps.temperature.curr' | sed -e s/[^0-9.]//g)
ph=$(echo "$data" | jq '.exps.ph.curr' | sed -e s/[^0-9.]//g)
nh3=$(echo "$data" | jq '.exps.nh3.curr' | sed -e s/[^0-9.]//g)
# Calculate slide expiry days
currentdate=$(date +%s)
unixexpiry=$(echo "$data" | jq '.status.slide_expires' | sed -e s/[^0-9.]//g)
math1=$(echo ""$unixexpiry"-"$currentdate"" | bc)
daysremaining=$(echo ""$math1" / 60 / 60 / 24" | bc)

# Display data in terminal
echo "temperature:" "$temperature"
echo "ph:" "$ph"
echo "nh3:" "$nh3"
echo "slide days remaining:" "$daysremaining"

# Load the data into Domoticz
echo "Sending data to Domoticz..."
curl -s "http://USERNAME:[email protected]/json.htm?type=command&param=udevice&idx=619&svalue=${temperature}"
curl -s "http://USERNAME:[email protected]/json.htm?type=command&param=udevice&idx=620&svalue=${ph}"
curl -s "http://USERNAME:[email protected]/json.htm?type=command&param=udevice&idx=621&svalue=${nh3}"
curl -s "http://USERNAME:[email protected]/json.htm?type=command&param=udevice&idx=622&svalue=${daysremaining}"

# Refresh data every 10 minutes
sleep 600
done

I use this startup.sh script to run it in the background using screen:

Code: Select all

# Start seneyemonitor
/usr/bin/screen -S seneyemonitor -d -m /root/seneye/update.sh
Screen Shot 2017-05-13 at 4.45.16 am.png
Screen Shot 2017-05-13 at 4.45.16 am.png (108.2 KiB) Viewed 5033 times
Screen Shot 2017-05-13 at 4.45.52 am.png
Screen Shot 2017-05-13 at 4.45.52 am.png (132.61 KiB) Viewed 5033 times
Screen Shot 2017-05-13 at 4.46.12 am.png
Screen Shot 2017-05-13 at 4.46.12 am.png (64.65 KiB) Viewed 5033 times

Re: Seneye Fish Tank Monitor Bash Script

Posted: Friday 04 August 2017 18:56
by ropske
Hi, i'm interested in your setup :)

What device are you using?
Seneye Home ?
Is this device connected to your Raspberry Pi ?

Can this device be connected with WiFi?
Thank you.

Re: Seneye Fish Tank Monitor Bash Script

Posted: Saturday 05 August 2017 23:59
by ben53252642
Seneye Home with the Seneye Web Server.

I ran this setup for about 3 months but have recently removed the Seneye home because I got sick of the bright red light it shines through the tank every 60 seconds or so. I found it distracting since my fish tank is located in the living room near the TV. It was useful to learn how NH3 and PH levels of the tank but thanks to the Seneye, now I know approx how often to change the water etc... so I no longer need the unit to tell me + the Seneye slides are kinda expensive here in Aus (about $20 each) and they only last 30 days.

The script will work fine with Raspberry Pi and yes I had the Seneye Web Server running on Wifi via the ethernet / wifi adapter.

Re: Seneye Fish Tank Monitor Bash Script

Posted: Monday 24 May 2021 21:21
by astrapowerrr
hi

maybe nobody anymore here, but can someone please explane how to implement startup.sh?
when i google it gives me a thousand ways to use, but im getting confussed how to setup automaticly start the script

Re: Seneye Fish Tank Monitor Bash Script

Posted: Tuesday 25 May 2021 0:42
by waltervl
This script is not good enough to run as a service (no external logging, echo command in it etc). See https://unix.stackexchange.com/question ... s-a-daemon for some basic instructions.

So to have this script run as a service or as a Cron you will have to modify it. Or start it manually like the topic starter did.

Re: Seneye Fish Tank Monitor Bash Script

Posted: Tuesday 25 May 2021 7:46
by astrapowerrr
Hmmm that’s to bad.
I’m absolutely not familiar with Linux. So that’s gonna be a disappointment.

But thanks for letting me know.
I will google it how to get it working.
Hope
I find a proper solution that is well explained

Greets


Verzonden vanaf mijn iPhone met Tapatalk