Announcement

Collapse
No announcement yet.

Getting Cast from 'String' to type 'Integer' is not valid

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

    Getting Cast from 'String' to type 'Integer' is not valid

    Hi

    I know I am missing some simple . I have the following very basic script running on Troller Z Raspberry PI

    Code:
    sub Main(parm as object)
    
        hs.WriteLog("Node 22 Device Q69", "Querying")
    
    hs.speak("Your Hot tub has a temperature of "   ) 
    hs.speak(hs.DeviceValue("Q69"))
    
    End Sub
    the ref to the device value throws the following error:
    Error 1 Running script /usr/local/HomeSeer/scripts/Startup.vb :Exception has been thrown by the target of an invocation.Cast from 'String' to type 'Integer' is not valid.
    The device is a z wave at node 22 with a reference of code of Q69

    I tried using cstr to no avail. the value of Q69 is a temperature ie current value is 103.1 F

    Thanks for any help

    #2
    hs.DeviceValue now uses the Reference ID for a device. This will be in the format hs.DeviceValue(1234) where 1234 is the reference number for Q69. This only outputs an Integer so would return 103

    You should be using hs.devicevalueEx(1234) which will give you a double Integer output i.e. 103.1
    Jon

    Comment


      #3
      Originally posted by wkrasner View Post
      Hi

      I know I am missing some simple . I have the following very basic script running on Troller Z Raspberry PI

      Code:
      sub Main(parm as object)
      
      hs.WriteLog("Node 22 Device Q69", "Querying")
      
      hs.speak("Your Hot tub has a temperature of " )
      hs.speak(hs.DeviceValue("Q69"))
      
      End Sub
      the ref to the device value throws the following error:
      Error 1 Running script /usr/local/HomeSeer/scripts/Startup.vb :Exception has been thrown by the target of an invocation.Cast from 'String' to type 'Integer' is not valid.
      The device is a z wave at node 22 with a reference of code of Q69

      I tried using cstr to no avail. the value of Q69 is a temperature ie current value is 103.1 F

      Thanks for any help
      The parameter for DeviceValue is the device reference id, not the address code. The id is an integer hence the error message.
      Also you should really use hs.DeviceValueEx(dvRef) because hs.DeviceValue(dvRef) returns an integer so decimal values will be truncated.

      Steve

      Comment


        #4
        Jon00 replied while I was typing

        Comment


          #5
          Thanks guys worked great

          Comment

          Working...
          X