View unanswered posts | View active topics It is currently Tue Jun 18, 2013 5:38 pm



Reply to topic  [ 2 posts ] 
 AppleScript Implementation Help 
Author Message

Joined: May 01, 2011
Posts: 29
Post AppleScript Implementation Help
Hi-

I was on the forums and I saw how helpful you all are with using Indigo. I have been using Indigo since version 2.0 and I am a very happy customer. I was trying to figure out how to code a script for a garage door control and status check and was struggling. Can you please help?

Here is what I was thinking in my own code like language:


Devices:

Kitchen Keypad is an 8 button keypad in the kitchen where button 7 is the garage
Entry Keypad is an 8 button keypad in the foyer where button 7 is the garage
Stairway Keypad is an 8 button keypad in the stairway where button 7 is the garage
Garage Door is I/O Linc connected to Garage
ClosingTime is a variable to close garage door with a value of 12
GarageStatusGroup is a scene/group with Kitchen Keypad button 7 and Entry Keypad button 7 and Stairway keypad button 7
isGarageDoorClosed is a variable showing true or false. The Garage Sensor closed is a closed garage door and open is an open garage door.

Start Script

If GarageStatusGroup is toggled (turned on or off) (since the pressing of the button is most important)
then turn on Garage Door.
end if

Wait ClosingTime seconds

Repeat for 30 seconds
if isGarageDoor Closed = true
then turn off GarageStatusGroup
else turn on GarageStatusGroup
end if
end repeat

end script


The above would be my way to control and check the status of the garage door in a single action.


I also wanted a program to randomly check the status of the garage door on a timed basis:

This version checks all the states before sending a command:

start script

every 5 minutes

if isGarageDoorClosed = true and GarageStatusGroup is off
then do nothing and end program? (I dont know how to say this)
else
if isGarageDoorClosed = false and GarageStatusGroup is on
then do nothing and end program? (I dont know how to say this)
else
if isGarageDoorClosed = true and GarageStatusGroup is on
then turn off GarageStatusGroup
else
if isGarageDoorClosed = false and GarageStatusGroup is off
then turn on GarageStatusGroup
else
end if

end script

This version takes action and only checks sensor state. It is less code but it takes action regardless of the status already showing correctly.

start script

every 5 minutes

if isGarageDoorClosed = true
then turn off GarageStatusGroup
else
turn on GarageStatusGroup
end if

end script

I was also curious how in applescript I would turn on or off a keypad button, like:

if isGarageDoorClosed = true
then turn off Kitchen Keypad button 7
end if


I know my code is not correct but I was going more for the logic part. I just ordered the book you recommended from Amazon (AppleScript: The Definitive Guide, 2nd Edition). I really would appreciate the help. Thanks in advance.


Mon May 02, 2011 2:05 pm
Profile

Joined: Aug 13, 2006
Posts: 390
Location: Northern Idaho
Post Re: AppleScript Implementation Help
Here is the code I use to check my garage door status. You'll notice I don't check a variable value with Indigo but a hardware state instead. Sometimes the hardware inputs (in this case and EZIO8SA) do not get up updated on my system (usually because I have scripts running at the 5 or 10 minute intervals and some Insteon signals get missed by the receiving PLM.)

I use the first button of my KeypadLinc to indicate the status of my garage door (LED on is closed, LED off is open).

Code: Select all
--delay 10
tell application "Finder"
   set volume 5.3
end tell
tell application "IndigoServer"
   status request "EZIO8SA"
   delay 10
   set firstBinaryInput to item 1 of (get binary inputs of device "EZIO8SA")
   if firstBinaryInput is equal to true then set value of variable "Garagedoor" to "false"
   if firstBinaryInput is equal to true then turn on "Keypadlinc"
   if firstBinaryInput is equal to false then set value of variable "Garagedoor" to "true"
   if firstBinaryInput is equal to false then turn off "Keypadlinc"
   if value of variable "Garagedoor" is "true" then
      say "Garage door is open"
      log "GARAGE DOOR IS OPEN"
      return firstBinaryInput
   end if
   --return firstBinaryInput
end tell


I know this post doesn't address all of your issues, but hopefully you can use a large part of my code to do what you want. I am not sure how to applescript the botton 7 on the keypadLinc, I just use the Insteon Group on/off action in Indigo to control individual LEDs other than button 1.

_________________
Image


Sat May 07, 2011 1:11 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.