Small Script Probelm

Posted on
Sun Jul 20, 2014 6:38 pm
jltnol offline
Posts: 994
Joined: Oct 15, 2013

Small Script Probelm

So I'm trying to consolidate multiple triggers with scripts when possible... and while I've had some success, this one has me stuck.

This one is triggered anytime there is a change in the status of the lock..

I want to keep track of the time of the last status change, and what the last status update was

The time part of this works fine, but the status part doesn't. Regardless of the state the lock (on or off), the script always puts "Un-Locked!" into the variable...

Code: Select all
tell application "IndigoServer"
   set value of variable "LockTime" to (time string of (current date))
   if on state of device named "Front Door Lock" is "true" then
      set value of variable "FrontDoor" to "Locked!"
   else
      set value of variable "FrontDoor" to "Un-Locked!"
   end if
end tell


Do I need to do some kind of "get status", or does the "if on state..." line do the same thing?

Posted on
Sun Jul 20, 2014 7:55 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Small Script Probelm

on state returns an AppleScript boolean, so change the conditional to:

Code: Select all
   if on state of device named "Front Door Lock" is true then

Image

Posted on
Sun Jul 20, 2014 9:27 pm
jltnol offline
Posts: 994
Joined: Oct 15, 2013

Re: Small Script Probelm

Once again Thanks Matt..

All this tiny script lines help me use them in lots of different situations, and put bigger things together...

Cheers

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 14 guests