Morning and evening colors reminder

Posted on
Mon Jul 04, 2011 8:22 pm
Brandt offline
User avatar
Posts: 414
Joined: Dec 24, 2008
Location: Mission Viejo, CA

Morning and evening colors reminder

Since it's fourth of July weekend, I created reminders for morning and evening colors.

-Raise the flag smartly (quickly) at 8am
-Lower the flag slowly at sunset


Schedule Actions:

Morning Colors -
Schedule: 7:55am
Conditions: Always
Actions:
Execute AS

Code: Select all
property emailAddress : "1234567890@mms.att.net"

tell application "IndigoServer"
    set emailSubject to "It's " & time string of (current date) & ", Morning Colors in 5 Minutes!"
    set emailBody to "Evening colors at sunset, " & time string of (calculate sunset)
    send email to emailAddress with subject emailSubject with body emailBody
end tell




Evening Colors -
Schedule: Sunset -5
Conditions: Always
Actions:
Execute AS

Code: Select all
property emailAddress : "1234567890@mms.att.net"

tell application "IndigoServer"
    set emailBody to "Evening colors in 5 minutes at " & time string of (calculate sunset)
    send email to emailAddress with body emailBody
end tell




If you want it for some reason to sound military, you make it say "First call, first call to colors" 5 minutes ahead, and then say "Attention to colors." during, and then "Carry on" a minute or so later.
Last edited by Brandt on Fri Jul 22, 2011 9:30 am, edited 3 times in total.

Indigo 7 w/ Dual-Band 2413U PLM
macOS High Sierra 10.13.x
2011 iMac 3.4 GHz Intel Core i7

Posted on
Tue Jul 05, 2011 4:06 pm
Brandt offline
User avatar
Posts: 414
Joined: Dec 24, 2008
Location: Mission Viejo, CA

Re: Morning and evening colors reminder

Hmm, I got a text message from this script this morning at 7:55 but it said the current time was 10:47pm....is "time string of (current date)" the correct way to get the time?

Thanks!

Indigo 7 w/ Dual-Band 2413U PLM
macOS High Sierra 10.13.x
2011 iMac 3.4 GHz Intel Core i7

Posted on
Tue Jul 05, 2011 5:04 pm
jay (support) offline
Site Admin
User avatar
Posts: 18261
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Morning and evening colors reminder

Yep, that's correct. Not sure why you got that time. The script works correctly for me.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jul 05, 2011 5:33 pm
Brandt offline
User avatar
Posts: 414
Joined: Dec 24, 2008
Location: Mission Viejo, CA

Re: Morning and evening colors reminder

jay wrote:
Yep, that's correct. Not sure why you got that time. The script works correctly for me.



I've also had the email sending hang on me while I was testing where the log tells me sending failed or timed out. In that case I restarted the indigo server.

Indigo 7 w/ Dual-Band 2413U PLM
macOS High Sierra 10.13.x
2011 iMac 3.4 GHz Intel Core i7

Posted on
Wed Jul 06, 2011 10:14 am
Brandt offline
User avatar
Posts: 414
Joined: Dec 24, 2008
Location: Mission Viejo, CA

Re: Morning and evening colors reminder

jay wrote:
Yep, that's correct. Not sure why you got that time. The script works correctly for me.



Got the same timestamp in the text message this morning at 7:55am as I got yesterday morning at 7:55am (noted in bold) :

It's 10:47:04 PM, Morning Colors in 5 Minutes!
-----------------------------------
Evening colors at sunset
Tuesday, July 5, 2011
8:04:23 PM



It's 10:47:04 PM, Morning Colors in 5 Minutes!
-----------------------------------
Evening colors at sunset
Wednesday, July 6, 2011
8:04:13 PM



Also it looks like "time string" of the calculated sunset also didn't work in either text message....

Indigo 7 w/ Dual-Band 2413U PLM
macOS High Sierra 10.13.x
2011 iMac 3.4 GHz Intel Core i7

Posted on
Wed Jul 06, 2011 10:43 am
jay (support) offline
Site Admin
User avatar
Posts: 18261
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Morning and evening colors reminder

Do you have the right timezone specified for your Mac? And the date/time is correct? I just created an identical schedule, set it for 11:35, and this is what I got:

It's 11:34 AM, Morning Colors in 5 Minutes!

Evening colors at sunset, 8:36 PM


A minute early, which probably means the actual execution happened on a sub-second. The evening sunset time seems right.

As for your sunset times, are you sure those times are incorrect? They seem reasonable to me.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jul 06, 2011 11:20 am
Brandt offline
User avatar
Posts: 414
Joined: Dec 24, 2008
Location: Mission Viejo, CA

Re: Morning and evening colors reminder

jay wrote:
Do you have the right timezone specified for your Mac? And the date/time is correct? I just created an identical schedule, set it for 11:35, and this is what I got:

It's 11:34 AM, Morning Colors in 5 Minutes!

Evening colors at sunset, 8:36 PM


A minute early, which probably means the actual execution happened on a sub-second. The evening sunset time seems right.

As for your sunset times, are you sure those times are incorrect? They seem reasonable to me.


