Page 1 of 1

cookie support in dzVents

Posted: Sunday 28 October 2018 10:50
by akamming
Hi,

i created a dzvents script which sends a Notification if i have to put my garbage container at the road by accessing the API of the company which collects the garbage. This API uses cookies. And since domoticz.openURL does not support cookies i had to use curl. Unfortunately this does not work as an asynchronous mechanism, so sometimes when the internet is slow my domoticz 'hangs' on completing this request.

my suggestion would therefore be to extend the domoticz.openURL function with cookiesupport, by adding a 'cookie' field to the definitiion, e.g.


domoticz.openURL({
url = 'http://domain/path/to/something',
method = 'POST',
callback = 'mycallbackstring',
cookie = 'cookiedata'
postData = {
paramA = 'something',
paramB = 'something else'
}
})


so i can change this curl statement to domoticz.openURL command

Code: Select all

curl --cookie "RovaLc_inwoners={\"Id\":160266,\"ZipCode\":\"8013TP\",\"HouseNumber\":\"10\",\"HouseAddition\":null,\"Municipality\":\"Zwolle\",\"Province\":null,\"Firstname\":null,\"Lastname\":null,\"UserAgent\":\"\",\"School\":null,\"Street\":null,\"Country\":null,\"Portal\":null,\"AreaLevel\":5,\"City\":\"Zwolle\",\"Ip\":null}" https://www.rova.nl/api/TrashCalendar/GetCalendarItems?portal=inwoners
Would this be possible? If not? Is there another way to make this an asynchronous call in dzvents?

Re: cookie support in dzVents

Posted: Tuesday 05 May 2020 13:29
by stephanvdplas
Bump

This would be a very nice step in making my implementation OS-independent.

Re: cookie support in dzVents

Posted: Wednesday 06 May 2020 0:25
by waaren
stephanvdplas wrote: Tuesday 05 May 2020 13:29 This would be a very nice step in making my implementation OS-independent.
I would also like to have this functionality in domoticz / dzVents but this cannot be solved in dzVents. DzVents just uses the openURL API domoticz provides. Until then using io.popen or os.execute with a curl running in the background and a follow up triggered by a customEvent is a proven and asynchronous work-around that will not block the eventSystem.

I am aware that the dzVents- and OS script code cannot be the same for Windows and for Linux based systems but it is possible to use such an approach for both OS.

Re: cookie support in dzVents

Posted: Wednesday 06 May 2020 19:34
by stephanvdplas
agreed, but still would be nice if things could be solved native-dzvents.