No announcement yet.

Sending emails with content only one time.

  • Filter
  • Time
  • Show
Clear All
new posts

    Sending emails with content only one time.


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

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


      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.

      Attached Files


        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.

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


          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.


            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

            Sub Main
            (ByVal Parms as Object)


            Dim MyDevice As String
            Dim MTo 
            As String ""
            Dim MFrom As String ""
            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
            end if

            End Sub 

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


              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.






                  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


                    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.


                      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.

             is the link I assign to device F3

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




                        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:


                        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.


                          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.



                            The issue is in your trigger.
                            Attached Files