Announcement

Collapse
No announcement yet.

HSEvent

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

    HSEvent

    The SDK docs identifies a parameter of HSEvent type for the HSEvent method. I was not able to find the a HSEvent type definition. Where is it? Are there any examples of using HSEvent method? I did not see it in the samples provided.

    #2
    In your plugin, HSEvent would be defined as (C#):

    Code:
            public override void HsEvent(HomeSeer.PluginSdk.Constants.HSEvent eventType, object[] @params)
            {
                Console.WriteLine("HSEvent: " + eventType.ToString());
    
            }
    You can right click on the HSEvent type to get the enum, but the values are:

    Code:
            public enum HSEvent
            {
                LOG = 2,
                AUDIO = 8,
                CONFIG_CHANGE = 32,
                STRING_CHANGE = 64,
                SPEAKER_CONNECT = 128,
                CALLER_ID = 256,
                VALUE_CHANGE = 1024,
                VALUE_SET = 2048,
                VOICE_REC = 4096,
                SETUP_CHANGE = 8192,
                RUN_SCRIPT_SPECIAL = 16384,
                GENERIC = 32768
            }
    website | buy now | support | youtube

    Comment


      #3
      Digging this up again .....

      Does anyone know where is the definition of the "PARAMS" object that accompanies the HSEvent callback? I've registered for CONFIG_CHANGE events because I want to get notified when a user deletes one of the PIs devices.

      At least 2 questions:
      1. what triggers CONFIG-CHANGE, is this only deletes, but also creates or modifies? Suspect the params object provides more detail
      2. what exaclty is to be found in params? Where is it documented? I looked at the HS4 documents and couldn't find anything. I looked at HS3 documents and at least I could find it but it shows 5 fields of PARAMS, but I see 6 (5 integers and a string). What are they?
      Thanks for the help

      Comment


        #4
        Originally posted by dcorsus View Post
        Digging this up again .....

        Does anyone know where is the definition of the "PARAMS" object that accompanies the HSEvent callback? I've registered for CONFIG_CHANGE events because I want to get notified when a user deletes one of the PIs devices.

        At least 2 questions:
        1. what triggers CONFIG-CHANGE, is this only deletes, but also creates or modifies? Suspect the params object provides more detail
        2. what exaclty is to be found in params? Where is it documented? I looked at the HS4 documents and couldn't find anything. I looked at HS3 documents and at least I could find it but it shows 5 fields of PARAMS, but I see 6 (5 integers and a string). What are they?
        Thanks for the help
        Click image for larger version

Name:	Screenshot 2021-02-24 110501.jpg
Views:	257
Size:	95.0 KB
ID:	1458419

        Comment


          #5
          Thanks Alex!

          Comment


            #6
            Can anyone confirm how to register for multiple event types? In hs3, you ORd the values and made one call. I'm hs4, I've had to register each type via separate calls.

            Anyone confirm this?
            tenholde

            Comment


              #7
              It is the same in HS4. The routine I use to register for user-variable event callbacks is
              Code:
              Public Sub RegisterEvents(ByVal iEventType As Integer)
              '1 value
              '2 string HomeSeer.PluginSdk.Devices.EMiscFlag.ShowValues,
              '3 log
              'If gDebugLog Then
              'hsWritelog(PLUGIN_DEBUG, "Register Events " & iEventType.ToString & ", bValueCallbackRegistered=" & bValueCallbackRegistered.ToString & ", bStringCallbackRegistered=" & bStringCallbackRegistered.ToString)
              'End If
              If iEventType = 1 AndAlso Not bValueCallbackRegistered Then
              hsWritelog(PLUGIN_DEBUG, "RegisterEvents " & iEventType.ToString)
              bValueCallbackRegistered = True
              hs.RegisterEventCB(HomeSeer.PluginSdk.Constants.HSEvent.VALU E_CHANGE, PLUGIN_NAME)
              hs.RegisterEventCB(HomeSeer.PluginSdk.Constants.HSEvent.VALU E_SET, PLUGIN_NAME)
              ElseIf iEventType = 2 AndAlso Not bStringCallbackRegistered Then
              hsWritelog(PLUGIN_DEBUG, "RegisterEvents " & iEventType.ToString)
              bStringCallbackRegistered = True
              hs.RegisterEventCB(HomeSeer.PluginSdk.Constants.HSEvent.STRI NG_CHANGE, PLUGIN_NAME)
              ElseIf iEventType = 3 AndAlso Not bLogCallbackRegistered Then
              hsWritelog(PLUGIN_DEBUG, "RegisterEvents " & iEventType.ToString)
              bLogCallbackRegistered = True
              hs.RegisterEventCB(HomeSeer.PluginSdk.Constants.HSEvent.LOG, PLUGIN_NAME)
              End If
              
              End Sub

              Comment


                #8
                Originally posted by alexbk66 View Post

                Click image for larger version

Name:	Screenshot 2021-02-24 110501.jpg
Views:	257
Size:	95.0 KB
ID:	1458419
                Alex - Thank you for this post - It is extremely helpful!

                Comment


                  #9
                  I have HS3 code that makes a single call to RegisterEventCB requesting multiple events by ORing the bits together. This does not appear to work with HS4, you must make multiple calls to register for multiple events. That's my experience.
                  tenholde

                  Comment

                  Working...
                  X