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...
      HS3Pro Running on a Raspberry Pi3
      64 Z-Wave Nodes, 168 Events, 280 Devices
      UPB modules via OMNI plugin/panel
      Plugins: Z-Wave, BLRF, OMNI, HSTouch, weatherXML, EasyTrigger
      HSTouch Clients: 3 Android, 1 Joggler

      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

          HS3Pro Running on a Raspberry Pi3
          64 Z-Wave Nodes, 168 Events, 280 Devices
          UPB modules via OMNI plugin/panel
          Plugins: Z-Wave, BLRF, OMNI, HSTouch, weatherXML, EasyTrigger
          HSTouch Clients: 3 Android, 1 Joggler

          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:
               
              Date/Time Pri Type/Error Message/Source
              Dec-12 15:06:57 TEST PAGE POST Test page postback data: ref=950&plugin=HSPIPluginB1&instance=&action=pluginpost&id=button1&button1=Submit

              Comment


              • #8
                Looks like I found the problem - I was specifying 'test' page:
                Code:
                clsJQuery.jqButton("button1", "Button for form2", "test", 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).
                            Thanks,
                            Frank

                            Comment

                            Working...
                            X