Scheduled action doesn't work as expected

Posted on
Mon Nov 17, 2014 11:42 am
Umtauscher offline
User avatar
Posts: 395
Joined: Oct 03, 2014
Location: Cologne, Germany

Scheduled action doesn't work as expected

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

Posted on
Tue Nov 18, 2014 3:56 pm
howartp offline
Posts: 3592
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Scheduled action doesn't work as expected

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?

Posted on
Wed Nov 19, 2014 8:18 am
Umtauscher offline
User avatar
Posts: 395
Joined: Oct 03, 2014
Location: Cologne, Germany

Re: Scheduled action doesn't work as expected

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.

Posted on
Wed Nov 19, 2014 8:48 am
matt (support) offline
Site Admin
User avatar
Posts: 19127
Joined: Jan 27, 2003
Location: Texas

Re: Scheduled action doesn't work as expected

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.

Image

Posted on
Wed Nov 19, 2014 8:50 am
Umtauscher offline
User avatar
Posts: 395
Joined: Oct 03, 2014
Location: Cologne, Germany

Re: Scheduled action doesn't work as expected

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?

Posted on
Wed Nov 19, 2014 8:55 am
matt (support) offline
Site Admin
User avatar
Posts: 19127
Joined: Jan 27, 2003
Location: Texas

Re: Scheduled action doesn't work as expected

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.

Image

Posted on
Wed Nov 19, 2014 9:04 am
wiery offline
Posts: 288
Joined: Jun 02, 2008
Location: Ireland

Re: Scheduled action doesn't work as expected

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

Posted on
Wed Nov 19, 2014 9:14 am
Umtauscher offline
User avatar
Posts: 395
Joined: Oct 03, 2014
Location: Cologne, Germany

Re: Scheduled action doesn't work as expected

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

Posted on
Wed Nov 19, 2014 9:20 am
Umtauscher offline
User avatar
Posts: 395
Joined: Oct 03, 2014
Location: Cologne, Germany

Re: Scheduled action doesn't work as expected

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!

Posted on
Wed Nov 19, 2014 9:50 am
wiery offline
Posts: 288
Joined: Jun 02, 2008
Location: Ireland

Re: Scheduled action doesn't work as expected

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.

Posted on
Wed Nov 19, 2014 10:14 am
jay (support) offline
Site Admin
User avatar
Posts: 15467
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Scheduled action doesn't work as expected

Did you disable sleep for the computer?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Nov 19, 2014 10:23 am
Umtauscher offline
User avatar
Posts: 395
Joined: Oct 03, 2014
Location: Cologne, Germany

Re: Scheduled action doesn't work as expected

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

Posted on
Wed Nov 19, 2014 10:47 am
jay (support) offline
Site Admin
User avatar
Posts: 15467
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Scheduled action doesn't work as expected

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.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Nov 19, 2014 10:50 am
Umtauscher offline
User avatar
Posts: 395
Joined: Oct 03, 2014
Location: Cologne, Germany

Re: Scheduled action doesn't work as expected

Ok, der schedule just failed again.
How would I do that in Python? It's worth a shot.

Posted on
Wed Nov 19, 2014 11:29 am
jay (support) offline
Site Admin
User avatar
Posts: 15467
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Scheduled action doesn't work as expected

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.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Who is online

Users browsing this forum: No registered users and 1 guest