Code: Select all
p=$(curl -s 'http://www.energyhive.com/mobile_proxy/getCurrentValuesSummary?token=<token>' | jq -r .[].data)
e=$(curl -s 'http://www.energyhive.com/mobile_proxy/getEnergy?token=<token>&period=day&offset=-60' | jq -r .sum)
power=$(echo $p |cut -f2 -d":"|cut -f1 -d"}"| tr -d ' ')
energyToday=$(awk "BEGIN {print $e*1000}")
curl -s -i -H "Accept: application/json" "http://192.168.0.1:8084/json.htm?type=command¶m=udevice&idx=115&nvalue=0&svalue=$power;$energyToday" > /dev/null 2>&1
The only users modifications required should be adding your own token and modifying the idx of the virtual device accordingly to your own setup. The offset parameter in the second call to the API may also be modified according to your time zone.
I can see one potential improvement on adding a check in case the API is not available or returns an error. I will update the script when it's ready - however the API has been proving to be very reliable up to now.
Enjoy!