http command
Posted: Wednesday 12 June 2019 10:08
As you can add multipple devices to a scene, would be great to have also the option to add multipple http commands
Join 16,000+ members discussing home automation with Domoticz. Get help with Zigbee, ZWave, MQTT, scripting, and 150+ integrations
https://forum.domoticz.com/
Code: Select all
return {
on = {
timer = {'every 1 minutes'},
httpResponses = { 'oid' }
},
execute = function(dz, item)
if (item.isTimer) then
dz.openURL({
url = 'http://192.168.178.20/getentry.cgi?&oid=10',
method = 'GET',
callback = 'oid',
})
end
if (item.isHTTPResponse) then
if (item.ok) then
local pv_data = dz.utils.toJSON(item.data)
dz.log('PVSW30 ' .. pv_data, dz.LOG_ERROR)
else
dz.log('PVSW30 not OK', dz.LOG_ERROR)
end
end
end
}Code: Select all
2021-05-11 16:57:00.621 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2021-05-11 16:57:01.082 Status: dzVents: Info: Handling httpResponse-events for: "oid
2021-05-11 16:57:01.082 Status: dzVents: Info: ------ Start internal script: PVSW30 dz: HTTPResponse: "oid"
2021-05-11 16:57:01.086 Status: dzVents: Error (2.4.19): PVSW30 "-1"
2021-05-11 16:57:01.086 Status: dzVents: Info: ------ Finished PVSW30 dz
Code: Select all
http://192.168.178.20/getentry.cgi?&oid=10
{ "oid" : 10, "label" : "UserConfig.Inverter.Info.SystemName", "type" : "S", "val" : "PVSW30", "uitext" : "System name", "savetype" : 1, "factor" : 1.000000, "unit" : "", "portal" : 1, "AutoZero" : 0, "fb" : 1 }Can you try this one? It is not complete but should point you in the right directionSagitarius wrote: Tuesday 11 May 2021 17:08 thanks, I had a view on this but the 2nd part, looks like, is a bit complex for me yet.
Any further detailed information is really appreciated
Code: Select all
local scriptVar = 'oid'
return
{
on =
{
timer =
{
'every 1 minutes'
},
httpResponses =
{
scriptVar,
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = scriptVar,
},
execute = function(dz, item)
if item.isTimer then
dz.openURL(
{
url = 'http://192.168.178.20/getentry.cgi?&oid=10',
method = 'GET',
callback = scriptVar,
})
elseif item.isHTTPResponse and item.ok then
dz.log('item.data: ' .. item.data, dz.LOG_FORCE)
dz.utils.dumpTable(item) -- only during debug
local pv_data = dz.utils.fromJSON(item.data) -- you want to convert a JSON to a Lua table
dz.utils.dumpTable(pv_data) -- only during debug
else
dz.log('PVSW30 not OK', dz.LOG_ERROR)
end
end
}
The call only returns -1 so not much to work with. It should return the same information as what comes back if you enter this http in your browser. Can you try to do this from an incognito browser page and post the result?Sagitarius wrote: Friday 14 May 2021 11:58 that's what I get, but I'm not sure what kind of information would help.