Announcement

Collapse
No announcement yet.

Get device data based on device name, location1 and location2

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

    Get device data based on device name, location1 and location2

    I looking for a way to get device data with the devicename and location 1 (and location2) as search criteria.
    In my HS setup the name en location1 gives me already the capability to address every single device.

    I've seen the topics (solutions) that go through the whole devicelist but is it possible to query the HS db and fetch directly single device data like the Reference ID?

    #2
    As location 1 and/or location 2 can be duplicated between devices, it would not be possible to do this as a specific scripting command.

    Best to iterate though all devices and find what you are looking for. Takes no time at all to go through the list.
    Jon

    Comment


      #3
      While the combination of: Location2 + Location + Name may not be unique, you can obtain device info via the full name. HS will return the first device that matches. If you know you do not have duplicates, then you will be fine.

      Code:
      hs.GetDeviceRefByName("Basement Storage CedarClosetDoor"))
      
      hs.DeviceStringByName("Basement Storage CedarClosetDoor")
      
      MyDevice = CType(hs.GetDeviceByRef(hs.GetDeviceRefByName("Basement Storage CedarClosetDoor")),Scheduler.Classes.DeviceClass)
      Courtesy of: http://tenholder.net/tenWare2/tenScriptAid/default.aspx
      tenholde

      Comment

      Working...
      X