Announcement

Collapse
No announcement yet.

Get the event Group name

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

    Get the event Group name

    Is it possible to get the group name (hopefully I'm using the right name for it) from within a script?

    Thanks
    Attached Files

    #2
    Sure...this will provide a list in the log:

    Code:
        Sub Main(ByVal Parms As Object)
    
           Dim EventGroup As String = ""
           For Each evGroup As HomeSeerAPI.strEventGroupData In hs.Event_Group_Info_All
               EventGroup = evGroup.GroupName.ToString
               hs.writelog("EventGroup",EventGroup)
           Next
    
        End Sub
    Jon

    Comment


      #3
      Hi Jon,
      thanks for taking your time to write this.
      Sorry my mistake, I did not explain correctly, from that event that I call the script, I would like to know the event that calls it (hs.getlastevent) and the event group that is in. I do not know how to get this value.

      Comment


        #4
        You can try the following; however it may not be 100% reliable if another event fires at the same time:

        Code:
            Sub Main(ByVal Parms As Object)
        
                Dim EventGroup As String = ""
                Dim EventName As String = ""
                Try
                    For Each evGroup As HomeSeerAPI.strEventGroupData In hs.Event_Group_Info_All
                        EventGroup = evGroup.GroupName.ToString
                        For Each eva As HomeSeerAPI.strEventData In hs.Event_Info_Group(evGroup.GroupID)
                            EventName = eva.Event_Name.ToString
                            If EventName = hs.GetLastEvent Then Exit Try
                        Next
                    Next
                Catch
                End Try
                hs.writelog("EventGroup", EventGroup)
                hs.writelog("EventName", EventName)
        
            End Sub
        Jon

        Comment


          #5
          Actually, it may be more reliable with this code:

          Code:
              Sub Main(ByVal Parms As Object)
          
                  Dim EventGroup As String = ""
                  Dim EventName As String = ""
                  Dim LastEvent As String = hs.GetLastEvent
                  Try
                      For Each evGroup As HomeSeerAPI.strEventGroupData In hs.Event_Group_Info_All
                          EventGroup = evGroup.GroupName.ToString
                          For Each eva As HomeSeerAPI.strEventData In hs.Event_Info_Group(evGroup.GroupID)
                              EventName = eva.Event_Name.ToString
                              If EventName = LastEvent Then Exit Try
                          Next
                      Next
                  Catch
                  End Try
                  hs.writelog("EventGroup", EventGroup)
                  hs.writelog("EventName", EventName)
          
              End Sub
          Jon

          Comment


            #6
            I can not thank you enough Jon. It is perfect, thank you.

            Comment

            Working...
            X