Efergy sensor implementation via scripting

Moderator: leecollings

Post Reply
manutremo
Posts: 69
Joined: Saturday 19 November 2016 17:02
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Efergy sensor implementation via scripting

Post by manutremo »

It is already known that the efergy sensors have an API available which allows to access a lot of data. I implemented a simple script to collect the instantaneous power consumption and daily energy and feed it into a counter virtual device via JSON.

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&param=udevice&idx=115&nvalue=0&svalue=$power;$energyToday" > /dev/null 2>&1
I have this script running on a Synology NAS every minute via crontab with no issues.

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!
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: Efergy sensor implementation via scripting

Post by Westcott »

Hi Manutremo,

That looks really neat!
Which Efergy sensor are you using, or which ones support this method?
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
manutremo
Posts: 69
Joined: Saturday 19 November 2016 17:02
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Efergy sensor implementation via scripting

Post by manutremo »

Hi Westcott,

I'm using an Efergy hub kit. I haven't used other models but as far as I know the API is model independent so the script should work with any model that sends its data to the internet.

I used the API description here http://napi.hbcontent.com/document/index.php.

Thanks,
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest