Unfortunately my search was not good enough as I could not find any results.
So I had to build something myself.
To see if all is working I enabled the rsync feature to replicate data from and to a remote location.
This to emulate upload and download. The script is running on the router itself and posts the data to 2 virtual sensors (COUNTERS). At the moment it runs every minute or so, but that can be changed to every 5 minutes or every hour.
Probably the /tmp/var/spool is not the best directory but this is just an initial test.

After a reboot it will be gone.
Just add the following to the Administration -> scripts -> init.
Code: Select all
SCRIPT="/var/spool/script.sh"
cat << "EOF" > $SCRIPT
#!/bin/sh
DOMO_IP="***.***.***.***" # Domoticz IP Address
DOMO_PORT="8080" # Domoticz Port
UPLOAD_IDX="***" # Upload IDX
DOWNLOAD_IDX="***" # Download IDX
killall -USR2 rstats # Create the statistics
sleep 2 # Just wait for statistics to be created
if [ -e /var/spool/rstats-history.js ] # Execute only if file exists
then
input=$(cat /var/spool/rstats-history.js | grep -A 1 'daily' | grep "[[A-Za-z]]" | sed 's/\],\[/\n/g' | tr -d '[' | tr -d '];' | tail -1)
download=$(echo $input | cut -f2 -d ',')
upload=$(echo $input | cut -f3 -d ',')
upload=$((upload/1024)) # HEX -> DEC conversion and in MB
download=$((download/1024)) # HEX -> DEC conversion and in MB
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$UPLOAD_IDX&svalue=$upload"
curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$DOWNLOAD_IDX&svalue=$download"
else
echo "File not created!"
fi
EOF
chmod +x $SCRIPT
# uncomment the following line if you want it to execute immediately
#$SCRIPT &
You will only have to run it every x minutes or so via: administration -> scheduler.
Code: Select all
/tmp/var/spool/script.sh 2>&1 >> /dev/null