View unanswered posts | View active topics It is currently Tue May 21, 2013 5:27 pm



Reply to topic  [ 11 posts ] 
 TriggerLinc Button 1 & Applescript 
Author Message
User avatar

Joined: Apr 26, 2011
Posts: 50
Location: United States
Post TriggerLinc Button 1 & Applescript
Could someone please explain how to check the state of a device through Applescript for a TriggerLinc's button 1. So far I got it to work for button 2 (see code below), but can't figure out how to do button 1. I've got a pressure sensitive mat hooked up to a TriggerLinc's external sensor terminals.


Button 2 - Applescript:

Code: Select all
if (on state of device "Sofa - Pressure Sensitive Mat" is true) then
    
   -- do stuff
    
end if


Tue Apr 26, 2011 5:28 pm
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6654
Location: Austin, Texas
Post Re: TriggerLinc Button 1 & Applescript
The TriggerLinc's wired terminals behave identically to the magnetic sensor - they turn the state of the TL on/off - you can't differentiate between the two.

_________________
Jay (Indigo Support)
Image


Wed Apr 27, 2011 6:41 am
Profile WWW
User avatar

Joined: Apr 26, 2011
Posts: 50
Location: United States
Post Re: TriggerLinc Button 1 & Applescript
Ok, I understand that the wired and magnetic is the same, but I'm still a little confused. I've tried switching the "true" in the if statement in my first reply to "false" and the code doesn't work in detecting the on for button 1. In the event log (see below), it gives me an "on" command on button 2 when put it up to the magnet and an "on" command on button 1 when I take it away from the magnet.

How do I check the state of a device Applescript code-wise for an "on" command for button 1? It would help a lot if you showed me how it would look like in an if statement.

Code: Select all
  Received INSTEON    "Sofa - Pressure Sensitive Mat" on (button 2)
  Received INSTEON    "Sofa - Pressure Sensitive Mat" on (button 1)


Wed Apr 27, 2011 1:55 pm
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6654
Location: Austin, Texas
Post Re: TriggerLinc Button 1 & Applescript
Button/Group 1/2 don't represent state in any way - they are simply commands sent when the TL opens/closes respectively (depending on how you have the jumper set). The TriggerLinc itself doesn't maintain state so there's no way to query state from it. You currently have the jumper off, so what you're seeing is Button 1 ON when the TL opens, Button 2 ON when the TL closes.

If you replace the jumper, Indigo will track the state for you, so that all you need to do is:

Code: Select all
on state of device "Sofa - Pressure Sensitive Mat"


That will return true if it's open, false if it's closed. Indigo will only maintain it's pseudo-state for the TL if the jumper is installed (so Button/Group 1 ON means open, Button/Group 1 OFF means closed, and Button/Group 2 is unused).

_________________
Jay (Indigo Support)
Image


Wed Apr 27, 2011 3:23 pm
Profile WWW
User avatar

Joined: Apr 26, 2011
Posts: 50
Location: United States
Post Re: TriggerLinc Button 1 & Applescript
LOL, what a difference a jumper makes. I got it to work successfully. Thanks for explaining this to me. Nice personal website by the way. ^_^


Wed Apr 27, 2011 6:39 pm
Profile
User avatar

Joined: Oct 08, 2010
Posts: 246
Location: Boston, MA
Post Re: TriggerLinc Button 1 & Applescript
Doh! Putting the jumper across the pins just helped me as well. Thanks Jay!

I am using the TriggerLinc as a water detector that doesn't need A/C, so I needed it to set a variable if it detected water (really just closed the circuit) and the correct placement of the jumped made all the difference.

_________________
Dave


Sat May 28, 2011 11:23 am
Profile

Joined: Mar 31, 2008
Posts: 738
Post Re: TriggerLinc Button 1 & Applescript
Dave, what did you hook up to the triggerlinc for water detection?


Sat May 28, 2011 4:19 pm
Profile
User avatar

Joined: Oct 08, 2010
Posts: 246
Location: Boston, MA
Post Re: TriggerLinc Button 1 & Applescript
hamw,

http://www.machomestore.com/catalog/pro ... cts_id=180

Cheap ($19) and effective. It's really just pair of contacts that when water touches both, the current flows through the water from one contact to another. About as simple as you can get, but very effective as it can be used over and over again. While being simple, it also is very dumb. For $19 it doesn't check humidity levels, or get fancy in any way, but I wasn't looking for that. Think "KISS" principal...

I like the solution so much I am thinking of buying a few more, some of the rest of the toilets in the house, some for the water heater and A/C units, and one for under the kitchen sink. Since I like in a vertical (townhouse) house, a water leak on one floor will run to others, and the cost of overflowing bathtub can easily run +$1k in repairs.

How I built It
I needed to monitor for a toilet overflowing, so I bought a TriggerLinc, popped the case off, and connected this sensor the the screw down terminals inside the TriggerLinc (only two wires to connect - easy). Then, after snapping back on the TriggerLinc case, I put some strong sticky tape on the TriggerLinc and stuck it to the back of the toilet tank, out of site. Then, I ran the included wire to the sensor from the TriggerLinc down to the floor (only a few feet), and used more sticky tape attach the sensor to the wall board where it meets the floor. Since the sensor is on the floor, or really by design, about 1/16" above the floor, it can detect if there is water behind the toilet. If I was clever, I would have mounted the sensor into the wall with screws, but it was a tight area, and I was lazy ;-)

Indigo Configuration
With the jumper inside the TriggerLinc "jumped" (thanks again Jay!), I have a Trigger for Sensor #2 ON, (water detected) and a Sensor #1 ON (water not detected). These Triggers set a variable (isWaterOnBathroomFloor = TRUE) to the state (I could just check the TriggerLinc state, but I like variables), and have it turn on all the lights in the effected area (why fumble for a light switch when you are standing in water!). It also sends me an email and SMS as well as "speaking" about the water leak via Indigo.

Why I like it
1. Effective
2. Cheap
3. Wireless
4. Runs on a single AA battery. No need to "plug it in" means less wires.
5. Easy to test - just spill a little water on the floor and in 1-2 seconds Indigo registers it.

Potential Problems
1. The battery in the TriggerLinc will need to be changed when it runs out (no idea when - 6 months maybe?), and being behind the toilet, it's awkward to change.
2. If someone splashes a lot of water around, a puddle the size of a paperclip could set off the TriggerLinc in false-positive mode (unlikely, but possible)
3. Looks weird. If you notice a wire running from the back of a toilet, it looks strange. Is it a bomb? ;-) Luckily the wire and sensor are white, and so is the wall/toilet.

Hope all this helps!

_________________
Dave


Sun May 29, 2011 5:09 am
Profile

Joined: Mar 31, 2008
Posts: 738
Post Re: TriggerLinc Button 1 & Applescript
Neat! I think I understand triggerlincs much better after reading this thread.

Dave, you might consider posting your water detection explanation in one of the "How I did it" areas so others can find it easily.


Sun May 29, 2011 6:26 am
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6654
Location: Austin, Texas
Post Re: TriggerLinc Button 1 & Applescript
Dave, if you'd like to turn it into a how-to on the wiki (which I think would be a great idea) make an account there then send us an email (indigo DASH support AT perceptiveautomation DOT com) and we'll get you set up with write privileges.

_________________
Jay (Indigo Support)
Image


Sun May 29, 2011 8:30 am
Profile WWW
User avatar

Joined: Oct 08, 2010
Posts: 246
Location: Boston, MA
Post Re: TriggerLinc Button 1 & Applescript
Jay,

Will do this week.

_________________
Dave


Sun May 29, 2011 8:44 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 11 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.