Announcement

Collapse
No announcement yet.

Getting a Device SubType Description Value

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

    Getting a Device SubType Description Value

    Hi,

    Can anyone help point me in the direction of pulling the value of a Device_SubType?

    I would like to populate a Virtual Device with the 'Battery days left' value.



    I apologise for my code as I have next to nothing in terms of coding experience, but I've tried to write it as logically (how I understand it) as possible.

    I've basically lifted bits from the HS3 End User Doc

    Code:
    sub main()
    
    Dim myVal as string
    Dim DT As New DeviceAPI.DeviceTypeInfo
    
    DT.Device_SubType_Description = "Battery days left"
    
    [COLOR=Red]'here I think I need to set myVal to be the value of Device_SubType_Description value? Then set my Virtual device (443) to equal myVal [/COLOR]
    
    hs.setdevicestring(443, myVal,true)
    
    end sub
    THANKS!

    #2
    there's not a DT.Device_SubType_Value

    If I had to guess, I bet they are using PED (Plugin Extra Data) to store the values. Pulling them out requires a little more coding. You might ask the plugin author what the "key" name is for storing that value.
    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
      Thanks for the reply. It was the plugin author that pointed me in this direction.

      Comment


        #4
        Run this script and change 552 to the device reference that you are after. See what goes into the HS log and copy and paste the results here. If that data is stored in a key then perhaps luck might come up but if it isn't or it is stored in some custom format it may not be possible to get this out.

        Code:
        Sub Main(ByVal Parm As Object)
        
            Try
        
            Dim dv As Scheduler.Classes.DeviceClass
        
            dv = hs.getdevicebyref(552)
        
        	Dim EDO as clsPlugExtraData = Nothing
        	EDO = dv.PlugExtraData_Get(hs)
        
        	If EDO IsNot Nothing Then
        		If EDO.NamedCount > 0 Then
        			Dim Keys() As String = Nothing
        			Keys = EDO.GetNamedKeys
        			If Keys IsNot Nothing AndAlso Keys.Count > 0 Then
        				For i As Integer = 0 to Keys.Length - 1
                            hs.writelog("", "One of the named keys is:" & Keys(i))
        				Next
        			End If
        		End If
        	End If
        
            Catch ex As Exception : hs.writelog("", "Exception: " & ex.message)
            End Try
        
        End Sub

        Comment


          #5
          Really appreciate your help!

          I've just run it and the following happened in the log. Nothing else came out after it.

          Jan-21 10:17:50 Event Running script in background: C:/Program Files (x86)/HomeSeer HS3/scripts/Sys.vb
          Jan-21 10:17:50 Event Event Trigger "TEST Test - Battery Script"
          Jan-21 10:17:50 Event Event TEST Test - Battery Script triggered by the event page 'Run' button.








          Comment


            #6
            I'm afraid then it's a bit of a mystery where and how the data is stored, it could be stored in a database or anything and I am not a user of RFXCOM. The sub type is only used as a reference and not normally used to store data http://www.homeseer.com/support/home...escription.htm

            Comment


              #7
              Originally posted by X10Ben View Post
              Hi,

              Can anyone help point me in the direction of pulling the value of a Device_SubType?

              I would like to populate a Virtual Device with the 'Battery days left' value.



              I apologise for my code as I have next to nothing in terms of coding experience, but I've tried to write it as logically (how I understand it) as possible.

              I've basically lifted bits from the HS3 End User Doc

              Code:
              sub main()
              
              Dim myVal as string
              Dim DT As New DeviceAPI.DeviceTypeInfo
              
              DT.Device_SubType_Description = "Battery days left"
              
              [COLOR=Red]'here I think I need to set myVal to be the value of Device_SubType_Description value? Then set my Virtual device (443) to equal myVal [/COLOR]
              
              hs.setdevicestring(443, myVal,true)
              
              end sub
              THANKS!
              I believe he meant that it's contained within the Device_Subtype_Description (TEMP2[5380]Ly36509/3/2015n)
              It's a bit obtuse but it contains the entries you make on the RFXcom device page (ie battery life and date of install) , so you'll need to parse the data out and calculate the time difference yourself.

              Here's a start. Replace the XXX with the device refID


              Z

              Code:
              Sub Main(ByVal Parm As Object)
              
                  Try
              
                  Dim dv As Scheduler.Classes.DeviceClass
                  Dim SubType As String = Nothing
                  Dim SubString As String() = Nothing
              
                  dv = hs.getDevicebyRef(XXXX)
                  SubType = dv.DeviceType_Get(hs).Device_SubType_Description
              
                  hs.writelog("Test","SubType=" & SubType)
              
                  Catch ex As Exception : hs.writelog("", "Exception: " & ex.message)
                  End Try
              
              End Sub

              Comment


                #8
                Thanks for the replies guys.

                Running the second lot of code gives me

                SubType=ELEC3[35746]Ly36518/06/2016n
                So all I need to do now is:

                1. Use the install date from the above and work out the no. of days which have passed up to the current date
                2. Take this figure away from 365
                3. Populate this info into my Virtual device

                I'll give this a go later.

                Thanks again :-)

                Comment


                  #9
                  Originally posted by X10Ben View Post
                  Thanks for the replies guys.

                  Running the second lot of code gives me

                  So all I need to do now is:

                  1. Use the install date from the above and work out the no. of days which have passed up to the current date
                  2. Take this figure away from 365
                  3. Populate this info into my Virtual device

                  I'll give this a go later.

                  Thanks again :-)
                  Only "problem" will be delineating the battery time and date since there's not a delimiter between them and the length depends on what you entered. If you standardize on 3 digit battery lengths and 2 digit months/days you should be able to parse it out manually then.

                  Z

                  Comment

                  Working...
                  X