Announcement

Collapse
No announcement yet.

Sending emails with content only one time.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bill Brower
    replied
    The issue is in your trigger.
    Attached Files

    Leave a comment:


  • will40
    replied
    Thanks Jon. That is the problem I am having.

    My IP Cam produces the snapshot in it's webserver with that link. It appears I will need a way to save that image to disk in order to email it.

    I will look into your image builder.

    Thanks.

    Leave a comment:


  • jon00
    replied
    You will need to send the jpg as an attachment.

    It looks like the address you are using is not actually the image file itself. Load the jpg page in IE and then right-click on the image itself and select properties. Take a note of the URL.

    If this image is on your network, it's fairly easy. There is a fifth parameter to hs.sendemail which is the absolute path to the file you wish to attach.

    You just need to add this to the script i.e. add:

    Dim FileAttach As String = "<path and name of image file>"

    and the hs.sendemail becomes:

    hs.SendEmail(MTo,MFrom,MSubject,MMessage,FileAttach)

    You can also use my image utility on my site to grab the image from the URL. You just need to save the image somewhere and adjust the path for the file attachment accordingly.

    Leave a comment:


  • will40
    replied
    Hi Jon,

    I used portions of your above code for something similar I am trying to do.

    I have a motion sensor trigger my house cam to take a jpg snapshot and assign it to a device F3. I can view the image just fine.

    I am trying to create an event to email the snapshot but all I get in email body is HTML.

    10.17.0.4:81/snapshot.htm.jpg is the link I assign to device F3



    Is there anyway for me to attach to email as a jpg?

    Thanks,

    Will

    Leave a comment:


  • jon00
    replied
    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.

    Leave a comment:


  • nslmanu
    replied
    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 ?
    Attached Files

    Leave a comment:


  • jon00
    replied
    Excellent!

    Leave a comment:


  • nslmanu
    replied
    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

    Leave a comment:


  • jon00
    replied
    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 

    Leave a comment:


  • nslmanu
    replied
    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.

    Leave a comment:


  • mrhappy
    replied
    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...

    Leave a comment:


  • nslmanu
    replied
    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 Files

    Leave a comment:


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

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

    Leave a comment:


  • nslmanu
    started a topic Sending emails with content only one time.

    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 Files
    Last edited by nslmanu; October 8, 2009, 05:08 AM.
Working...
X