Announcement

Collapse
No announcement yet.

What are best practices for saving plugin state??

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

    What are best practices for saving plugin state??

    I am writing a multi instance plugin and I need to save instance / configuration data to some form of non volatile storage. I have used external data files for this purpose in the past but am concerned that this approach will not pass muster for an official HomeSeer plugin.

    I have initially tried using Visual Basic application configuration services:
    https://docs.microsoft.com/en-us/vis...t?view=vs-2017

    Unfortunately, it looks like this approach is much more complicated than it looks from looking at the Microsoft documentation. I am not able to get my saved application data to persist across multiple runs of the plugin.

    So what is best practice here?? I am hoping there is another approach than using Visual Basic application configuration services.

    #2
    Oops. Never mind. I got the Visual Basic application configuration services to work. If there is a different preferred approach, please let me know.

    Comment


      #3
      Most plugins use the ini files for global settings, these are convent since if the plugin is run remotely you still can access the ini file on the HS server. For per device configuration, many developers use the per device data object.

      Comment


        #4
        Originally posted by bsobel View Post
        Most plugins use the ini files for global settings, these are convent since if the plugin is run remotely you still can access the ini file on the HS server. For per device configuration, many developers use the per device data object.
        Thanks for the useful info. I found APIs for adding sections for adding and replacing sections and keys to an ini file {ini(), initadd(), iniaddparam()}. So how do I remove sections and keys from an ini file?

        Comment


          #5
          To clear a section:

          hs.clearinisection("Section_name","My_App_Settings.ini")

          To clear a key:

          hs.SaveINISetting("Section_Name", "Key_Name", "", "My_App_Settings.ini")
          Jon

          Comment


            #6
            I forgot one more thing. What is the API to get an ini file section / key? Is there a way to enumerate ini file sections / keys?

            Thanks

            Comment


              #7
              GetINISection or GetINISectionEx: http://help.homeseer.com/help/HS3/st..._file_editing1
              HS 4.2.8.0: 2134 Devices 1252 Events
              Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

              Comment


                #8
                Have a look at the help file:

                http://help.homeseer.com/help/HS3/st..._file_editing1
                Jon

                Comment


                  #9
                  Sorry. I just realized that the documentation for ini files is in the regular scripting documentation. I didn't know to look there.

                  Thanks for your help.

                  Comment

                  Working...
                  X