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'
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¶m=udevice&idx=619&svalue=${temperature}"
curl -s "http://USERNAME:[email protected]/json.htm?type=command¶m=udevice&idx=620&svalue=${ph}"
curl -s "http://USERNAME:[email protected]/json.htm?type=command¶m=udevice&idx=621&svalue=${nh3}"
curl -s "http://USERNAME:[email protected]/json.htm?type=command¶m=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