Announcement

Collapse
No announcement yet.

Fan Control

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

    Fan Control

    People,

    I'm trying to automate a fan dependent on room temperature. I have tried hs.setdevicevaluebyname(,) with no success and currently grinding on CAPIControl but lack the knowledge of CAPIanything. My test script
    Code:
        Public Sub Main(Parms As Object)
    
            Dim setting As Double = 50
            Dim objCAPIControl As CAPIControl
            Dim dvRef As Integer
    
            dvRef = hs.GetDeviceRefByName(deviceName)
            'objCAPIControl = hs.CAPIGetSingleControlByUse(dvRef, ePairControlUse._Off)
            objCAPIControl = hs.CAPIGetSingleControlByUse(dvRef, setting)
            If objCAPIControl IsNot Nothing Then
                hs.CAPIControlHandler(objCAPIControl)
            End If
    
        End Sub
    is trying to set the fan to 50. Building an event to 50 works but events are not dynamic enough.

    The values available for the fan are 0=off, 1-99=speed

    Thanks in Advance!
    J

    #2
    Here's an example of a script that I use for ceiling fans to loop through low, medium, high and off:

    Code:
    Sub Main(ByVal theDevice As String)
    	Dim devValue As Double
    	' Get the Device Status
    	devValue = hs.DeviceValue(theDevice)
    	Select Case devValue
    		Case 0
    		hs.CAPIControlHandler(hs.CAPIGetSingleControl(theDevice,false,"33",false,true))
    		Case 1 To 33
    		hs.CAPIControlHandler(hs.CAPIGetSingleControl(theDevice,false,"66",false,true))
    		Case 34 To 66
    		hs.CAPIControlHandler(hs.CAPIGetSingleControl(theDevice,false,"On",false,false))
    		Case 67 To 100
    		hs.CAPIControlHandler(hs.CAPIGetSingleControl(theDevice,false,"Off",false,false))
    	End Select
    End Sub
    Hope that points you in the right direction.

    Cheers
    Al
    HS 3.0.0.548: 1990 Devices 1172 Events
    Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

    Comment


      #3
      Perfect!

      One last question. I encounter a strange behavior when entering "10", here is the log "May-28 9:35:10 AM Device Control Device: 1st Living Room LivingRoomFan - Node 14 to 100% (99) by/from: CAPI Control Handler" Now if I enter "9" or "11" or it seems any other number. The result seems to be appropriate. Why is that?

      J

      Comment


        #4
        Got, typed too soon, % sign adds new perspective. Al, thanks AGAIN for your help!

        J

        Comment


          #5
          Originally posted by jsyers View Post
          Perfect!

          One last question. I encounter a strange behavior when entering "10", here is the log "May-28 9:35:10 AM Device Control Device: 1st Living Room LivingRoomFan - Node 14 to 100% (99) by/from: CAPI Control Handler" Now if I enter "9" or "11" or it seems any other number. The result seems to be appropriate. Why is that?

          J
          Originally posted by jsyers View Post
          Got, typed too soon, % sign adds new perspective. Al, thanks AGAIN for your help!

          J
          You're welcome. The last true/false in the function call is for whether to check if the status contains that value. So if it is set to true, it will look for a partial match and if it is set to false it will look for a complete match. If it is set to True and you look for 10, 100 contains 10, so it could find it first. Adding the % will make sure it gets the right match (since 100% does not contain 10%). Hope that makes sense.

          Cheers
          Al
          HS 3.0.0.548: 1990 Devices 1172 Events
          Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

          Comment


            #6
            For help with CAPI calls for specific devices, you should look at:

            http://tenholder.net/tenWare2/tenScriptAid/default.aspx

            https://www.youtube.com/watch?featur...&v=Lt5cPChb9jw

            tenholde
            Last edited by tenholde; May 28, 2016, 09:08 AM.
            tenholde

            Comment

            Working...
            X