Announcement

Collapse
No announcement yet.

how to auto refresh a page, and get a callback to postbackproc

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

    #16
    check upper/lower case, shouldn't be an issue but you never know, especially when you register your link and use of pluginId, your pathname which uses same pluginId, check they are consistently "Insteon" with capital I. Your registration should look something like

    RegisterFeaturePage("Insteon", "statuspage.html", "") and the statuspage.html must be in the \html\Insteon subdirectory

    Comment


      #17
      i think i got it working (at least the POST part). thank you very much
      Mark

      HS3 Pro 4.2.17.0
      Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
      Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
      Platform: Windows Server 2022 Essentials, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

      Comment


        #18
        Originally posted by mnsandler View Post
        i think i got it working (at least the POST part). thank you very much
        Glad to help. Not sure over time you want to have your page refreshing all the time, maybe that is not the intent but if you have questions, glad to share some sample code to refresh just div sections

        Comment


          #19
          Ultimately, I do want to only refresh a couple of div sections...so I'm all ears.

          I need to be able to get the new div values from my plugin
          Mark

          HS3 Pro 4.2.17.0
          Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
          Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
          Platform: Windows Server 2022 Essentials, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

          Comment


            #20
            Originally posted by mnsandler View Post
            Ultimately, I do want to only refresh a couple of div sections...so I'm all ears.

            I need to be able to get the new div values from my plugin
            If there is a piece of info on the page that you want to update, put a <div></div> tag around it and make sure that <div> has an id that is unique, say <div id="veryuniqueInsteon">.

            So if you now postback every 2 seconds to your plugin, the plugin would verify if that info was changed and if so, the content of that div can be updated without updating the page.
            You make up your own syntax but upon receiving a response, what is crutial is the div id and the new content and then you update it something like the following




            $('#'+idivId).empty();
            $('#'+idivId).append(item.updateDivInfo);

            Comment


              #21
              Hey Dirk,
              I got it working with the AjaxPost routine. it accepts a response type from postbackproc that will update divs for you without additional code; which is what i needed for now to get started.

              Return "[""statusmessage"",""" + gBkUpdate.StatusMessage + """,""primaryprogressmessage"",""" + gBkUpdate.PrimaryProgressMessage + """]"
              Mark

              HS3 Pro 4.2.17.0
              Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
              Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
              Platform: Windows Server 2022 Essentials, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

              Comment


                #22
                Originally posted by mnsandler View Post
                Hey Dirk,
                I got it working with the AjaxPost routine. it accepts a response type from postbackproc that will update divs for you without additional code; which is what i needed for now to get started.
                Awesome!

                Comment


                  #23
                  Originally posted by mnsandler View Post
                  Hey Dirk,
                  I got it working with the AjaxPost routine. it accepts a response type from postbackproc that will update divs for you without additional code; which is what i needed for now to get started.
                  Can you lease provide more code example?

                  Comment


                    #24
                    Originally posted by mnsandler View Post
                    Return "[""statusmessage"",""" + gBkUpdate.StatusMessage + """,""primaryprogressmessage"",""" + gBkUpdate.PrimaryProgressMessage + """]"
                    BTW, in JS using Template Literals make string concatenation more readable


                    Code:
                    let a = 5; b = 10;
                    console.log('Sum of %d and %d is %d.', a, b, (a+b));
                    [EDIT]

                    In C#:

                    Code:
                    $"[\"{statusmessage}\",\"{gBkUpdate.StatusMessage}\",\"{primaryprogr essmessage}\",\"{gBkUpdate.PrimaryProgressMessage}\"]"

                    Comment


                      #25
                      ie
                      Originally posted by alexbk66 View Post

                      Can you please provide more code example?
                      Here are a few more return values that AjaxPost accepts and responses to:

                      refresh the current page; I use this after the user changes a filter select list
                      Code:
                      Result = "[""PAGE_refresh"",""true""]"

                      jump to a new page where NextPage is a variable containing the filename
                      Code:
                      Result = "[""PAGE_newpage"",""" + NextPage + """]"
                      Mark

                      HS3 Pro 4.2.17.0
                      Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
                      Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
                      Platform: Windows Server 2022 Essentials, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

                      Comment


                        #26
                        Originally posted by alexbk66 View Post

                        BTW, in JS using Template Literals make string concatenation more readable


                        Code:
                        let a = 5; b = 10;
                        console.log('Sum of %d and %d is %d.', a, b, (a+b));
                        [EDIT]

                        In C#:

                        Code:
                        $"[\"{statusmessage}\",\"{gBkUpdate.StatusMessage}\",\"{primaryprogr essmessage}\",\"{gBkUpdate.PrimaryProgressMessage}\"]"
                        thanks for this; i'll give it a try
                        Mark

                        HS3 Pro 4.2.17.0
                        Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
                        Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
                        Platform: Windows Server 2022 Essentials, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

                        Comment


                          #27
                          Originally posted by mnsandler View Post
                          thanks for this; i'll give it a try
                          You can insert variables directly into the string

                          Code:
                          let eggCount = 20;
                          console.log(`On easter we decorted ${eggCount}` easter eggs)

                          Comment

                          Working...
                          X