Announcement

Collapse
No announcement yet.

Controlling multiple devices with one Slider - Solved!

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

    #31
    I could probably clean that code up to use a function call for testing and setting each item. I was in a hurry when I wrote it. Got it working for one and copied it for the rest. Would probably look like this (UNTESTED!):

    Code:
    Sub Main(Parms As Object)
    '  hs.writelog("Parameter Test",CInt(Parms(0)))
    
    
    	'Ceiling Fan
    	TestSet("Ceiling Fan Light Selector", "Ceiling Fan Light")
    
    	'Fireplace Outside Cans
    	TestSet("HSTouch -Fireplace Outside Cans Selector", "Fireplace Outside Lights")
    
    	'Fireplace Inside Cans
    	TestSet("Fireplace Inside Lights", "HSTouch -Fireplace Inside Cans Selector")
    
    	'Entrance Light
    	TestSet("Entrance Light @ Door", "HSTouch - Foyer Selector")
    
    	'Light Outside Powder Room
    	TestSet("Light Outside Powder Room", "HSTouch - Light Outside Powder Room Selector")
    
    	'Stairs Light
    	TestSet("HSTouch - Stairs Light Selector","Main Stairs Lights @ Top of Steps")
    
    End Sub
    
    
    
    Sub TestSet(byRef Selector as String, byRef Device as String)
    
    Dim SelectorRef As Integer
    Dim DevRef As Integer
    
    	'Get the Device References
    	SelectorRef = hs.GetDeviceRefByName(Selector)
    	DevRef = hs.GetDeviceRefByName(Device)
    
    	'Set the Device Value if the Device Selector is selected.
    	If hs.IsOn (SelectorRef) then
    		hs.CAPIControlHandler(hs.CAPIGetSingleControl(DevRef,false,CInt(Parms(0)),false,true))
    	end if
    
    End Sub
    Karl S
    HS4Pro on Windows 10
    242 Devices
    56 Z-Wave Nodes
    37 Events
    HSTouch Clients: 3 Android, 1 iOS
    Google Home: 3 Mini units 1 display

    Comment


      #32
      I could have cleaned that script up a bit but was in a hurry when I wrote it. See this thread for an untested version. If what I am after there is possible, you may find the final answer helpful.
      Karl S
      HS4Pro on Windows 10
      242 Devices
      56 Z-Wave Nodes
      37 Events
      HSTouch Clients: 3 Android, 1 iOS
      Google Home: 3 Mini units 1 display

      Comment


        #33
        CAPI Replacement Script

        Originally posted by ksum View Post
        I could probably clean that code up to use a function call for testing and setting each item. I was in a hurry when I wrote it. Got it working for one and copied it for the rest. Would probably look like this (UNTESTED!)
        I will give this a test to see if it works. On one set of sliders I eliminated the selectors entirely and just used the command. (If I stare at code long enough I can figure out enough to be dangerous)

        One issue I am finding with this set-up is that the slider is sending multiple setpoints to the devices while sliding it to the desired level. In the log I will have 4 pages of device control commands sent to the devices sliding it from 0% to 65%. It then takes the devices forever to process all the commands and get to the desired level. I have the 'Track Realtime' setting on the slider set to False in HSTouch but it continues to do it.

        Another issue I have is that I cannot dim my lights all the way down to 0% or up to 100%. It seems 5%-94% is my range if I'm using the master slider.

        Comment


          #34
          First, be sure to see my code at the linked thread as the untested code I provided does not pass the slider's value. The code there is closer to working, but still untested. Also, in that thread, a way was given to include a second file for the sub function. This allows you to have that portion of the code used for multiple scripts.

          I did some testing and created a thread about slider increments. It appears there is no good way to increment the slider. It could be done in the code with something to only pass values when the passed value is divisible by a given number (i.e. 5 for increments of 5). I am disappointed that HSTouch won't increment the values by a defined amount. Another option, which I mentioned in that thread, would be to create a virtual device with values at increments and track that device. But I would have more virtual devices than actual if I kept using that band-aide to make things work. You may be OK with that, though.

          I also noticed that the values don't like going to 0 or 100. There is a video on Complex Sliders which allow for an On/Off button setting the value to 0 or 100
          Karl S
          HS4Pro on Windows 10
          242 Devices
          56 Z-Wave Nodes
          37 Events
          HSTouch Clients: 3 Android, 1 iOS
          Google Home: 3 Mini units 1 display

          Comment

          Working...
          X