No announcement yet.

Virtual Device vs. Global Variable

  • Filter
  • Time
  • Show
Clear All
new posts

    Virtual Device vs. Global Variable

    I am a novice HS scripter and utilize Virtual Devices to hold data that I need for my scripts, but never actually use the virtual device for any other purpose.

    I guess my question is, what is the difference between using a Virtual Device vs a Global variable for this purpose. I know that global variables have to be defined each time HS is started up, but are they easier to use or should I just stick with virtual devices?

    Virtual devices

    String/double integer is stored in the Homeseer database and not lost when rebooting.
    Can be read/saved by any script.

    Can only store a single string and/or double Integer
    String will be visible on the web page against this virtual device.

    Global variables

    Can hold any object (String,Integer,Array etc).
    Can be read/saved by any script once created.
    Unlimited number of variables can be created.

    Variables are lost after each restart of Homeseer and have to be recreated.
    Can only store a single object per variable created.

    Ini files

    Can hold any string.
    Globally available to be read/written from any script.
    Multiple storage areas available
    Data is never normally lost.

    Can only store strings (but can be converted to Integers etc)
    May be slightly slower in read times than other methods


      Wow thanks Jon. That clears it up for me. INI files are still over my head (except for updating the values in an already created one IE. your plugins).

      I like the idea of being able to store Arrays as I have a few scripts doing that already and that is where my experience and learning is right now with scripting in

      Thanks again.