Announcement

Collapse
No announcement yet.

ConfigDevice and ConfigDevicePost - noob question

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

    ConfigDevice and ConfigDevicePost - noob question

    I'm learning plugin development and have a problem/question - what's the minimum HTML code with just a single button I need to return from ConfigDevice to be able to catch the button click in ConfigDevicePost? I'm looking at many VB and C# samples, but my code doesn't break in ConfigDevicePost when I click the button.
    Something like:
    Code:
    stb.Append("<form id='frmSample' name='SampleTab' method='Post'>");
    stb.Append( BuildButton("Save", "btn_save") );
    stb.Append("</form>");
    return stb.ToString();

    #2
    Why are you not using the jquery-buttons? I am not 100% sure how you go around creating your own buttons and getting them to post to HomeSeer correctly.
    Link
    https://homeseer.com/support/homesee...K/jqbutton.htm
    It even has a working example.

    Comment


      #3
      You should set your breakpoint in PostBackProc - at least that's what I use.

      Also, do use the jQuery buttons - it's much easier...
      HS4Pro on a Raspberry Pi4
      54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
      Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

      HSTouch Clients: 1 Android

      Comment


        #4
        Originally posted by Guahtdim View Post
        Why are you not using the jquery-buttons?
        I am, it's in BuildButton function
        Code:
        var b = new clsJQuery.jqButton(name, label, "PageName", submitForm)
        {
            id = $"o{name}",
        };
        
        var button = b.Build();
        //button = button.Replace("</button>\r\n", "</button>").Trim();
        return button;
        Here's the HTML created:
        HTML Code:
        <form id='frmSample' name='SampleTab' method='Post'>
        <!-- jqButton button1_ID598385-->
        <script>
        $(function() {
        $('#button1_ID598385').button({icons: {primary:'',secondary:''} });
        $('#button1_ID598385').click(function(e) {
        var theform =$('#'+$(this)[0].form.id);
        var theData = theform.serialize();
        returnTrue = false;
        theData = theData+'&id='+this.id+'&button1=Submit';
        commonAjaxPost(theData,'test');
        if(returnTrue) {
        location.reload();
         return false;
        }
        else {
         return false;
        }
        });
        });
        </script>
        <button type='submit'   id='button1_ID598385'  name='button1' >Button for form2</button>
        </form>
        Problem is - PostBackProc() doesn't get called when I press the button - and I don't know how to troubleshoot it?

        Comment


          #5

          in your hspi class, you would define your function that implements your PostBackProc:
          Public Function PostBackProc(ByVal pageName As String, ByVal data As String, ByVal user As String, ByVal userRights As Integer) As String Implements HomeSeerAPI.IPlugInAPI.PostBackProc

          Then, over in your WebPage class, you would override the PostBackProc function with your own:
          Public Overrides Function PostBackProc(page As String, data As String, user As String, userRights As Integer) As String

          You would set your breakpoint in the function in WebPage

          HS4Pro on a Raspberry Pi4
          54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
          Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

          HSTouch Clients: 1 Android

          Comment


            #6
            Originally posted by rmasonjr View Post
            in your hspi class, you would define your function that implements your PostBackProc:
            I know, unfortunately it's not working. I'm using C#, but the code is the same:
            Code:
            public abstract string PostBackProc(string page, string data, string user, int userRights);
            and
            Code:
            public override string PostBackProc(string page, string data, string user, int userRights)
            {
                 Console.WriteLine("PostBackProc: {0} ~ {1}", page, data);
                 return "PostBackProc";
            }
            Drives me nuts

            Comment


              #7
              Actually I'm getting in the log a message, but can't find anything in the source code!

              Code:
               [TABLE="cellspacing: 0"]
              [TR]
              [TD="colspan: 1, align: left"][B]Date/Time[/B][/TD]
               			[TD="colspan: 1, align: left"][B]Pri[/B][/TD]
               			[TD="colspan: 3, align: left"][B]Type/Error[/B][/TD]
               			[TD="colspan: 8, align: left"][B]Message/Source[/B][/TD]
               		[/TR]
              [/TABLE]
              [TABLE="cellspacing: 0"]
              [TR]
              [TD="colspan: 1, align: left"][COLOR=#000000]Dec-12 15:06:57[/COLOR][/TD]
               			[TD="colspan: 1, align: left"][COLOR=#000000] [/COLOR][/TD]
               			[TD="colspan: 3, align: left"][COLOR=#000000]TEST PAGE POST[/COLOR][/TD]
               			[TD="colspan: 8, align: left"][COLOR=#000000]Test page postback data: ref=950&plugin=HSPIPluginB1&instance=&action=pluginpost&id=button1&button1=Submit[/COLOR][/TD]
               		[/TR]
              [/TABLE]

              Comment


                #8
                Looks like I found the problem - I was specifying 'test' page:
                Code:
                clsJQuery.jqButton("button1", "Button for form2", "[B]test[/B]", true)
                I changed it to "deviceutility" - and it works now. Is it HS "hidden feature"?

                Comment


                  #9
                  In HS SDK documentation for jqButton it says
                  p_page String Name of the page this control is on
                  What is it supposed to mean?

                  Comment


                    #10
                    I suspect it is there to help you to send the response to the correct config-page if you have more than one.

                    Comment


                      #11
                      Originally posted by Guahtdim View Post
                      I suspect it is there to help you to send the response to the correct config-page if you have more than one.
                      Not sure - when I was passing "test" as in example jqButton - it wasn't working.

                      Comment


                        #12
                        Try something other than Test. It could be that 'test' is a HS magic string triggering logging. After looking at my own code I see that I use pagename to find the correct config-page to send the postprocessing to.

                        Comment


                          #13
                          Originally posted by Guahtdim View Post
                          Try something other than Test. It could be that 'test' is a HS magic string triggering logging. After looking at my own code I see that I use pagename to find the correct config-page to send the postprocessing to.
                          The button is on "Device Config" page - not plugin config. I tried empty string - didn't work. "deviceutility" works, thanks god - I spent many days trying to figure it out and almost gaveup

                          Comment


                            #14
                            Originally posted by alexbk66 View Post
                            The button is on "Device Config" page - not plugin config. I tried empty string - didn't work. "deviceutility" works, thanks god - I spent many days trying to figure it out and almost gaveup
                            Happen to fall upon this. It is "deviceutility" because that is the pate you are on. For the events page (For triggers/actions) that is "Events". For plugin config pages it's the name of the registered page.

                            I imagine it is so that HS3 knows where to update any info you send back if any (i.e. over write divs, etc without refreshing the whole screen).

                            Comment

                            Working...
                            X