making some progress

Posted on
Wed Feb 18, 2004 7:40 pm
ddeppe offline
Posts: 23
Joined: Dec 13, 2003

making some progress

Ok, I figured out I was using an invalid command. Below is the revised script:

Code: Select all
-- note: depends on nightly enablment of FishLightActive variable
tell application "Indigo" 
  if daylight then
    log "Andrews motion during daylight"
    remove delayed actions for device "Andrews Light"
    remove delayed actions for device "Andrews Closet"
   all off F in 10 * 60
  else -- it is nighttime
    if (FishLitTime <= 120) then
      if (FishLightActive = true) then
        if (on state of device "Andrews Fish Light" is false) then
          log "Turning on Andrews Fish Light"
          turn on "Andrews Fish Light" for 10 * 60
          set value of variable "FishLitTime" to "FishLitTime" + 10
          remove delayed actions for trigger "Andrews Motion"
          set value of variable "FishLightActive" to False
          set value of variable "FishLightActive" to True in 8 * 60
        else -- fish light is already on
          log "Leaving Andrews Fish Light on additional 10 min's"
          remove delayed actions for device "Andrews Fish Light"
          turn off "Andrews Fish Light" in 10 * 60
          set "FishLitTime" to FishLitTime + 8
          remove delayed actions for trigger "Andrews Motion"
         set value of variable "FishLightActive" to False
          set value of variable "FishLightActive" to True in 8 * 60
       end if -- state of fish light
      remove delayed actions for device "Andrews Light"
      dim "Andrews Light" by 15  in 35 * 60
      turn off "Andrews Light" in 40 * 60
    else -- FishLitTime has reached daily limit
      set value of variable "FishLightActive" to False
      set value of variable "FishLitTime" to 0
      log "Andrews fishlight has reached limit - disabling until next night"
     end if -- Fishlight Active
   end if -- FishLitTime
end if -- daylight 
end tell


But now I'm getting the following error "Can't get true in 8. Access not allowed." on the following line:
set value of variable "FishLightActive" to True in 8 * 60

Posted on
Wed Feb 18, 2004 7:45 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: making some progress

See my post on the other thread.

Regards,
Matt

Posted on
Wed Feb 18, 2004 8:00 pm
ddeppe offline
Posts: 23
Joined: Dec 13, 2003

(No subject)

I found the issue - just had to enclose true in () - also made some other fixes. Below is the revised code:
-- note: depends on nightly enablment of FishLightActive variable
tell application "Indigo"
if daylight then
log "Andrews motion during daylight"
remove delayed actions for device "Andrews Light"
remove delayed actions for device "Andrews Closet"
all off (F in 10) * 60
else -- it is nighttime
if (FishLitTime <= 120) then
if (FishLightActive = true) then
if (on state of device "Andrews Fish Light" is false) then
log "Turning on Andrews Fish Light"
turn on "Andrews Fish Light" for 10 * 60
set value of variable "FishLitTime" to "FishLitTime" + 10
remove delayed actions for trigger "Andrews Motion"
set value of variable "FishLightActive" to false
set value of variable "FishLightActive" to true * 60
else -- fish light is already on
log "Leaving Andrews Fish Light on additional 10 min's"
remove delayed actions for device "Andrews Fish Light"
turn off "Andrews Fish Light" in 10 * 60
set value of "FishLitTime" to FishLitTime + 8
remove delayed actions for trigger "Andrews Motion"
set value of variable "FishLightActive" to false
set value of variable "FishLightActive" to true * 60
end if -- state of fish light
remove delayed actions for device "Andrews Light"
dim "Andrews Light" by 15 in 35 * 60
turn off "Andrews Light" in 40 * 60
else -- FishLitTime has reached daily limit
set value of variable "FishLightActive" to false
set value of variable "FishLitTime" to 0
log "Andrews fishlight has reached limit - disabling until next night"
end if -- Fishlight Active
end if -- FishLitTime
end if -- daylight
end tell

Posted on
Wed Feb 18, 2004 9:21 pm
ddeppe offline
Posts: 23
Joined: Dec 13, 2003

more progress

Ok, I've made more progress - figured out I simply can't change a variable with a delay - only option was to create a "group" which had the simple reason for existence to modify the variable, and then I was able to execute that "group" with a delay. The next problem I ran into was that I needed to convert a string into an integer - Indigo is storing the value as a string, but I need it as an integer in order to pass the if validation as true. I solved it by creating a local variable as an integer from the string. Not sure if there is a better way. Below is my the current version of my code:
Code: Select all
-- note: depends on nightly enablment of FishActive variable
tell application "Indigo"
   if daylight then
      log "Andrews motion during daylight"
      remove delayed actions for device "Andrews Light"
      remove delayed actions for device "Andrews Closet"
      all off (F in 10) * 60
   else -- it is nighttime
      if (value of variable "FishActive" = "true") then
         set FishLitTime to (value of variable "FishLitTime")
         if (FishLitTime > 120) then
            if (on state of device "Andrews Fish Light" is false) then
               log "Turning on Andrews Fish Light"
               turn on "Andrews Fish Light" for 10 * 60
               set value of variable "FishLitTime" to (value of variable "FishLitTime") + 10
               remove delayed actions for trigger "Andrews Motion"
               set value of variable "FishActive" to false
               execute group "Enable FishActive" in 10 * 60
            else -- fish light is already on
               log "Leaving Andrews Fish Light on additional 10 min's " & value of variable "FishLitTime"
               remove delayed actions for device "Andrews Fish Light"
               turn off "Andrews Fish Light" in 10 * 60
               set value of variable "FishLitTime" to (value of variable "FishLitTime") + 8
               log "new value of FishLitTime is: " & value of variable "FishLitTime"
               remove delayed actions for trigger "Andrews Motion"
               set value of variable "FishActive" to false
               execute group "Enable FishActive" in 10 * 60
            end if -- state of fish light
            remove delayed actions for device "Andrews Light"
            dim "Andrews Light" by 15 in 35 * 60
            turn off "Andrews Light" in 40 * 60
         else -- FishLitTime has reached daily limit
            log "Andrews fishlight has reached limit - disabling until next night " & value of variable "FishLitTime"
            -- set value of variable "FishActive" to false
            -- set value of variable "FishLitTime" to 0
         end if -- FishLitTime
      else
         log "FishActive is false"
      end if -- FishActive
   end if -- daylight 
end tell

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 28 guests