Seneye Fish Tank Monitor Bash Script

All kinds of 'OS' scripts
Post Reply
ben53252642
Posts: 207
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version:
Contact:

Seneye Fish Tank Monitor Bash Script

Post by ben53252642 » Friday 12 May 2017 20:55

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 537 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 537 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 537 times

ropske
Posts: 225
Joined: Tuesday 12 August 2014 5:37
Target OS: Raspberry Pi
Domoticz version: V3_8394
Location: Rumbeke,Belgium
Contact:

Re: Seneye Fish Tank Monitor Bash Script

Post by ropske » Friday 04 August 2017 18:56

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.

ben53252642
Posts: 207
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version:
Contact:

Re: Seneye Fish Tank Monitor Bash Script

Post by ben53252642 » Saturday 05 August 2017 23:59

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests