Logic Machine Forum
SolarEdge monitoring website - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: SolarEdge monitoring website (/showthread.php?tid=3342)



SolarEdge monitoring website - baggins - 04.05.2021

Hi,

I have a script that gets data from my solar panels from the SolarEdge monitoring site.
This script has worked without problems for the past year, but lately two out of three attempts fail.
For testing I can run the same script on another server in the same network without any problems.

This is the relevant part of the script:

Code:
require('socket')
local https = require("ssl.https")

socket.http.TIMEOUT = 20

local SolarEdge = https.request('https://monitoringapi.solaredge.com/site/1234567/overview?api_key=mykey')

if not SolarEdge then
  alert('SolarEdge data cannot be retrieved..  ' .. tostring(SolarEdge))
  return
else
  log(SolarEdge)
end
At first I thought that I exceeded the maximum number of reads per day but that is not the case. The script runs every 15 minutes (=96 times a day) and Solaredge allows 300 reads.

This is the Alert message:
Code:
SolarEdge data cannot be retrieved  nil
So this is not a SolarEdge server error message.
This is on a LM4 firmware 20160714.

What could be the cause of this?


RE: SolarEdge monitoring website - baggins - 06.05.2021

I have modified the script to return the error:

Code:
local SolarEdge,err = ...

if not SolarEdge then
  alert('SolarEdge cannot be retrieved.  ' .. tostring(SolarEdge) .."  error:  " ..err)
  return
end
The error that I get is:

Code:
error: recvd alert fatal error
What does this mean?


RE: SolarEdge monitoring website - admin - 06.05.2021

You have an outdated firmware that causes this error.
Try requesting like this:
Code:
https = require('ssl.https')
url = 'https://monitoringapi.solaredge.com/site/1234567/overview?api_key=mykey'

resp = {}
res, code, headers = https.request({
  url = url,
  method = 'GET',
  sink = ltn12.sink.table(resp),
  protocol = 'tlsv12'
})

resp = table.concat(resp)
log(res, code, resp)



RE: SolarEdge monitoring website - baggins - 06.05.2021

(06.05.2021, 09:44)admin Wrote: You have an outdated firmware that causes this error.
Try requesting like this:
Code:
https = require('ssl.https')
url = 'https://monitoringapi.solaredge.com/site/1234567/overview?api_key=mykey'

resp = {}
res, code, headers = https.request({
  url = url,
  method = 'GET',
  sink = ltn12.sink.table(resp),
  protocol = 'tlsv12'
})

resp = table.concat(resp)
log(res, code, resp)

Success!
The strange thing is that my original script not always fails, sometimes I can get the data...
Thanks.

(06.05.2021, 10:15)baggins Wrote:
(06.05.2021, 09:44)admin Wrote: You have an outdated firmware that causes this error.
Try requesting like this:
Code:
https = require('ssl.https')
url = 'https://monitoringapi.solaredge.com/site/1234567/overview?api_key=mykey'

resp = {}
res, code, headers = https.request({
  url = url,
  method = 'GET',
  sink = ltn12.sink.table(resp),
  protocol = 'tlsv12'
})

resp = table.concat(resp)
log(res, code, resp)

Success!
The strange thing is that my original script not always fails, sometimes I can get the data...
Thanks.

Well, unfortunately now I get the same error as with the original script. Two times out of three it fails and then for some reason it works...


RE: SolarEdge monitoring website - admin - 08.05.2021

Then the only solution is to upgrade the firmware.


RE: SolarEdge monitoring website - baggins - 08.05.2021

(08.05.2021, 10:25)admin Wrote: Then the only solution is to upgrade the firmware.

As you probably remember I cannot upgrade at the moment because of an issue with a third party library Angry 

It is strange though that the script works from time to time.

Anyway, I moved the script to another server from where i set the group address values on the LM. Not convenient but it works...