Announcement

Collapse
No announcement yet.

Hide A device button via script

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

  • Hide A device button via script

    Totally new to Homeseer.... That said I am happy with the move from the Vera environment.

    Question is, can I use a script to hide a button? I currently have a Virtual switch with 5 elements: Open, Close, 1 Hour, 2 Hour, 3 Hour. I would like to hide the Open Button if the 1 2 or 3 Hour buttons are selected.

    CAPIControlLocation could be used to set the row / column to both 0 hence hiding the button but I have no idea of its syntax for implementation for setting there values of if it is even possible.

    I can find no example of it's usage in any of my searches. Any push in the right direction would be appreciated.

    Thanks Aundee

  • #2
    Originally posted by Aundee View Post
    Totally new to Homeseer.... That said I am happy with the move from the Vera environment.

    Question is, can I use a script to hide a button? I currently have a Virtual switch with 5 elements: Open, Close, 1 Hour, 2 Hour, 3 Hour. I would like to hide the Open Button if the 1 2 or 3 Hour buttons are selected.

    CAPIControlLocation could be used to set the row / column to both 0 hence hiding the button but I have no idea of its syntax for implementation for setting there values of if it is even possible.

    I can find no example of it's usage in any of my searches. Any push in the right direction would be appreciated.

    Thanks Aundee
    It's a little confusing because you have to have at least one visible VSPair it appears, if you have one control pair that is set to 1,1 (column/row) then the one still set to 0,0 will go hidden. If however you have both set to 0,0 then it will show all controls so it is not possible to hide all of the VSPairs.

    I'm not sure they were really designed for hiding on the fly and I'm not sure there is a good way of doing it because you would have to get the control, copy it's properties and then add a new one but with the render_location changed. I can't say I've ever seen a scripting command to edit a pair, just add, get and delete.

    Here is a script that would create one pair hidden and one pair visible.

    Code:
    Sub Main(ByVal Parms As Object)
    
        Try
    
        Dim dv As Scheduler.Classes.DeviceClass = hs.GetDeviceByRef(1762)
    
                        Dim Pair As VSPair
    
                        Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Both)
                        Pair.PairType = VSVGPairType.SingleValue
                        Pair.Status = "Stop"
                        Pair.Render_Location.Row = 0
                        Pair.Render_Location.Column = 0
                        Pair.Value = 0
                        Pair.Render = Enums.CAPIControlType.Button
                        Pair.ControlUse = ePairControlUse._Off 'HSTouch?
                        hs.DeviceVSP_AddPair(dv.Ref(hs), Pair)
    
                        Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Both)
                        Pair.PairType = VSVGPairType.SingleValue
                        Pair.Render_Location.Row = 1
                        Pair.Render_Location.Column = 1
                        Pair.Status = "Start"
                        Pair.Value = 100
                        Pair.Render = Enums.CAPIControlType.Button
                        Pair.ControlUse = ePairControlUse._On 'HSTouch?
    
                        hs.DeviceVSP_AddPair(dv.Ref(hs), Pair)
    
                        dv.MISC_Set(hs, Enums.dvMISC.SHOW_VALUES)
    
        Catch ex As Exception : hs.writelog("", "Exception: " & ex.Message.ToString)
        End Try
    
    End Sub

    Comment


    • #3
      Thanks!

      Will give it a go and let you know how it goes!

      Comment


      • #4
        Works Great!!!!

        Edited the script with notes for those of us less gifted in coding and thanks much for the help! It works perfectly. In the end I'll be using this to control my drive gate with a count down timer. If it is held open for a period of time, I don't want the open option available to the end user. This will hide the button if it is held open for a time frame.

        Try

        Dim dv As Scheduler.Classes.DeviceClass = hs.GetDeviceByRef(1762)

        Dim Pair As VSPair

        Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Both)
        Pair.PairType = VSVGPairType.SingleValue
        Pair.Status = "Stop" ' Sets the Button Label
        Pair.Render_Location.Row = 0 'Sets the Button Location
        Pair.Render_Location.Column = 0 'Sets the Button Column
        Pair.Value = 0 ' Sets the Value of the Button This is important if you have multiple buttons as to whitch to hide
        Pair.Render = Enums.CAPIControlType.Button
        Pair.ControlUse = ePairControlUse._Off 'HSTouch?
        hs.DeviceVSP_AddPair(dv.Ref(hs), Pair)

        Comment

        Working...
        X