Announcement

Collapse
No announcement yet.

Device Values

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Device Values

    I have been able to use virtual devices, simply by assigning a string to a fictious device e.g. hs.SetDeviceString "T90", "Hello". This will work fine up to values of 99 (T99 etc) but for some reason, I cannot seem to write a Device Value to the same virtual device, only a string. Can anyone tell me what the restriction is, I have read somewhere in the help that you can only use q - z 17 - 64, is that right? How can I then still write and retrieve strings to T99 ? Slightly puzzled as to what the limitations are. Can someone explain ?

    #2
    I probably don't fully understand your question, but if you want a Device Value to appear on the Devices or 'Status' page, you have to copy it to the Device String. Each device can have a Device Status (an integer), a Device Value (also an integer), and a Device String. Under default conditions the Device Status is automatically converted to a string, such as 'On' or 'Off' and displayed on the Status page. If the device has a non-null string, then that is displayed instead. (There are also things called value-status / graphics pairs, but that's for a different day.)

    Can you elaborate a bit more on what you would like to do?
    Mike____________________________________________________________ __________________
    HS3 Pro Edition 3.0.0.548, NUC i3

    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

    Comment


      #3
      Thanks Mike. I would really just like to use the DeviceValue to store some variables, rather than using SaveVar and GetVar as these are volatile in memory i.e. if you restart HomeSeer, your variable are gone (as I understand it). I don't need to 'see' these devices in the status page, they are just used in scripts. So I have say T80 through to T90 as devices where I can store values as strings in the DeviceString property. It still works, but if I would like to use proper Integer values then it would make sense to use the DeviceValue property, however if I set a DeviceValue of T90 to 1234 and set the DeviceString to 1234, then although there is no error reported in the log or anywhere else, I can only retrieve the 1234 from the String, but the DeviceValue will read 0 (give it a try yourself):
      hs.SetDeviceString "T90", "1234"
      hs.SetDeviceValue "T90", 1234
      hs.Writelog "Hello", "DeviceString = "hs.DeviceString("T90") &" - DeviceValue = " & hs.DeviceValue("T90")

      It will return: DeviceString = 1234 - DeviceValue = 0
      Why is this ??

      Comment


        #4
        Originally posted by vossenh View Post
        Thanks Mike. I would really just like to use the DeviceValue to store some variables, rather than using SaveVar and GetVar as these are volatile in memory i.e. if you restart HomeSeer, your variable are gone (as I understand it). I don't need to 'see' these devices in the status page, they are just used in scripts. So I have say T80 through to T90 as devices where I can store values as strings in the DeviceString property. It still works, but if I would like to use proper Integer values then it would make sense to use the DeviceValue property, however if I set a DeviceValue of T90 to 1234 and set the DeviceString to 1234, then although there is no error reported in the log or anywhere else, I can only retrieve the 1234 from the String, but the DeviceValue will read 0 (give it a try yourself):
        hs.SetDeviceString "T90", "1234"
        hs.SetDeviceValue "T90", 1234
        hs.Writelog "Hello", "DeviceString = "hs.DeviceString("T90") &" - DeviceValue = " & hs.DeviceValue("T90")

        It will return: DeviceString = 1234 - DeviceValue = 0
        Why is this ??
        You can subtract a long from a string. You must convert the string to a int or long first.
        💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

        Comment


          #5
          After fixing your WriteLog syntax, my log entries are:

          2/1/2010 11:48:52 AM Info Event Trigger "testsss"
          2/1/2010 11:48:52 AM Info Running script in background: testss.txt
          2/1/2010 11:48:52 AM Hello DeviceString = 1234 - DeviceValue = 1234




          tenholde
          tenholde

          Comment


            #6
            You had:

            hs.Writelog "Hello", "DeviceString = "hs.DeviceString("T90") &" - DeviceValue = " & hs.DeviceValue("T90")



            You meant:

            hs.Writelog "Hello", "DeviceString = " & hs.DeviceString("T90") & " - DeviceValue = " & hs.DeviceValue("T90")


            tenholde
            tenholde

            Comment


              #7
              Hi Ed, I don't understand. You are correct about the error, but I had this corrected in the script when I ran it. I have now used the following:
              hs.SetDeviceString "U90", "1234"
              hs.SetDeviceValue "U90", 1234
              hs.Writelog "Hello", "DeviceString = "& hs.DeviceString("U90") &" - DeviceValue = " & hs.DeviceValue("U90")

              The log then reports the following:
              02/02/2010 11:53:19 Event Running script in background: test1
              02/02/2010 11:53:20 Hello DeviceString = 1234 - DeviceValue = 0

              As you can see, the DeviceValue is 0. How can it be that you get a value of 1234 and I don't. Totally confused.

              Harry

              Comment


                #8
                What version of HS?

                How is your device defined - as a Virtual Device?

                I'm mystified as well.

                tenholde
                tenholde

                Comment


                  #9
                  OK, I think I have solved the Mistery. When I used the script to store devicestring and devicevalues in U90 or T90, I had not created the devices in the status page (i.e. by using Add Devices and setting them up). Interestingly enough, you therefore seem to be able to use these devices to store a devicestring, without the need to add them as a device, the downside is that you cannot access the devicevalue.

                  I have now added the U90 device as a Virtual device and the same script now indeed returns both the devicestring AND the correct deviceValue.

                  Lesson here for me is that if you just want to use virtual devices to store variables, without wanting to create them as devices and therefore clog up your status page, you can simply use the devicevalue property. If you want to access the devicevalue property, you MUST set up the device properly as virtual device from the status page (or I suppose by script). Hope that is all correct. Any comments from HomeSeer on this ??

                  Harry

                  Comment

                  Working...
                  X