| 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. |

October 8th, 2009, 06:41 AM
|
|
Seer Deluxe
|
|
Join Date: Feb 2009
Location: France
Posts: 178
|
|
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
__________________
Last edited by nslmanu; October 8th, 2009 at 07:08 AM.
|

October 8th, 2009, 07:07 AM
|
|
Seer Deluxe
|
|
Join Date: Nov 2007
Location: UK
Posts: 426
|
|
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...
|

October 11th, 2009, 01:39 AM
|
|
Seer Deluxe
|
|
Join Date: Feb 2009
Location: France
Posts: 178
|
|
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
__________________
|

October 11th, 2009, 02:13 AM
|
|
Seer Deluxe
|
|
Join Date: Nov 2007
Location: UK
Posts: 426
|
|
Quote:
Originally Posted by nslmanu
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...
|

October 11th, 2009, 02:25 AM
|
|
Seer Deluxe
|
|
Join Date: Feb 2009
Location: France
Posts: 178
|
|
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.
__________________
|

October 13th, 2009, 07:03 PM
|
 |
OverSeer
|
|
Join Date: Jan 2002
Location: London UK
Posts: 5,143
|
|
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) > 0 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.Replace( MyDevice,"")
End Function
__________________
Jon
|

October 16th, 2009, 05:01 AM
|
|
Seer Deluxe
|
|
Join Date: Feb 2009
Location: France
Posts: 178
|
|
Thanks a lot Jon00
It works great ...
I create a second one for the sensor display too !
Tested with actual words "messages" and put Failure back.
 Happy
__________________
|

October 16th, 2009, 05:29 AM
|
 |
OverSeer
|
|
Join Date: Jan 2002
Location: London UK
Posts: 5,143
|
|
Excellent!
__________________
Jon
|

October 16th, 2009, 07:32 AM
|
|
Seer Deluxe
|
|
Join Date: Feb 2009
Location: France
Posts: 178
|
|
Yep
And i have an idea, after trigerring the event, i'd like it to clear ... : just to receive 1 mail and that's all.
But has you can see : there is a button to clear the message, but in the action, it'is impossible to have this button, it's normal ?
Really strange, and at final i don't know how to clear the message.
Any idea ?
it's strange, i'm the first to have this kind of problems ?
__________________
|

October 16th, 2009, 07:45 AM
|
 |
OverSeer
|
|
Join Date: Jan 2002
Location: London UK
Posts: 5,143
|
|
Script and plugin writers can add as many buttons as they like to a virtual device but they will not appear necessarily in the drop down menu.
Your best bet would be to ask for help in the RFXCOM forum as it is a plugin issue. The script I provided will only send you one email if the failure message stays the same.
__________________
Jon
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is On
|
|
|
All times are GMT -4. The time now is 09:49 AM.
|