@@ -98,20 +98,59 @@ rm -rf batterydata.json
9898rm -rf outputdata.json
9999rm -rf dcactemp.json
100100rm -rf inverterinfo.json
101+ rm -rf settings.json
101102
103+ curlError=0
102104echo " Please wait while curl is fetching input, grid, load, battery & output data..."
103- curl -s -k -X GET -H " Content-Type: application/json" -H " authorization: Bearer $ServerAPIBearerToken " https://api.sunsynk.net/api/v1/inverter/$inverter_serial /realtime/input -o " pvindata.json"
104- curl -s -k -X GET -H " Content-Type: application/json" -H " authorization: Bearer $ServerAPIBearerToken " https://api.sunsynk.net/api/v1/inverter/grid/$inverter_serial /realtime? sn=$inverter_serial -o " griddata.json"
105- curl -s -k -X GET -H " Content-Type: application/json" -H " authorization: Bearer $ServerAPIBearerToken " https://api.sunsynk.net/api/v1/inverter/load/$inverter_serial /realtime? sn=$inverter_serial -o " loaddata.json"
106- curl -s -k -X GET -H " Content-Type: application/json" -H " authorization: Bearer $ServerAPIBearerToken " " https://api.sunsynk.net/api/v1/inverter/battery/$inverter_serial /realtime?sn=$inverter_serial &lan=en" -o " batterydata.json"
107- curl -s -k -X GET -H " Content-Type: application/json" -H " authorization: Bearer $ServerAPIBearerToken " https://api.sunsynk.net/api/v1/inverter/$inverter_serial /realtime/output -o " outputdata.json"
108- curl -s -k -X GET -H " Content-Type: application/json" -H " authorization: Bearer $ServerAPIBearerToken " " https://api.sunsynk.net/api/v1/inverter/$inverter_serial /output/day?lan=en&date=$VarCurrentDate &column=dc_temp,igbt_temp" -o " dcactemp.json"
109- curl -s -k -X GET -H " Content-Type: application/json" -H " authorization: Bearer $ServerAPIBearerToken " https://api.sunsynk.net/api/v1/inverter/$inverter_serial -o " inverterinfo.json"
110- curl -s -k -X GET -H " Content-Type: application/json" -H " authorization: Bearer $ServerAPIBearerToken " https://api.sunsynk.net/api/v1/common/setting/$inverter_serial /read -o " settings.json"
105+ curl -s -f -S -k -X GET -H " Content-Type: application/json" -H " authorization: Bearer $ServerAPIBearerToken " https://api.sunsynk.net/api/v1/inverter/$inverter_serial /realtime/input -o " pvindata.json"
106+ if [[ $? -ne 0 ]]; then
107+ echo " Error: Request failed for pvindata.json"
108+ curlError=1
109+ fi
110+
111+ curl -s -f -S -k -X GET -H " Content-Type: application/json" -H " authorization: Bearer $ServerAPIBearerToken " https://api.sunsynk.net/api/v1/inverter/grid/$inverter_serial /realtime? sn=$inverter_serial -o " griddata.json"
112+ if [[ $? -ne 0 ]]; then
113+ echo " Error: Request failed for griddata.json"
114+ curlError=1
115+ fi
116+
117+ curl -s -f -S -k -X GET -H " Content-Type: application/json" -H " authorization: Bearer $ServerAPIBearerToken " https://api.sunsynk.net/api/v1/inverter/load/$inverter_serial /realtime? sn=$inverter_serial -o " loaddata.json"
118+ if [[ $? -ne 0 ]]; then
119+ echo " Error: Request failed for loaddata.json"
120+ curlError=1
121+ fi
122+
123+ curl -s -f -S -k -X GET -H " Content-Type: application/json" -H " authorization: Bearer $ServerAPIBearerToken " " https://api.sunsynk.net/api/v1/inverter/battery/$inverter_serial /realtime?sn=$inverter_serial &lan=en" -o " batterydata.json"
124+ if [[ $? -ne 0 ]]; then
125+ echo " Error: Request failed for batterydata.json"
126+ curlError=1
127+ fi
128+
129+ curl -s -f -S -k -X GET -H " Content-Type: application/json" -H " authorization: Bearer $ServerAPIBearerToken " https://api.sunsynk.net/api/v1/inverter/$inverter_serial /realtime/output -o " outputdata.json"
130+ if [[ $? -ne 0 ]]; then
131+ echo " Error: Request failed for outputdata.json"
132+ curlError=1
133+ fi
111134
135+ curl -s -f -S -k -X GET -H " Content-Type: application/json" -H " authorization: Bearer $ServerAPIBearerToken " " https://api.sunsynk.net/api/v1/inverter/$inverter_serial /output/day?lan=en&date=$VarCurrentDate &column=dc_temp,igbt_temp" -o " dcactemp.json"
136+ if [[ $? -ne 0 ]]; then
137+ echo " Error: Request failed for dcactemp.json"
138+ curlError=1
139+ fi
112140
141+ curl -s -f -S -k -X GET -H " Content-Type: application/json" -H " authorization: Bearer $ServerAPIBearerToken " https://api.sunsynk.net/api/v1/inverter/$inverter_serial -o " inverterinfo.json"
142+ if [[ $? -ne 0 ]]; then
143+ echo " Error: Request failed for inverterinfo.json"
144+ curlError=1
145+ fi
113146
147+ curl -s -f -S -k -X GET -H " Content-Type: application/json" -H " authorization: Bearer $ServerAPIBearerToken " https://api.sunsynk.net/api/v1/common/setting/$inverter_serial /read -o " settings.json"
148+ if [[ $? -ne 0 ]]; then
149+ echo " Error: Request failed for settings.json"
150+ curlError=1
151+ fi
114152
153+ if [ $curlError -eq 0 ]; then
115154inverterinfo_brand=$( jq -r ' .data.brand' inverterinfo.json)
116155inverterinfo_status=$( jq -r ' .data.status' inverterinfo.json)
117156inverterinfo_runstatus=$( jq -r ' .data.runStatus' inverterinfo.json)
@@ -274,7 +313,33 @@ EntityLogOutput="-o tmpcurllog.json"
274313if [ $Enable_Verbose_Log == " true" ]
275314then
276315EntityLogOutput=" "
277- echo " If ALL values are NULL then something went wrong."
316+ echo " Raw data per file"
317+ echo ------------------------------------------------------------------------------
318+ echo " pvindata.json"
319+ cat pvindata.json
320+ echo ------------------------------------------------------------------------------
321+ echo " griddata.json"
322+ cat griddata.json
323+ echo ------------------------------------------------------------------------------
324+ echo " loaddata.json"
325+ cat loaddata.json
326+ echo ------------------------------------------------------------------------------
327+ echo " batterydata.json"
328+ cat batterydata.json
329+ echo ------------------------------------------------------------------------------
330+ echo " outputdata.json"
331+ cat outputdata.json
332+ echo ------------------------------------------------------------------------------
333+ echo " dcactemp.json"
334+ cat dcactemp.json
335+ echo ------------------------------------------------------------------------------
336+ echo " inverterinfo.json"
337+ cat inverterinfo.json
338+ echo ------------------------------------------------------------------------------
339+ echo " settings.json"
340+ cat settings.json
341+ echo ------------------------------------------------------------------------------
342+ echo " Values to send. If ALL values are NULL then something went wrong:"
278343# Dump of all values
279344echo " battery_capacity" $battery_capacity
280345echo " battery_chargevolt" $battery_chargevolt
575640 curl -s -k -X POST -H " Authorization: Bearer $HA_LongLiveToken " -H " Content-Type: application/json" -d ' {"attributes": {"unit_of_measurement": "", "friendly_name": "solarsynk_inverter_settings"}, "state": ""}' $HTTP_Connect_Type ://$Home_Assistant_IP :$Home_Assistant_PORT /api/states/input_text.solarsynk_" $inverter_serial " _inverter_settings > /dev/null
576641fi
577642
578-
643+ fi
644+ # EOF Curl failure
579645
580646# EOF Serial Number Loop
581647echo " Fetch complete for inverter: $inverter_serial "
0 commit comments