http/https poller

Jumper3126
Posts: 64
Joined: Thursday 31 December 2015 16:26
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: http/https poller

Post by Jumper3126 » Saturday 15 September 2018 12:55

Got it running :D
Perhaps not the cleanest way, but it works and that is the main goal

Wrote a bash file, based on this onehttp://www.domoticz.com/forum/viewtopic ... ase#p56105.
I have 14 panels, you'll have to adjust the script for the amount of panels, the ip adress of your enphase gateway and the installer password of your system (see https://thecomputerperson.wordpress.com ... r-toolkit/).

Run the script every 5 minutes using crontab

Code: Select all

#!/bin/bash
# bash script to read production per panel from Enphase gateway
# V1.0 15/09/2018
# Based on script by Koen Vanduffel

# variables
enphase_IP="192.168.1.xx"

panel1_idx="989"
panel2_idx="1004"
panel3_idx="991"
panel4_idx="992"
panel5_idx="993"
panel6_idx="994"
panel7_idx="995"
panel8_idx="996"
panel9_idx="997"
panel10_idx="998"
panel11_idx="999"
panel12_idx="1001"
panel13_idx="1002"
panel14_idx="1003"

# Read Enphase status page
DATA=`wget --user installer --password xxxxxxxx -q -O - $enphase_IP/api/v1/production/inverters`

# Extract data per panel
PANEL1=`echo $DATA | awk '{print $136, $142, $144}'`
PANEL2=`echo $DATA | awk '{print $148, $154, $156}'`
PANEL3=`echo $DATA | awk '{print $88, $94, $96}'`
PANEL4=`echo $DATA | awk '{print $124, $130, $132}'`
PANEL5=`echo $DATA | awk '{print $52, $58, $60}'`
PANEL6=`echo $DATA | awk '{print $28, $34, $36}'`
PANEL7=`echo $DATA | awk '{print $16, $22, $24}'`
PANEL8=`echo $DATA | awk '{print $40, $46, $48}'`
PANEL9=`echo $DATA | awk '{print $4, $10, $12}'`
PANEL10=`echo $DATA | awk '{print $76, $82, $84}'`
PANEL11=`echo $DATA | awk '{print $112, $118, $120}'`
PANEL12=`echo $DATA | awk '{print $64, $70, $72}'`
PANEL13=`echo $DATA | awk '{print $160, $166, $168}'`
PANEL14=`echo $DATA | awk '{print $100, $106, $108}'`

echo $PANEL1
echo $PANEL2
echo $PANEL3
echo $PANEL4
echo $PANEL5
echo $PANEL6
echo $PANEL7
echo $PANEL8
echo $PANEL9
echo $PANEL10
echo $PANEL11
echo $PANEL12
echo $PANEL13
echo $PANEL14

# Extract production per panel
POWER1=`echo $PANEL1 | awk '{print $0}'`
POWER2=`echo $PANEL2 | awk '{print $0}'`
POWER3=`echo $PANEL3 | awk '{print $0}'`
POWER4=`echo $PANEL4 | awk '{print $0}'`
POWER5=`echo $PANEL5 | awk '{print $0}'`
POWER6=`echo $PANEL6 | awk '{print $0}'`
POWER7=`echo $PANEL7 | awk '{print $0}'`
POWER8=`echo $PANEL8 | awk '{print $0}'`
POWER9=`echo $PANEL9 | awk '{print $0}'`
POWER10=`echo $PANEL10 | awk '{print $0}'`
POWER11=`echo $PANEL11 | awk '{print $0}'`
POWER12=`echo $PANEL12 | awk '{print $0}'`
POWER13=`echo $PANEL13 | awk '{print $0}'`
POWER14=`echo $PANEL14 | awk '{print $0}'`

echo $POWER1
echo $POWER2
echo $POWER3
echo $POWER4
echo $POWER5
echo $POWER6
echo $POWER7
echo $POWER8
echo $POWER9
echo $POWER10
echo $POWER11
echo $POWER12
echo $POWER13
echo $POWER14

# Execute curl command to post to Domoticz
curl -i -H "Accept: application/json" "http://localhost:8080/json.htm?type=command&param=udevice&idx=$panel1_idx&nvalue=0&svalue=$POWER1;$W"
curl -i -H "Accept: application/json" "http://localhost:8080/json.htm?type=command&param=udevice&idx=$panel2_idx&nvalue=0&svalue=$POWER2;$W"
curl -i -H "Accept: application/json" "http://localhost:8080/json.htm?type=command&param=udevice&idx=$panel3_idx&nvalue=0&svalue=$POWER3;$W"
curl -i -H "Accept: application/json" "http://localhost:8080/json.htm?type=command&param=udevice&idx=$panel4_idx&nvalue=0&svalue=$POWER4;$W"
curl -i -H "Accept: application/json" "http://localhost:8080/json.htm?type=command&param=udevice&idx=$panel5_idx&nvalue=0&svalue=$POWER5;$W"
curl -i -H "Accept: application/json" "http://localhost:8080/json.htm?type=command&param=udevice&idx=$panel6_idx&nvalue=0&svalue=$POWER6;$W"
curl -i -H "Accept: application/json" "http://localhost:8080/json.htm?type=command&param=udevice&idx=$panel7_idx&nvalue=0&svalue=$POWER7;$W"
curl -i -H "Accept: application/json" "http://localhost:8080/json.htm?type=command&param=udevice&idx=$panel8_idx&nvalue=0&svalue=$POWER8;$W"
curl -i -H "Accept: application/json" "http://localhost:8080/json.htm?type=command&param=udevice&idx=$panel9_idx&nvalue=0&svalue=$POWER9;$W"
curl -i -H "Accept: application/json" "http://localhost:8080/json.htm?type=command&param=udevice&idx=$panel10_idx&nvalue=0&svalue=$POWER10;$W"
curl -i -H "Accept: application/json" "http://localhost:8080/json.htm?type=command&param=udevice&idx=$panel11_idx&nvalue=0&svalue=$POWER11;$W"
curl -i -H "Accept: application/json" "http://localhost:8080/json.htm?type=command&param=udevice&idx=$panel12idx&nvalue=0&svalue=$POWER12;$W"
curl -i -H "Accept: application/json" "http://localhost:8080/json.htm?type=command&param=udevice&idx=$panel13_idx&nvalue=0&svalue=$POWER13;$W"
curl -i -H "Accept: application/json" "http://localhost:8080/json.htm?type=command&param=udevice&idx=$panel14_idx&nvalue=0&svalue=$POWER14;$W"

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest