Page 1 of 2

Scheduled action doesn't work as expected

PostPosted: Mon Nov 17, 2014 11:42 am
by Umtauscher
Hi,

I have a puzzler for You:
I have a script action consisting of two curl commands that I execute in an action group.
Code: Select all
do shell script "/usr/bin/curl -s -G -m 20  'http://192.168.1.2/preset?switch=6&value=on'"
do shell script "/usr/bin/curl -s -G -m 20  'http://192.168.1.2/preset?switch=7&value=on'"

When I excute this Action Group via webinterface, IndigoTouch or the ExecuteAll button in the OSX-Client it works great. (These commands close the blinds on two windows via an external tcpip interface)
When I excute the same action via a indigo schedule on Sunset+60 minutes, it fails nearly every time.
Fail means that the blinds start and stop shortly after that. Normally this could be caused by sending the same command once again.
In the log, I can only see a single execution of the schedule.
What can that be? I hope anybody has some more ideas than me.
Thanks in advance
Wilhelm

Re: Scheduled action doesn't work as expected

PostPosted: Tue Nov 18, 2014 3:56 pm
by howartp
Any other triggers or actions (with conditions?) that interact with this same unit?

Have you tried executing manually at approximately the same time (sunset + 60) as the schedule to prove if any other triggers/ variables are in s different state at this time than when you were testing maybe earlier in the day?

Re: Scheduled action doesn't work as expected

PostPosted: Wed Nov 19, 2014 8:18 am
by Umtauscher
Thanks for your response.
There are no other Actions defined for that interface and no othe variables are involved.
I am suspecting, that the applescript /curl is terminated by indigo before it finishes, but I don't know how to verify that suspicion.

Re: Scheduled action doesn't work as expected

PostPosted: Wed Nov 19, 2014 8:48 am
by matt (support)
Hi Wilhelm,

My guess would be the embedded Web server in the blind controller isn't handling the back-to-back HTTP commands well. Try adding a "delay 3" command between the two do shell script calls to see if that helps.

Re: Scheduled action doesn't work as expected

PostPosted: Wed Nov 19, 2014 8:50 am
by Umtauscher
Hi Matt,

thanks, but I tried that already.
When I fire the action by hand, it works every time. It just fails, when the Schedule starts it.
I had the same interface working with my vera for years. There I used the wget to trigger the interface.
Do you know of any difference between wget and curl that could cause something like that?

Re: Scheduled action doesn't work as expected

PostPosted: Wed Nov 19, 2014 8:55 am
by matt (support)
Internally in Indigo there is no difference in how an action is executed (directly or via schedule/trigger), so the only thing I can think is that it is the time-of-day that it is executed that is making a difference. You said it fails "nearly every time", so I think what you are looking at is an intermittent failure (that we don't yet know the cause of) and it isn't really because of the schedule executing the action.

Re: Scheduled action doesn't work as expected

PostPosted: Wed Nov 19, 2014 9:04 am
by wiery
I think that given you are using -m 20, that you should put a delay of greater than 20 seconds between the execution of the two commands, as -m is the max time of exectiuon of the curl command.

Another option would be to actually create a shell script and put a sleep between the commands, you can also debug it better

Re: Scheduled action doesn't work as expected

PostPosted: Wed Nov 19, 2014 9:14 am
by Umtauscher
When I excute the action by hand, at least there are no power conserving actions on the Mac that are active, because I woke it before by activateing the webinterface or indigo-app.
When the schedule fires, the mac might be in some low power state.
I certainly disabled powernap and suspend, but the harddrive might be asleep.
Sorry, I'm speculating. Let me try to put another schedule a few minute before to wake it....we'll see tonight

Re: Scheduled action doesn't work as expected

PostPosted: Wed Nov 19, 2014 9:20 am
by Umtauscher
wiery wrote:
I think that given you are using -m 20, that you should put a delay of greater than 20 seconds between the execution of the two commands, as -m is the max time of exectiuon of the curl command.

Correct me if I'm wrong, but I think -m 20 defines the timeout if the server doesn't respond, not the time the curl command will always take.
So the two commands are excuted short after each other.
But you are right, that kills my theory about the sript beeing terminated prematurely, because both blinds start and both stop.
So at least the first command should get the required time.
But that in fact would mean, the script is excuted twice!

Re: Scheduled action doesn't work as expected

PostPosted: Wed Nov 19, 2014 9:50 am
by wiery
Sorry yes i should have been clearer. I meant -m as in the time out value but it could potentially take up to 20 seconds to complete.

I would definitely disable ALL power saving on the MAC, i'm pretty sure that is written somewhere in the pre-reqs for Indigo ( i could be imagining that ).

Personally I would have one shell script with a sleep between the commands and call the script from Indigo.

Re: Scheduled action doesn't work as expected

PostPosted: Wed Nov 19, 2014 10:14 am
by jay (support)
Did you disable sleep for the computer?

Re: Scheduled action doesn't work as expected

PostPosted: Wed Nov 19, 2014 10:23 am
by Umtauscher
Hi Jay,

yes certainly, the only powersaving that is activated is the harddrive which I put to sleep.
Don't bother, if you are certain, that there is no way the script could be run twice, I will try to find out myself.
Thanks

Re: Scheduled action doesn't work as expected

PostPosted: Wed Nov 19, 2014 10:47 am
by jay (support)
Another option would be to just write your script in Python rather than AppleScript. You could then use Python's urllib module to hit the URL directly rather than escaping to a shell script. Not sure it would solve your problem, but it would eliminate one moving piece.

Re: Scheduled action doesn't work as expected

PostPosted: Wed Nov 19, 2014 10:50 am
by Umtauscher
Ok, der schedule just failed again.
How would I do that in Python? It's worth a shot.

Re: Scheduled action doesn't work as expected

PostPosted: Wed Nov 19, 2014 11:29 am
by jay (support)
Did you attempt to run it manually at about the same time? What shows up in the event log around that time (include several minutes of log results).

Just use Python's urllib.urlopen method:

Code: Select all
import urllib
urllib.urlopen("http://192.168.1.2/preset?switch=6&value=on")


Untested of course, but that's close.