Announcement

Collapse
No announcement yet.

Event Properties Device info in Message E-Mail

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

    Event Properties Device info in Message E-Mail

    Is there anyway to have device properties ie TempLinc
    Current Temp Data to be inside my event message.
    As opose to have the event run a script that get the Device data and write it to a file and that file is updataed and then attatched to the Event email. This is fine for normal e-mail.
    But to email o my pager I can't open the atatch file.
    Here is the small script that was sent to me to get started.
    I still do not have this scripting language programming down within HS. I don't totally understand all commands in this script.
    So is there a way within script to get the value of the G17?
    Also one other question. within theis script is there a way to
    grab the time stanp listed in HS coraspnding to the last value change?

    >>>>>>>>>>>>>>>>>>>>>>>>>
    sub main()
    Dim fso,f1
    Const OpenFileForReading = 1
    Const OpenFileForWriting = 2
    Const OpenFileForAppending = 8
    HS.PollDevice "G17"
    status = HS.DeviceStatus("G17")
    Path = "c:\Program Files\HomeSeer\TEMPB\TEMP_LOG.log"
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set file = fso.OpenTextFile(path, OpenFileForAppending , True)
    file.WriteLine(hs.deviceString("G17"))
    file.Close
    end sub
    HS.PollDevice "G17"
    status = HS.DeviceStatus("G17")

    #2
    No Reply posts???????????

    Could someone chime in with some comments or suggestions on my question to get device data embedded in an event e-mail!!!!

    Thanks,
    Michael

    Comment


      #3
      I'm not sure that this is what you're asking for, but maybe it will help.

      This script will email you the status for each of your devices. The majority of the work was done by mckillen_stephan.
      Attached Files

      Comment


        #4
        What all needs to be edited in this script?

        Thank you for this script. But according to the instructions at the top header info of the script I need to edit the
        email info. I did but still does not work. I also unremed the
        lines for sending e-mail then get errors. I need more
        insrtuctions on what I am doing wrong.

        Michael

        Top of Script
        >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        Name: Device Status Email
        ' Author: JR
        ' Credit: Thanks to mckillen_stephan in New Zealand for the initial work
        ' Date: June 2003
        ' Purpose: Captures status of devices and puts in email
        ' Requirements: HS must be email enabled
        ' Installation: 1) install in HS scripts directory
        ' 2) build event in HS that calls this script
        ' 3) change email address in code below
        ' Notes: none
        ' Called From: Event in HS
        Bottem og script
        >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        My_Device_String = "You have " & My_Dev_Count & " Devices " & vbnewline & My_Device_String
        '===========================================================
        'send a email
        '===========================================================
        hs.SendEmail "michael_barker@ltx.com","mjbarker56@access4less.net,"Subjec t",My_Device_String
        'hs.speak "done"
        '===========================================================

        end sub

        Comment


          #5
          I think you're just missing a " sign.
          Try this line:

          hs.SendEmail "to email address in quotes", "from email address in quotes","Subject",My_Device_String

          Comment


            #6
            Script works

            Thanks Jeff for catching the Synrax error ".
            That fixed the script. Now I need to hack this code
            so I can have the script just send the devices I want as appose to all devices. I just need to the knowlegde of what commands do what. Is there a training lesson or documentation for HS embedded commands?
            Scripting seems pretty powerful but only for programmers.
            I am more GUI capable vers command line programming.
            Thanks again for your help.

            Michael

            Comment


              #7
              Michael,
              The hs help files outline the use of every property and method used in the attached script. Most of them even have examples.
              💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

              Comment


                #8
                It should be easy to restrict the results to the house code you want. Find the following portion of the code, and add an IF with a corresponding END IF.

                It should look like this if you want to include ONLY Housecode "G". (NOTE THAT I HAVE CAPITALIZED THE NEW LINES, but that the housecode is case sensitive so you need to make sure it is correct - either "G" or "g".)
                .
                .
                .
                '===========================================================
                ' continue to concatinate the text of the email
                '===========================================================
                IF DEVICES.HC = "G" THEN 'My_Device_String = My_Device_String & devices.hc & devices.dc & " = " & devices.location & " " & devices.Name & " = " & my_status_value & vbnewline 'vbnewline creates a new line after each pass of the loop
                My_Device_String = My_Device_String & devices.hc & devices.dc & " = " & devices.location & " " & devices.Name & " = " & my_status_value & " " & s & " " & last_change & vbnewline 'vbnewline creates a new line after each pass of the loop
                'My_Device_String = My_Device_String & devices.hc & devices.dc & " = " & " " & devices.Name & " = " & VBVerticalTab & VBtab & VBtab & VBtab & my_status_value & " " & s & " " & last_change & vbnewline 'vbnewline creates a new line after each pass of the loop
                END IF
                next
                '===========================================================
                'display message box requiring OK click
                .
                .
                .
                Last edited by JeffCharger; January 13, 2005, 02:53 PM.

                Comment


                  #9
                  OR if your only after a few devices then simply list the ones you want. If your only intereted in the device string then a few
                  status = status & "A1 : " & hs.DeviceString "a1" & vbnewline
                  status = status & "A2 : " & hs.DeviceString "a2" & vbnewline
                  ...etc
                  💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                  Comment


                    #10
                    Edit to script

                    Rupp, where exactly would I put the lines you sent? In the script I have.
                    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
                    status = status & "A1 : " & hs.DeviceString "a1" & vbnewline
                    status = status & "A2 : " & hs.DeviceString "a2" & vbnewline
                    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
                    My script that was sent to me to edit and use. Below
                    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

                    sub main()
                    Dim Dev_count
                    Dim i
                    Dim My_Dev_Count
                    Dim Devices
                    Dim My_Status
                    Dim My_Status_Value
                    Dim My_Device_String
                    Dim last_change

                    'determine # of devices
                    My_Dev_Count = hs.DeviceCount
                    My_Device_String ="" ' set to null

                    'hs.speak "device count " & My_Dev_Count
                    'msgbox My_Dev_Count

                    '===========================================================
                    'assemble for each device found
                    '===========================================================
                    For i = 1 to My_Dev_Count
                    Set Devices = hs.GetDevice(i)
                    my_status = hs.DeviceStatus(devices.hc & devices.dc) ' will return one of these values

                    'status = status & "E17 : " & hs.DeviceString "E17" & vbnewline
                    'status = status & "H17 : " & hs.DeviceString "H17" & vbnewline

                    'hs.speak devices.hc & devices.dc
                    select case my_status
                    case 2 ' ON
                    My_Status_Value = "ON "
                    case 3 ' OFF
                    My_Status_Value = "OFF "
                    case 4 ' DIM
                    My_Status_Value = "DIM "
                    case else ' Don't know what it is
                    My_Status_Value = ""
                    End select

                    s=hs.DeviceString(devices.hc & devices.dc) ' will return the string assigned to the device
                    '===========================================================
                    ' now need to remove any image tags - remove any characters between "<" and ">"
                    '===========================================================
                    x=instr(s,">")
                    s=right(s,len(s)-x)
                    '===========================================================
                    ' will return the time of last change
                    '===========================================================
                    last_change = hs.DeviceLastChange(devices.hc & devices.dc)
                    '===========================================================
                    ' continue to concatinate the text of the email
                    '===========================================================

                    'My_Device_String = My_Device_String & devices.hc & devices.dc & " = " & devices.location & " " & devices.Name & " = " & my_status_value & vbnewline 'vbnewline creates a new line after each pass of the loop
                    My_Device_String = My_Device_String & devices.hc & devices.dc & " = " & devices.location & " " & devices.Name & " = " & my_status_value & " " & s & " " & last_change & vbnewline 'vbnewline creates a new line after each pass of the loop
                    'My_Device_String = My_Device_String & devices.hc & devices.dc & " = " & " " & devices.Name & " = " & VBVerticalTab & VBtab & VBtab & VBtab & my_status_value & " " & s & " " & last_change & vbnewline 'vbnewline creates a new line after each pass of the loop

                    next
                    '===========================================================
                    'display message box requiring OK click
                    'msgbox My_Device_String 'debug statement, will display limited # of findings (msgbox seems to be limited in length)
                    'put # of devices comment as first line in display

                    My_Device_String = "You have " & My_Dev_Count & " Devices " & vbnewline & My_Device_String
                    '===========================================================
                    'send a email
                    '===========================================================
                    hs.SendEmail "michael_barker@ltx.com","mjbarker@intertex.net","Home Devices Status",My_Device_String
                    'hs.speak "done"
                    '===========================================================

                    end sub

                    Thanks Michael

                    Comment


                      #11
                      Michael,
                      Here's a new script to try that should give you a good idea of how to do just a few devices. If you want more infor let me/us know and we can show you how.
                      Code:
                      sub main()
                      List = "A2,C1"
                      splList = Split(List, ",")
                      
                      For i = LBound(splList) To UBound(splList)
                      strStatus = hs.DeviceStatus(splList(i))
                      strStatus = Replace(strStatus, 2, "On")
                      strStatus = Replace(strStatus, 3, "Off")
                      strStatus = Replace(strStatus, 4, "Dim")
                      strStatus = Replace(strStatus, 17, "Unknown")
                      
                      Status = Status & splList(i) & " : " & strStatus & vbCrLf
                      
                      
                      Next
                      MsgBox (Status)
                      'Put your email line here ....
                      end sub
                      💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                      Comment


                        #12
                        Confused.

                        Rupp, I know you are trying to help. But that script for a message pop up is not what I am trying to do. Tis just kind of confused me.
                        The other script I was tying to debug and unnderstand what lines did what.
                        All I want to get is the temp data from my two devices and get that data sent
                        in e-mail. So the scrpt I have works great but sends me all devises which
                        is too much info. So If I could just understand how to plug ,grab the data and stick the right text in the script for just devices I want.

                        Michael

                        Comment


                          #13
                          Michael, without trying to confuse you further....Rupp's script is a nice simple one. I think you will get what you are after if you include the following line in replace of the msgbox line.

                          hs.SendEmail "michael_barker@ltx.com","mjbarker@intertex.net","Home Devices Status",Status

                          I would suggest that you leave the msgbox line in while trying it, since it will display on the screen what will ultimately appear in the email. It's nice for testing. Once it's working, comment out the msgbox line by putting a 'tick' in the first column - now it won't execute that line.

                          Comment


                            #14
                            Still Haching Script

                            Jeff, here is a the script.
                            sub main()

                            List = "E17,H17"
                            splList = Split(List, ",")

                            For i = LBound(splList) To UBound(splList)
                            strStatus = hs.DeviceStatus(splList(i))
                            strStatus = Replace(strStatus, 2, "On")
                            strStatus = Replace(strStatus, 3, "Off")
                            strStatus = Replace(strStatus, 4, "Dim")
                            strStatus = Replace(strStatus, 17, "Unknown")

                            Status = Status & splList(i) & " : " & strStatus & vbCrLf


                            Next
                            MsgBox (Status)

                            hs.SendEmail "mjbarker@intertex.net","mjbarker@intertex.net","Home Devices Status",Status

                            end sub
                            =====================================================
                            Here is what it send me:

                            E17 : Unknown
                            H17 : Unknown
                            =====================================================

                            =====================================================
                            I have actually got close withthis script:

                            ====================================================
                            sub main()
                            dim lc_E
                            dim s_E
                            dim lc_H
                            dim s_H
                            dim status_E
                            dim status_H


                            lc_E=hs.Devicelastchange("E17")
                            s_E=hs.DeviceString("E17")

                            lc_H=hs.Devicelastchange("H17")
                            s_H=hs.DeviceString("H17")

                            msgbox lc_E
                            msgbox s_E

                            msgbox lc_H
                            msgbox s_H

                            status_E = hs.DeviceString ("E17") & hs.Devicelastchange ("E17")
                            status_H = hs.DeviceString ("H17") & hs.Devicelastchange ("H17")

                            msgbox status_E
                            msgbox status_H


                            My_Device_String = "You have " & My_Dev_Count & " Devices " & vbnewline & My_Device_String

                            hs.SendEmail "mjbarker@intertex.net","mjbarker@intertex.net","Home Devices Status", status_E

                            end sub


                            Hers is what I want it to look like. Which was cut out of the long list of all devices from the orriganl script snt to me to play with.
                            Michael
                            'results wanted
                            ' H17 = TempLinc Device Current Inside Temp H = 69 1/16/2005 8:56:42 AM
                            ' E17 = TempLinc Device Current Outside Temp E = 47 1/16/2005 9:07:15 AM

                            Comment


                              #15
                              try this then
                              Attached Files

                              Comment

                              Working...
                              X