Forget the part about the sunset date, for some reason I could have sworn i was using "time string of (calculate sunset)" but I wasnt, i was only using "(calculate sunset)" ( i was referencing my original post, but somehow it didn't make it into the actual script )

The date and time for my mac is correct:

Code: Select all
bdaniels-mini:~ bdaniels$ date
Wed Jul  6 10:05:55 PDT 2011

bdaniels-mini:~ bdaniels$ sudo systemsetup -gettimezone
Time Zone: US/Pacific



Further testing:

When I click "Execute Actions Now" is when I get the 10:47:04 PM "time string of (current date)" I believe this is the time that I actually created this script two days ago.
When I click "run" inside the apple script window, I get the correct time of "time string of (current date)"

Indigo 7 w/ Dual-Band 2413U PLM
macOS High Sierra 10.13.x
2011 iMac 3.4 GHz Intel Core i7

Posted on
Wed Jul 06, 2011 12:13 pm
matt (support) offline
Site Admin
User avatar
Posts: 21429
Joined: Jan 27, 2003
Location: Texas

Re: Morning and evening colors reminder

The problem is you are storing the string in a property. AppleScript properties are actually saved in the AppleScript context, and the calculation to assign the property only occurs the first time the script is executed.

Instead, don't use a property. Just store in an AppleScript (not Indigo) variable. That will then get calculated every time the script is executed, which is what you want.

Image

Posted on
Wed Jul 06, 2011 12:16 pm
Brandt offline
User avatar
Posts: 414
Joined: Dec 24, 2008
Location: Mission Viejo, CA

Re: Morning and evening colors reminder

support wrote:
The problem is you are storing the string in a property. AppleScript properties are actually saved in the AppleScript context, and the calculation to assign the property only occurs the first time the script is executed.

Instead, don't use a property. Just store in an AppleScript (not Indigo) variable. That will then get calculated every time the script is executed, which is what you want.



Thanks Matt this sounds like it will work, I am still an AS newbie and was going off of the example from the wiki.

Indigo 7 w/ Dual-Band 2413U PLM
macOS High Sierra 10.13.x
2011 iMac 3.4 GHz Intel Core i7

Posted on
Wed Jul 06, 2011 12:34 pm
jay (support) offline
Site Admin
User avatar
Posts: 18261
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Morning and evening colors reminder

Yep, didn't spot the property, but that's exactly what it's doing. Which example in the wiki? It shouldn't be using a property either so I'll fix that.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jul 06, 2011 12:40 pm
Brandt offline
User avatar
Posts: 414
Joined: Dec 24, 2008
Location: Mission Viejo, CA

Re: Morning and evening colors reminder

Thank you again Matt, It works great. I've updated my original post.

Here is the wiki example I used, except it is not using any function calls in the properties so it should be OK, just as a newbie I did not know that.

http://www.perceptiveautomation.com/wik ... stom_email

Indigo 7 w/ Dual-Band 2413U PLM
macOS High Sierra 10.13.x
2011 iMac 3.4 GHz Intel Core i7

Posted on
Thu Jul 07, 2011 10:17 am
Brandt offline
User avatar
Posts: 414
Joined: Dec 24, 2008
Location: Mission Viejo, CA

Re: Morning and evening colors reminder

pomprocker wrote:
I've also had the email sending hang on me while I was testing where the log tells me sending failed or timed out. In that case I restarted the indigo server.


Well this morning the email didn't come at 7:55, I didnt get it until 9:15. I looked in the logs and there was a send email failed/timeout type of message. I am seeing this message all too often to where I'm not sure how reliable it is.

Is there any way to remedy this?

Indigo 7 w/ Dual-Band 2413U PLM
macOS High Sierra 10.13.x
2011 iMac 3.4 GHz Intel Core i7

Posted on
Thu Jul 07, 2011 10:42 am
jay (support) offline
Site Admin
User avatar
Posts: 18261
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Morning and evening colors reminder

Please post the exact message you saw. Generally, that means that your outbound mail server isn't responding for some reason so it goes into retry mode.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Jul 07, 2011 3:11 pm
Brandt offline
User avatar
Posts: 414
Joined: Dec 24, 2008
Location: Mission Viejo, CA

Re: Morning and evening colors reminder

jay wrote:
Please post the exact message you saw. Generally, that means that your outbound mail server isn't responding for some reason so it goes into retry mode.



Code: Select all
...
2011-07-07 08:05:00     Error   email send timeout
2011-07-07 08:05:00     Error   email re-send scheduled in 10 minutes
...
2011-07-07 08:25:00     Error   email send timeout
2011-07-07 08:25:00     Error   email re-send scheduled in 10 minutes
...
2011-07-07 08:45:00     Error   email send timeout
2011-07-07 08:45:00     Error   email re-send scheduled in 10 minutes
...
2011-07-07 08:55:00     Email Sent      to "1234567890@mms.att.net"; subject "It's 7:55:00 AM, Morning Colors in 5 Minutes!"
...


So the schedule is at 7:55am, which I see nothing. I also see nothing at 8:15, 8:35, and 8:55 when it says it will re-try. I ended up receiving it at 9:15.
Last edited by Brandt on Tue Sep 10, 2013 8:27 pm, edited 1 time in total.

Indigo 7 w/ Dual-Band 2413U PLM
macOS High Sierra 10.13.x
2011 iMac 3.4 GHz Intel Core i7

Posted on
Thu Jul 07, 2011 4:30 pm
jay (support) offline
Site Admin
User avatar
Posts: 18261
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Morning and evening colors reminder

Yep - those errors mean that your SMTP server wasn't responding correctly. It looks like your SMTP server is holding the connection open for 10 minutes before we get a timeout, then we wait for 10 minutes before trying again, for a total of 20 minutes. Not sure why that first part is taking 10 minutes, seems like it should timeout faster than that. Someone (can't find the thread) was having a similar issue and it turned out to be his server-side virus checker going bananas.

I'd check with your ISP to see if they're having some issues - I don't believe we've changed the SMTP code since Indigo 2.0.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Who is online

Users browsing this forum: No registered users and 2 guests