Announcement

Collapse
No announcement yet.

How DeviceValuesGraphicsAdd works with value ranges

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

    How DeviceValuesGraphicsAdd works with value ranges

    Could someone post an example on how to add custom images for device value ranges with DeviceValuesGraphicsAdd?

    I want to monitor the free space in the HS Disk and then change the device image based on this value, ie:

    0GB..2GB -> error.gif
    2GB..10GB -> warning.gif
    >10GB -> ok.gif

    Any help would be appreciated

    Thanks

    Juan

    #2
    Here is an example:

    Code:
    Public Sub Main(ByVal Parms As Object)
            Dim Pairs As String
            Dim theDevice As String = "a1"
    
            '' Add Value/String Pairs to Device
            Pairs = "One" & Chr(2) & "1"                    ' String for value of 1
            Pairs = Pairs & Chr(1)                          ' Separator between value/string pairs
            Pairs = Pairs & "Two" & Chr(2) & "2"            ' String for value of 2
            hs.DeviceValuesAdd(theDevice, Pairs, True)
    
            '' Add Image/Value Pairs to Device
            Pairs = "one.gif" & Chr(2) & "1"                ' Image for value of 1
            Pairs = Pairs & Chr(1)                          ' Separator between image/value pairs
            Pairs = Pairs & "two.gif" & Chr(2) & "2"        ' Image for value of 2
            hs.DeviceValuesGraphicsAdd(theDevice, Pairs)    ' Add the image/value pairs to the device
        End Sub
    Some key notes:

    (1) You must add value/string pairs for image/values to display
    (2) For the above example, images one.gif and two.gif must be in:
    \homeseer 2\html\Images\



    To change images/text based upon ranges, you might do something like:

    Use values of 1,2,3 for the three ranges in your example. Set the value for the device based upon the your disk space ranges. Set value/strings to text of the ranges and image/values to your images.


    tenholde
    tenholde

    Comment


      #3
      Originally posted by juande View Post
      Could someone post an example on how to add custom images for device value ranges with DeviceValuesGraphicsAdd?

      I want to monitor the free space in the HS Disk and then change the device image based on this value, ie:

      0GB..2GB -> error.gif
      2GB..10GB -> warning.gif
      >10GB -> ok.gif

      Any help would be appreciated

      Thanks

      Juan

      DeviceValuesGraphicsAdd is designed for a finite set of values. here is a simple script to update the devicestring based on your ranges.

      The following vb.net assumes a virtual device that already has the free space (in GBs) saved in its devicevalue. replace the square brackets [] with triangle brackets <>

      save as freespace.vb and run as hs.runex "freespace.vb","main","" from action of event


      sub main(parms as object)

      select case hs.devicevalue("a1")
      case is <= 2
      hs.setdevicestring ("a1","[img src=error.gif]")
      case 2 to 10
      hs.setdevicestring ("a1","[img src=warning.gif]")
      else
      hs.setdevicestring ("a1","[img src=ok.gif]")
      end select
      end sub
      Mark

      HS3 Pro 4.2.19.5
      Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
      Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
      Platform: Windows Server 2022 Standard, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

      Comment

      Working...
      X