local scriptVar = 'Fronius'
return
{
on =
{
timer =
{'at daytime'},
httpResponses =
{
scriptVar,
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = Fronius_Meter,
},
execute = function(dz, item)
local IPFronius = dz.variables('UV_FroniusIP').value -- string variables IPFronius
if item.isTimer then
dz.openURL(
{
url = 'http://'..IPFronius..'/solar_api/v1/GetPowerFlowRealtimeData.fcgi',
callback = scriptVar,
})
return
end
if item.ok and item.isJSON then
local rt = item.json.Body.Data
dz.devices('Fronius_P_Grid').updateCustomSensor( (rt.P_Grid and rt.P_Grid.Value ) or 0)
dz.devices('Fronius_P_Load').updateCustomSensor( (rt.P_Load and rt.P_Load.Value ) or 0)
else
dz.log('There was a problem handling the request', dz.LOG_ERROR)
dz.log(item, dz.LOG_DEBUG)
end
end
}
local scriptVar = 'Fronius'
return
{
on =
{
timer =
{'at daytime'},
httpResponses =
{
scriptVar,
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = Fronius_Meter,
},
execute = function(dz, item)
local IPFronius = dz.variables('UV_FroniusIP').value -- string variables IPFronius
if item.isTimer then
dz.openURL(
{
url = 'http://'..IPFronius..'/solar_api/v1/GetPowerFlowRealtimeData.fcgi',
callback = scriptVar,
})
return
end
if item.ok and item.isJSON then
local rt = item.json.Body.Data
dz.utils.dumpTable(rt or item.json)
dz.devices('Fronius_P_Grid').updateCustomSensor( rt.P_Grid or 0)
dz.devices('Fronius_P_Load').updateCustomSensor( (rt.P_Load or 0)
else
dz.log('There was a problem handling the request', dz.LOG_ERROR)
dz.log(item, dz.LOG_DEBUG)
end
end
}
local scriptVar = 'Fronius'
return
{
on =
{
timer =
{'every minute at 5:20-20:45'},
httpResponses =
{
scriptVar,
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = Fronius_Meter,
},
execute = function(dz, item)
local IPFronius = dz.variables('UV_FroniusIP').value -- string variables IPFronius
if item.isTimer then
dz.openURL(
{
url = 'http://'..IPFronius..'/solar_api/v1/GetPowerFlowRealtimeData.fcgi',
callback = scriptVar,
})
return
end
if item.ok and item.isJSON then
local rt = item.json.Body.Data
dz.utils.dumpTable(rt or item.json)
dz.devices('Fronius_E_Total').updateCustomSensor( rt.E_Total or 0)
dz.devices('Fronius_E_Day').updateCustomSensor( rt.E_Day or 0)
else
dz.log('There was a problem handling the request', dz.LOG_ERROR)
dz.log(item, dz.LOG_DEBUG)
end
end
}
return
{
on =
{
timer =
{'every minute at 5:20-21:45'},
httpResponses =
{
scriptVar,
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = Fronius_Meter,
},
execute = function(dz, item)
local IPFronius = dz.variables('UV_FroniusIP').value -- string variables IPFronius
if item.isTimer then
dz.openURL(
{
url = 'http://'..IPFronius..'/solar_api/v1/GetPowerFlowRealtimeData.fcgi',
callback = scriptVar,
})
return
end
if item.ok and item.isJSON then
local rt = item.json.Body.Data
if not(rt) then
dz.log('There is no Body.Data in the JSON', dz.LOG_ERROR)
dz.utils.dumpTable(item.json)
else
dz.devices('Fronius_E_Total').updateCustomSensor( rt[1].E_Total or 0)
dz.devices('Fronius_E_Day').updateCustomSensor( rt[1].E_Day or 0)
end
else
dz.log('There was a problem handling the request', dz.LOG_ERROR)
dz.log(item, dz.LOG_DEBUG)
end
end
}
local scriptVar = 'Fronius'
return
{
on =
{
timer =
{'every minute'},
httpResponses =
{
scriptVar,
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = Fronius_Meter,
},
execute = function(dz, item)
local IPFronius = dz.variables('UV_FroniusIP').value -- string IPFronius variables
if item.isTimer then
dz.openURL(
{
url = 'http://'..IPFronius..'/solar_api/v1/GetPowerFlowRealtimeData.fcgi',
callback = scriptVar,
})
return
end
if item.ok and item.isJSON then
local rt = item.json.Body.Data.Site
if not(rt) then
dz.log('There is no Body.Data in the JSON', dz.LOG_ERROR)
dz.utils.dumpTable(item.json)
else
dz.devices('Fronius_E_Total').updateCustomSensor( rt.E_Total or 0)
dz.devices('Fronius_E_Day').updateCustomSensor( rt.E_Day or 0)
dz.devices('Pobór_PGE').updateCustomSensor( rt.P_Grid or 0)
dz.devices('Pobór_Dom').updateCustomSensor( rt.P_Load or 0)
dz.devices('P_PV').updateCustomSensor( rt.P_PV or 0)
end
else
dz.log('There was a problem handling the request', dz.LOG_ERROR)
dz.log(item, dz.LOG_DEBUG)
end
end
}