Announcement

Collapse
No announcement yet.

HS4 Get total number of devices in script

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

    HS4 Get total number of devices in script

    Is there a way of getting the total number of HS devices in a script? I am trying to get away from hard coded device references in my scripts and want to loop through the devices to find specific text.

    #2
    To get all devices, you can call GetAllDevices(bool withFeatures) but this is a very expensive method to call.
    To get a list of all the Device Refs, you can call GetAllDeviceRefs() or GetAllRefs() which will return a list of all Device Refs.
    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


      #3
      I haven't done anything with the pluginSDK yet. I am working in Visual Studio 2022 with tenScripting and I can see some of the plugin SDK properties but I don't see those methods. I'm not sure if I have to import something else.

      Comment


        #4
        The HS4 scripting functionality is provided by the PluginSDK library as the class IhsController. The hs4 object is instanitated from this class in both the HS4 scripting environment and in tenScripting. In both you would use: hs4.GetAllDevices(True).

        In HS4, the hs3 scripting functionality from class IHSapplication and the hs4 scripting additions from IhsController are both available using the hs object. So, you could use either hs.GetAllDevices() or hs4.GetAllDevices() in HS scripting. However, only hs4.GetAllDevices() will work in tenScripting. Best practice is to always use hs for HS3 methods and hs4 for HS4 additions (there are some methods that exist in both classes, and hence require the use of the proper object).

        This page may clarify some: http://tenholder.net/tenWare2/tenScr...S4Changes.aspx

        tenholde

        Comment


          #5
          Thanks Ed. It's working nicely.

          Comment

          Working...
          X