Announcement

Collapse
No announcement yet.

Dim Value Match Script

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

    Dim Value Match Script

    I have been trying to write a script to set my lamps to the same value as the overhead lights whenever the overhead lights change. After tinkering for a while, I realized I was using HS2 code (hs.Transmit, hs.ExecX10). I tried to understand the CAPI scripting but it is way over my head. Can someone point me in the right direction on writing this script or some good resources on learning more about scripting?

    Thanks!

    #2
    This thread is probably a good start for some learning - http://forums.homeseer.com/showthread.php?t=167405

    Comment


      #3
      Thank you! I have come to the realization that I have much to learn on the scripting front. I am going to keep at it, but wanted to post my interim solution for anyone else searching on this.

      I had not done enough research on plug-ins. I was able to accomplish exactly this by using EasyTrigger. I have an event set to do the following: If Family Room Overhead Light has a value that just changed, then EasyTrigger Set Lamp to match Overhead Light.

      Also, I wanted to say thanks for the DoorBird plug-in. I was able to use it to trigger the Jetsons doorbell mp3 through my Sonos speakers when the doorbell rings!

      Comment


        #4
        As an FYI, here's the script I put together before EasyTrigger existed:

        Code:
        Sub Main(ByVal Parms as String)
        
        	Dim ParmArray() as String
        	ParmArray = Parms.tostring.split(",")
        	dim targetDev1 as Double = CDbl(ParmArray(0))		'reference ID of the device to use for existing value
        	dim targetDev2 as Double = CDbl(ParmArray(1))		'reference ID of the device to set based on value of targetDev1
        	dim Debug as Boolean = True
        	Dim logName as String= "Dim Follower"			'set log name for HS log
        
        	Dim dev1Value,dev2Value As Double
        	dev1Value = hs.DeviceValue(targetDev1)
        	dev2Value = hs.DeviceValue(targetDev2)
        
        	If Debug Then hs.writelog(logName,CStr(targetDev1) & ":" & CStr(dev1Value))
        	If dev1Value <> dev2Value Then
        		Select Case dev1Value
        			Case 1 to 98
        				' Device DIM, set its current dim level
        				hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev2, false, CStr(dev1Value), false, true))
        				If Debug Then hs.writelog(logName,CStr(targetDev2) & ":" & CStr(dev1Value))
        			Case 99
        				' Device ON, set it to on
        				hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev2, false, "On", false, false))
        				If Debug Then hs.writelog(logName,CStr(targetDev2) & " Set to On")
        			Case 0
        				' Device OFF, set it to off
        				hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev2, false, "Off", false, true))
        				If Debug Then hs.writelog(logName,CStr(targetDev2) & " Set to Off")
        		End Select
        	Else
        			If Debug Then hs.writelog(logName,"Devices are at same value already")
        	End If
        
        End Sub
        Cheers
        Al
        HS 4.2.8.0: 2134 Devices 1252 Events
        Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

        Comment

        Working...
        X