I have this setup working successfully, my energy retailer in Australia is Red Energy and my distributer is CitiPOWER in Victoria.
I simply created an account here to link the Eagle with my CitiPOWER smart meter:
Once linked the below script is able to get data from the Eagle. You will need to fill in both the Eagle and Domoticz configuration sections of the script and also set the Domoticz Device IDX number in the "# Send data to Domoticz virtual sensor type: Electricity (Instant+Counter)" section which is currently set to 635.
getdata.sh
Code: Select all
#!/bin/bash
while true; do
# Eagle Configuration (you can find the CloudID and IN numbers on the back of your Eagle device)
EagleIPAddress="IPADDRESS"
CloudID="CLOUDID"
IN="INNUMBER"
MAC="MACADDRESS" #// Format example: e8p5b20050003ac1
# Domoticz Configuration
domoticzserver="IPADDRESS"
domoticzport="80"
domoticzuser="USERNAME"
domoticzpass="PASSWORD"
# Get the data
data=$(curl -su "$CloudID":"$IN" "http://"$EagleIPAddress"/cgi-bin/cgi_manager" -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-GB,en-US;q=0.8,en;q=0.6' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: */*' -H 'X-Requested-With: XMLHttpRequest' --data $"<LocalCommand>\n <Name>get_usage_data</Name>\n <MacId>0x"$MAC"</MacId>\n</LocalCommand>\n<LocalCommand>\n <Name>get_price_blocks</Name>\n <MacId>0x"$MAC"</MacId>\n</LocalCommand>\n" --compressed)
# Meter connection status
status=$(echo "$data" | grep '{"meter_status":' | awk -F'"' '{print $4}')
# If Eagle is connected to the meter, fetch usage data and load it into Domoticz
if [ "$status" == "Connected" ]; then
# Current usage
current=$(echo "$data" | grep '"demand":' | sed 's/[^0-9.]*//g')
currentunits=$(echo "$data" | grep '"demand_units":' | awk -F'"' '{print $4}')
# Meter reading
fromgrid=$(echo "$data" | grep '"summation_delivered":' | sed 's/[^0-9.]*//g')
togrid=$(echo "$data" | grep '"summation_received":' | sed 's/[^0-9.]*//g')
gridunits=$(echo "$data" | grep '"summation_units":' | awk -F'"' '{print $4}')
# Display data in terminal
echo
echo "Connection Status"":" "$status"
echo "Current" "$currentunits"":" "$current"
echo "From Grid" "$gridunits"":" "$fromgrid"
echo "To Grid" "$gridunits"":" "$togrid"
# Do some math to prepare the data for Domoticz
if [ "$currentunits" == "kW" ]; then
currentwatts=$(echo "$current * 1000" | bc -l) #// Convert kW to Watts
fi
fromgriddomoticz=$(echo "$fromgrid * 1000" | bc -l) #// Multiply by 1000 for Domoticz
# Send data to Domoticz virtual sensor type: Electricity (Instant+Counter)
curl -s "http://{$domoticzuser}:{$domoticzpass}@{$domoticzserver}:{$domoticzport}/json.htm?type=command¶m=udevice&idx=635&nvalue=0&svalue={$currentwatts};{$fromgriddomoticz}"
else
echo "No connection to Meter, will check again shortly..."
fi
sleep 15
done
startup.sh
Code: Select all
#!/bin/bash
/usr/bin/screen -S eaglemonitor -d -m /root/eagle/getdata.sh
eaglemonitor
Code: Select all
#!/bin/sh
### BEGIN INIT INFO
# Provides: eaglemonitor
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 5
# Default-Stop:
# Description:
### END INIT INFO
case "$1" in
'start')
sudo /root/eagle/startup.sh
;;
'stop')
;;
*)
echo "Usage: $0 { start | stop }"
;;
esac
exit 0