Below is the script:
Code: Select all
local scriptVar = 'iDRAC_Temp'
return
{
on =
{
timer =
{
'every 1 minutes', -- just an example to trigger the request
},
httpResponses =
{
scriptVar, -- must match with the callback passed to the openURL command
},
},
logging =
{
--level = domoticz.LOG_DEBUG,
marker = scriptVar,
},
execute = function(dz, item)
if item.isTimer then
dz.openURL({
url = 'https://user:[email protected]/redfish/v1/Chassis/System.Embedded.1/Thermal',
method = 'GET',
callback = scriptVar, -- see httpResponses above.
})
return
end
if item.isJSON then
local inletTemp = -999
local exhaustTemp = -999
local cpu1Temp = -999
subTable = item.json.Temperatures
for index, record in ipairs(subTable) do
if record.Name:find('Inlet Temp') then
inletTemp = record.ReadingCelsius
elseif record.Name:find('Exhaust Temp') then
exhaustTemp = record.ReadingCelsius
elseif record.Name:find('CPU1 Temp') then
cpu1Temp = record.ReadingCelsius
end
end
if (inletTemp == -999) or (inletTemp == 0) or (inletTemp == nil) then
dz.log('There was a problem getting a reading for Inlet', dz.LOG_ERROR)
else
dz.devices(395).updateTemperature(inletTemp)
dz.log('Inlet: ' .. inletTemp, dz.LOG_DEBUG)
end
if (exhaustTemp == -999) or (exhaustTemp == 0) or (exhaustTemp == nil) then
dz.log('There was a problem getting a reading for exhaust', dz.LOG_ERROR)
else
dz.devices(396).updateTemperature(exhaustTemp)
dz.log('Exhaust: ' .. exhaustTemp, dz.LOG_DEBUG)
end
if (cpu1Temp == -999) or (cpu1Temp == 0) or (cpu1Temp == nil) then
dz.log('There was a problem getting a reading for CPU1', dz.LOG_ERROR)
else
dz.devices(397).updateTemperature(cpu1Temp)
dz.log('CPU1: ' .. cpu1Temp, dz.LOG_DEBUG)
end
else
dz.log('There was a problem handling the request', dz.LOG_ERROR)
dz.log(item, dz.LOG_ERROR)
end
end
}

This results in errors:
Code: Select all
2022-07-31 09:04:00.530 Status: dzVents: Info: iDRAC_Temp: ------ Start internal script: DZ_iDRAC_Temp:, trigger: "every 1 minutes"
2022-07-31 09:04:00.531 Status: dzVents: Debug: iDRAC_Temp: OpenURL: url = https://user:[email protected]/redfish/v1/Chassis/System.Embedded.1/Thermal
2022-07-31 09:04:00.531 Status: dzVents: Debug: iDRAC_Temp: OpenURL: method = GET
2022-07-31 09:04:00.531 Status: dzVents: Debug: iDRAC_Temp: OpenURL: post data = nil
2022-07-31 09:04:00.531 Status: dzVents: Debug: iDRAC_Temp: OpenURL: headers = nil
2022-07-31 09:04:00.531 Status: dzVents: Debug: iDRAC_Temp: OpenURL: callback = iDRAC_Temp
2022-07-31 09:04:00.533 Status: dzVents: Info: iDRAC_Temp: ------ Finished DZ_iDRAC_Temp
2022-07-31 09:04:00.539 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2022-07-31 09:04:00.773 Status: dzVents: Info: iDRAC_Temp: ------ Start internal script: DZ_iDRAC_Temp: HTTPResponse: "iDRAC_Temp"
2022-07-31 09:04:00.777 Status: dzVents: Info: iDRAC_Temp: ------ Finished DZ_iDRAC_Temp
2022-07-31 09:04:00.686 Error: Error opening url: https://user:[email protected]/redfish/v1/Chassis/System.Embedded.1/Thermal
2022-07-31 09:04:00.774 Error: dzVents: Error: (3.1.8) iDRAC_Temp: HTTP/1.1 response: 35 ==>> SSL connect error
2022-07-31 09:04:00.774 Error: dzVents: Error: (3.1.8) iDRAC_Temp: There was a problem handling the request
2022-07-31 09:04:00.774 Error: dzVents: Error: (3.1.8) iDRAC_Temp: {["_contentType"]="", ["isJSON"]=false, ["isShellCommandResponse"]=false, ["ok"]=false, ["isHardware"]=false, ["isCustomEvent"]=false, ["baseType"]="httpResponse", ["trigger"]="iDRAC_Temp", ["isVariable"]=false, ["isSystem"]=false, ["callback"]="iDRAC_Temp", ["isSecurity"]=false, ["isGroup"]=false, ["data"]="", ["isTimer"]=false, ["isHTTPResponse"]=true, ["statusText"]="SSL connect error", ["isScene"]=false, ["isDevice"]=false, ["statusCode"]=35, ["isXML"]=false, ["dump"]=function, ["protocol"]="HTTP/1.1", ["headers"]={}}