@Toulon7559
I have read the commented thread. I got a lot of inspiration and code from this thread to make my script
The inverter used is a solis-S5 mini 700W
Below my script a lot of inspiration and code examples are taken from the internet
a little explanation
It is intended that when the solar panels are on, the value is displayed in domoticz.
The part where it is determined whether the panels deliver has yet to be made. To simulate this I took sunset and sunrise
Code: Select all
return {
on = {
timer = {'every 5 minutes'},
httpResponses = {'solisInlog','solisData'},
},
logging = {
level = domoticz.LOG_DEBUG,
marker = 'solarpanel',
},
execute = function(domoticz, item)
domoticz.log('Timer event was triggered by ' .. item.trigger, domoticz.LOG_DEBUG)
-- ****** Start of personal settings *****
local username = "USERNAME"
local pw="PASSW"
--devices
local SolarPanelState = domoticz.devices(185) --schakelaar die aangeeft of panelen aan of uit staan
local SolarPanel = domoticz.devices(186) --managed counter voor weergeven van de data
-- ****** End of personal settings *****
local function callInlog()
domoticz.log("function callInlog", domoticz.LOG_INFO)
--logt in bij ginlog om de gegevens op te halen
domoticz.openURL({
url='http://m.ginlong.com/cpro/login/validateLogin.json?userName='.. username..'&password='..pw..'&lan=2&domain=m.ginlong.com&userType=C',
method = 'post',
callback='solisInlog',
})
end
local function procesInlogData(results)
domoticz.log("function procesInlogData", domoticz.LOG_DEBUG)
return results.isAccept
end
local function callData()
domoticz.log("function callData", domoticz.LOG_DEBUG)
--Haalt de data op van de ginlog site
domoticz.openURL({
url='https://m.ginlong.com/cpro/epc/plantview/view/doPlantList.json',
method = 'post',
callback='solisData',
})
end
local function procesData(Data)
domoticz.log("Function procesData", domoticz.LOG_DEBUG)
for index, D in ipairs(Data) do
domoticz.log("Actuele opbrengst: "..D.curPower, domoticz.LOG_INFO)
domoticz.log("Dagopbrengst: "..D.energyToday, domoticz.LOG_INFO)
--Tijd in variabele om timing problemen te voorkomen
local historyTime = domoticz.time
SolarPanel.updateCounter(D.curPower)
SolarPanel.updateHistory(historyTime.rawDateTime,'10;' .. D.curPower)
SolarPanel.updateHistory(historyTime.rawDate,'10;' .. (D.energyToday*1000))
end
end
-- Main programma executie
--uitvoeren wanneer deze ligt tussen zonsopgang en zonsondergang
if (domoticz.time.matchesRule("between sunrise and sunset")) then
SolarPanelState.switchOn().checkFirst()
if (item.isTimer) then
callInlog()
end
--uitvoeren bij de juiste callback
if (item.isHTTPResponse and item.isJSON) then
if item.trigger=='solisInlog' then -- bij inlog calback
domoticz.log("httresponse solislogin", domoticz.LOG_DEBUG)
--uitvoeren bij een geaccepteerde login
if procesInlogData(item.json.result) then
callData()
end
elseif item.trigger=='solisData' then --bij data callback
domoticz.log("httresponse solisData", domoticz.LOG_DEBUG)
procesData(item.json.result.pagination.data)
end
end
else -- tijdens de 'nacht' de paneelschakelaar uit zetten
SolarPanel.updateCounter(1)
SolarPanelState.switchOff().checkFirst()
end
end
}
The problem is not getting the data. That works well. The strange behavior of the manage counter is the problem.
I created a second counter where I don't use the following line
SolarPanel.updateHistory(historyTime.rawDateTime,'10;' .. D.curPower)
and there I don't get the strange 0 value ???????
maybe a timing problem?
i'm out of options