Announcement

Collapse
No announcement yet.

Retrieve device NAME via script

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

  • Retrieve device NAME via script

    Hello,

    I have a couple of devices who's names change fairly frequently. In HSTouch I'd like to retrieve their names via script so that I don't have to update HSTouch everytime I change the device names. I can't seem to find a script method to retrieve name but figure there's got to be one. Anyone have any ideas?

    Thanks
    Ben

  • #2
    Originally posted by bwstein View Post
    Hello,

    I have a couple of devices who's names change fairly frequently. In HSTouch I'd like to retrieve their names via script so that I don't have to update HSTouch everytime I change the device names. I can't seem to find a script method to retrieve name but figure there's got to be one. Anyone have any ideas?

    Thanks
    Ben
    This might sound crazy, but to me, the solution is to create virtual devices with names that never change. Anytime the name-changing devices status/value updates, an event is triggered to copy status to the corresponding virtual devices. In this way, you can use the device code in the event trigger instead of a device reference (like HSTouch uses in the deployed project xml files) or device name like they appear in the HSTouch designer.
    huggy_d1

    Automating made easy

    Comment


    • #3
      I am a bit confused here - HSTouch if you have status tracked these elements then no matter what you change their names to then it should not matter as the tracking (AFAIK) is to the device reference, not the name/code.

      Are you talking about labels that hold just the names of the devices? You could if you wanted put a script command in so these always had the latest names but excessive script commands on a page brings its own set of problems. Something like this might work;

      [$SCRIPT=&hs.getdevicebyref(hs.getdeviceref("A1")).name]
      My Plugins:

      Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
      Yeelight 3P | Nanoleaf 3P

      Comment


      • #4
        Mr. Happy,

        Yep, that's exactly what I wanted to do. I hope this won't slow the page down too much, it's only about four labels on the page that will have dynamic names. I'll give it a try and see if it has too much of an effect on performance.

        Thanks again
        Ben

        Comment


        • #5
          Hm. I was hoping to do something like this in a script I was working on. I haven't figured out how to get the syntax to work right yet.

          Was trying something like:

          hs.WriteLog (MessageID, "Time is set to " & UpTime & " (From Device: " & TimeDevice & " - " & GetDeviceByRef(TimeDevice).name & ")")

          I must be doing something that isn't allow by vb because it doesn't work. . .

          Comment


          • #6
            There is actually the function hs.devicename (not in the help file) that will do what you expect, but that syntax would have a number of issues - is that part of a script? Are you able to share the wider script?
            My Plugins:

            Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
            Yeelight 3P | Nanoleaf 3P

            Comment


            • #7
              Originally posted by mrhappy View Post
              There is actually the function hs.devicename (not in the help file) that will do what you expect, but that syntax would have a number of issues - is that part of a script? Are you able to share the wider script?
              Nice! Not sure why that isn't in the help!

              Hm. The script is probably a bit large to post inline. I am basically tweaking the Alarm Clock script from here:
              https://forums.homeseer.com/showthread.php?t=157784

              I got it working for HS3, but I was just trying to make the log descriptions easier to understand with names instead of just the device reference.

              Comment


              • #8
                if you are just after the device name use something like
                PHP Code:
                        Dim Ref As Integer 1234
                        Dim Name 
                As String Nothing
                        Dim dv 
                As Scheduler.Classes.DeviceClass
                        dv 
                hs.GetDeviceByRef(Ref)
                        
                Name dv.Name(hs
                hs.devicename is ok but it returns the type and location to.

                Greig.
                Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
                X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
                Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
                Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
                Scripts =
                Various

                Comment


                • #9
                  Originally posted by enigmatheatre View Post
                  if you are just after the device name use something like
                  PHP Code:
                          Dim Ref As Integer 1234
                          Dim Name 
                  As String Nothing
                          Dim dv 
                  As Scheduler.Classes.DeviceClass
                          dv 
                  hs.GetDeviceByRef(Ref)
                          
                  Name dv.Name(hs
                  hs.devicename is ok but it returns the type and location to.

                  Greig.
                  Nice. That is what I was missing. Didn't know what type to use in the Dim statement in order to access the device as an object. Thanks.

                  Comment

                  Working...
                  X