www.homeseer.com

Go Back   HomeSeer Message Board > Developer Support > Scripts & Plug-Ins:Development and Libraries > Script & Plug-In Library Discussion

Script & Plug-In Library Discussion This forum is for discussing scripts that are posted in the Script Library. To keep the Script Libray as neat as possible, replies are not permitted in that forum. Please post questions, comments, scripts in process, etc. to this forum.

Reply
 
Thread Tools Display Modes
  #1  
Old October 8th, 2009, 05:41 AM
nslmanu nslmanu is offline
Seer Deluxe
 
Join Date: Feb 2009
Location: France
Posts: 216
Default Sending emails with content only one time.

Hello,

In fact i don't really from where i need to begin with what i'd like to do :

Sometimes, i've got a communication failure with one of my sensor ...

And i'd like to receive a mail with the content of the message and only one time.

On the screeenshot, i'd like to receive the message in a mail sended just when the message arrived.

Do you think it's difficult to include the message in the mail ? because i don't really know how to do it.

Thanks a lot for any help

Have a nice day
Manu
Attached Images
 
__________________

Last edited by nslmanu; October 8th, 2009 at 06:08 AM.
Reply With Quote
  #2  
Old October 8th, 2009, 06:07 AM
mrhappy mrhappy is offline
Seer Master
 
Join Date: Nov 2007
Location: UK
Posts: 886
Default

I think i've understood you correctly, you want HS to send an email when that failure mode is detected and then nothing further?

Quote:
Sub Main()
dim dtext
dim eaddress
dim mail
eaddress = "your.email@email.com"
mail = "HomeSeer has detected the following failure: "
dtext = hs.devicestring("Z18")
hs.writelog "Test", dtext
if instr(lcase(dtext),"failure") > 0 then
hs.writelog "Test", "Failure Detected"
hs.sendemail eaddress, "", "HomeSeer Email", mail & dtext
end if
End Sub
Change eaddress to the email address you wish to receive the failure on, change the devicestring house code to your required house code ("[3"). If it detects the word 'failure' anywhere and will send you an email containing the device string. I would set it on a recurring event every minute.

To make this trigger only once may need a bit more code, what does the device string say when it is not suffering with a communications failure? You could disable the event when it detects failure so the event does not retrigger, then perhaps run a second script just before this one that then re-enables the event. Or could store a value in an ini file to say it had already been triggered. Someone may be able to answer an easier way to do it inside a script however...
Reply With Quote
  #3  
Old October 11th, 2009, 12:39 AM
nslmanu nslmanu is offline
Seer Deluxe
 
Join Date: Feb 2009
Location: France
Posts: 216
Default

Thanks a lot, i'm actually testing it ... but i have seen a problem :

I can't trigger these devices because : they don't exist in the trigger devices list.

the only things i have are State and status. Nothing else.

I don't know how to check them ...

Have you got an idea or i miss something in your mail ?

Thanks a lot for all.

Regards
Manu
Attached Images
  
__________________
Reply With Quote
  #4  
Old October 11th, 2009, 01:13 AM
mrhappy mrhappy is offline
Seer Master
 
Join Date: Nov 2007
Location: UK
Posts: 886
Default

Quote:
Originally Posted by nslmanu View Post
Thanks a lot, i'm actually testing it ... but i have seen a problem :

I can't trigger these devices because : they don't exist in the trigger devices list.

the only things i have are State and status. Nothing else.

I don't know how to check them ...

Have you got an idea or i miss something in your mail ?

Thanks a lot for all.

Regards
Manu
The script I posted would run happily from an event, there would not be any requirement for any conditions regarding devices (I don't think anyway) to be set so I am a bit confused what you are trying to do.

The idea I had was to pull the device string out, examine it for the word 'failure' and then do whatever you require it to (send an email). It also then emails you with a copy of the device string. It seems to work when I tried it.

I'm afraid RFXCOM is something I know little about so I may not be understanding what you are trying to do...
Reply With Quote
  #5  
Old October 11th, 2009, 01:25 AM
nslmanu nslmanu is offline
Seer Deluxe
 
Join Date: Feb 2009
Location: France
Posts: 216
Default

I have ultralog running ...

And it's easy to check if there was a "failure" word in it.

The problem is i don't found any failure message only for one thing, but nothing linked with the alarm display od device communication failure ...

It's for that i'm trying to check directly the device ALARM DISPLAY and sending the sending the message with your script ...

i haven't better idea.
__________________
Reply With Quote
  #6  
Old October 13th, 2009, 06:03 PM
jon00's Avatar
jon00 jon00 is offline
OverSeer
 
Join Date: Jan 2002
Location: London UK
Posts: 5,384
Default

Try the attached script. Copy it and name it something like alarmfail.vb and place it in your scripts directory.

Create a recurring event every 1-5 minutes (or whatever you want) to run the script.

Change the email details to suit. It will only send the email once each time the failure message appears.

It should work but depends if the device details can be extracted correctly using the devicestring method.

PHP Code:
Imports System.Text
Imports System
.Text.RegularExpressions

Sub Main
(ByVal Parms as Object)

hs.CreateVar("APMessages")

Dim MyDevice As String
Dim MTo 
As String "MailTo@123.com"
Dim MFrom As String "MailFrom@456.com"
Dim MSubject As String "Alarm Panel Failure"


MyDevice stripHTML(hs.devicestring("[3"))
Dim MMessage As String "Homeseer Alert" vbcrlf vbcrlf MyDevice

If Instr(1,MyDevice,"failure",1) > and hs.GetVar("APMessages") <> MyDevice then
    hs
.SaveVar("APMessages",MyDevice)
    
hs.SendEmail(MTo,MFrom,MSubject,MMessage)
end if

End Sub 

Function stripHTML(byVal MyDevice)
    
Dim re As New RegEx"<(.|\n)+?>" )
    
stripHTML re.ReplaceMyDevice,"")
End Function 
__________________
Jon

Reply With Quote
  #7  
Old March 28th, 2010, 11:05 AM
Bill Brower's Avatar
Bill Brower Bill Brower is offline
OverSeer
 
Join Date: Dec 2001
Location: Troutdale, Oregon (go to Portland, head east)
Posts: 3,669
Default

The issue is in your trigger.
Attached Images
 
__________________


~Bill
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 09:24 PM.


Copyright 1998-2008 HomeSeer Technologies, LLC