Trigger and Script question

Posted on
Tue Aug 27, 2013 3:00 pm
Ian offline
Posts: 66
Joined: Oct 13, 2008
Location: Ottawa, ON ,Canada

Trigger and Script question

I have a WMR200 weather station running with Indigo and populating the Weathersnoop Plugin info with all the correct values.

I put a temperature Sensor (#07) in the Fridge and setup a trigger to email me should the value be higher than the amount I specified....in my case 5C. This covers me for either fridge failure or leaving the door open/ajar.

I set this up as a trigger. So under the actions menu I have Type "Send Email (notification actions)" ......my email address obviously. Subject "Fridge Alert"

What I want to do is insert the Plugin value of that sensor into a sentence in the body of the email....ie The temperature of the fridge is "Insert Value" and the alert setpoint is 5C.

Any ideas of the best way to accomplish this...I am guessing if it was a variable....It would be a piece of cake but is it easier to setup a script to accomplish this instead.

thks in advance for everbodys opinions.

Cheers......Ian

Posted on
Tue Aug 27, 2013 3:52 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Trigger and Script question

check this wiki out:
http://www.perceptiveautomation.com/wik ... stom_email

1. create variable "fridgeTemp"
2. trigger: if device state has changed (from temp sensor#7), may be in condition you want to check if temp > xx
3. trigger action: insert device state (temp # 7) into variable .. fridgeTemp
4. see wiki how to create email and include variable in applescript

Karl

Posted on
Tue Aug 27, 2013 3:59 pm
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: Trigger and Script question

Currently, the only way to send an email with variable content is to do so using a script. I'm not aware of a way to send emails using Python (there may be one now). I use AppleScript to send all my emails with variable content. This does require that the device state values you wish to send be inserted into Indigo variables.

The link Karl shared provides a more detailed example. For your situation, follow Karl's steps 1 through 3. For step 4, in a separate action, delayed by at least 1 second to prevent previous variable values from being accidentally sent, use an embedded AppleScript to send yourself an email with the content you wish. Example code:

Code: Select all
set myTemp to value of variable "fridgeTemp"
send email to "your-email@address.com" with subject "Fridge Alert" with body "The fridge temperature is " & myTemp & "."

Posted on
Tue Aug 27, 2013 8:09 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Trigger and Script question


Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Aug 27, 2013 8:55 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Trigger and Script question

in the email sending action you have to add (I believe)

tell application "IndigoServer"

set ...
send ...

end tell

Posted on
Wed Aug 28, 2013 12:56 am
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: Trigger and Script question

jay (support) wrote:


Oh cool. Thanks Jay!

kw123 wrote:
in the email sending action you have to add (I believe)

tell application "IndigoServer"

set ...
send ...

end tell


While you can do that (it certainly won't hurt), it's not necessary from within an embedded AppleScript. That's only required when using AppleScript with an external script.

Posted on
Wed Aug 28, 2013 6:42 am
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Trigger and Script question

thanks, did not know that..

Karl

Posted on
Wed Aug 28, 2013 8:19 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Trigger and Script question

nsheldon wrote:
While you can do that (it certainly won't hurt), it's not necessary from within an embedded AppleScript. That's only required when using AppleScript with an external script.


Actually, we've had multiple reports in the past of an AppleScript scoping bug where an embedded script somehow didn't end up targeting the server like it's supposed to. Wrapping it in the tell block always seemed to fix the issue so it's recommended practice.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Aug 28, 2013 9:09 am
Ian offline
Posts: 66
Joined: Oct 13, 2008
Location: Ottawa, ON ,Canada

Re: Trigger and Script question

Thanks Guys

Seems to be working well with the embedded script.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 6 guests