Seneye Fish Tank Monitor Bash Script

All kinds of 'OS' scripts

Moderator: leecollings

Post Reply
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Seneye Fish Tank Monitor Bash Script

Post 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 3542 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 3542 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 3542 times
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
ropske
Posts: 483
Joined: Tuesday 12 August 2014 5:37
Target OS: Raspberry Pi / ODroid
Domoticz version: V3_8394
Location: Rumbeke,Belgium
Contact:

Re: Seneye Fish Tank Monitor Bash Script

Post 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.
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Seneye Fish Tank Monitor Bash Script

Post 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.
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
astrapowerrr
Posts: 141
Joined: Tuesday 31 January 2017 20:34
Target OS: -
Domoticz version:
Contact:

Re: Seneye Fish Tank Monitor Bash Script

Post 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
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Seneye Fish Tank Monitor Bash Script

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
astrapowerrr
Posts: 141
Joined: Tuesday 31 January 2017 20:34
Target OS: -
Domoticz version:
Contact:

Re: Seneye Fish Tank Monitor Bash Script

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests