Here's the code:
- Code: Select all
set {year:y, month:m, day:d} to current date
set str to (m as string) & " " & (d as string) & " " & (y as string)
set today to date str
set tomorrow to today + (60 * 60 * 24)
tell application "Calendar"
tell calendar "My Home Calendar"
set curr to every event whose start date is greater than or equal to today and start date is less than or equal to tomorrow
delay 10
if (count of items of curr) is greater than 0 then
repeat with b in curr
set a to summary of b
if a is equal to "Guest" then
tell application "IndigoServer"
if value of variable guestMode is not equal to "true" then
set value of variable "guestMode" to "true"
else
log "Not setting guestMode again, repeat"
end if
end tell
else
tell application "IndigoServer"
set value of variable "guestMode" to "false"
log "Looks like no sleepover tonight!"
end tell
end if
end repeat
else
tell application "IndigoServer"
set value of variable "guestMode" to "false"
log "Looks like no sleepover tonight!"
end tell
end if
end tell
end tell