Page 1 of 1

Calling function asynchronously (not openURL)

Posted: Thursday 17 January 2019 23:15
by Masure
Hi,

First I want to thank the developper for the effort put in dzVents, it's a pleasure to script with.

I have a quite time consuming powershell script I want to call many times. I'm afraid doing this synchronously won't be great for the whole domoticz system.

What I'm willing to do is, on alarm system trigger, grab the jpg image from my camera and send it on my telegram notification discussion. I want to do this multiple times in a row, every few seconds for a couple of minutes.

I already have the script thats get the image and send it. The 2 http requests are done with powershell because it's very convenient to make mutipart/form-data request with it on Windows.

How can I make this ?

Regards

Re: Calling function asynchronously (not openURL)

Posted: Friday 18 January 2019 0:26
by waaren
Masure wrote: Thursday 17 January 2019 23:15 I have a quite time consuming powershell script I want to call many times. I'm afraid doing this synchronously won't be great for the whole domoticz system.
Did you already managed to call the powershell script with os.execute ? If so I would be interested to find out if you can also call it as a background script using the powershell Start-Job command.
Once you got that to work, it will be relatively easy to have dzVents trigger this command repeatedly, without blocking the entire domoticz eventSystem.

Re: Calling function asynchronously (not openURL)

Posted: Wednesday 23 January 2019 13:49
by Masure
Hi,

I already executed powershell scripts. All that was missing is executing it a non blocking fashion.

I did not think about making the async call in the powershell part :roll:, I was trying to do this in the lua code.

Start-Job did the trick perfectly => Thank you !