Announcement

Collapse
No announcement yet.

Change a light dim value over a period of time

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

    Change a light dim value over a period of time

    I am a new user of HomeSeer and spent part of the weekend moving all my Z-Wave devices over from SmartThings to the new HomeTroller (Zee S2). Now I'm in the process of recreating all my automations on HS3.

    One of the automations I had on ST was called Gentle Wakeup, and it would change the dim level of a light from 0 to 100 over a period of about 15 minutes. I've got some ideas on how to make this work on HS, but I'm running into difficulty.

    My idea is to create two events: the first is an initial trigger based on time which sets a counter and fires a second event; the second event sets the light dim level based on the counter, updates the counter, waits, and then restarts the second event. The attached picture shows what this "step" event looks like.

    I've run into three problems.

    The first is that I can set a condition that a counter exceeds a value, but I want the condition to be < value.

    The second is that I don't see how to set the value of a dimmer based on a counter. The UI only seems to allow me to set the dim level to explicit values. How do I parameterize this?

    The third is that I don't have a way to retrigger the event. The Run Another Event dropdown list includes every other event but this one. How do I make an event retrigger on an interval? I'm working around this by now by ping-ponging to another event which merely retriggers this one.

    Click image for larger version

Name:	chrome_2019-02-20_00-14-00.png
Views:	283
Size:	210.9 KB
ID:	1286526
    Attached Files
    Last edited by pfreese; February 20, 2019, 03:16 AM. Reason: Added missing attachment

    #2
    You need a script to do this. Here's one that someone posted here. I can't find the post and forget how to use it but as I recall it's pretty straight forward. I also have a more complicated method that requires multiple events if this can't be made to work.


    Code:
    Sub Main(ByVal Parms as String)
    
        Dim ParmArray() as String
        ParmArray = Parms.tostring.split(",")
        dim targetDev as Double = CDbl(ParmArray(0))        'reference ID of the device for which to increase brightness
        dim targetDim as Double = CDbl(ParmArray(1))        'maximum brightness level
        dim rampRate as Integer = CInt(ParmArray(2))        'ramprate in seconds
    
        dim Debug as Boolean = False
        Dim logName = "Sunrise Alarm Script"                'set log type for HS log
        Dim devValue,newdevValue As Double
        Dim i As Double
    
        devValue = hs.DeviceValue(targetDev)
        If Debug Then hs.writelog(logName,"Current:" & CStr(devValue) & " Target:" & CStr(targetDim))
        If targetDim > devValue Then
            For i = devValue + 1 To targetDim
                hs.WaitEvents()
                hs.WaitSecs(rampRate)
                newdevValue = hs.DeviceValue(targetDev)
                If newdevValue = 0 Then                        'if switch is turned off, stop script
                    If Debug Then hs.writelog(logName,"Exited")
                    Exit For
                ElseIf newdevValue < i-2 Then                'if dim value is changed on switch, stop script to stay at that dim level
                    If Debug Then hs.writelog(logName,"Exited")
                    Exit For
                End If
                hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDev, false, CStr(i), false, true))
                If Debug Then hs.writelog(logName,CStr(i))
            Next
        End If
    
    End Sub
    If you can't get this one working I can point you to the more complicated version.
    Originally posted by rprade
    There is no rhyme or reason to the anarchy a defective Z-Wave device can cause

    Comment


      #3
      As with most HA there are a number of ways to do it. Here's a technique without scripting posted by jvm that could be adapted to your situation. link
      -Wade

      Comment


        #4
        Here's the thread where the script that S-F posted is from: https://forums.homeseer.com/forum/ho...hten-over-time
        HS 4.2.8.0: 2134 Devices 1252 Events
        Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

        Comment


          #5
          Originally posted by pfreese View Post
          The third is that I don't have a way to retrigger the event. The Run Another Event dropdown list includes every other event but this one. How do I make an event retrigger on an interval? I'm working around this by now by ping-ponging to another event which merely retriggers this one.
          You can't trigger the same event from itself. It's done to prevent loops that you can't get out of. You'd have to create a second event that would be triggered by the first event and it in turn triggers the first event. Since you are new to HS. there's a great resource on this forum called the Event Clinic. Take a look at this thread related to an event triggering other events: https://forums.homeseer.com/forum/ho...event?t=174310. The table of contents for the event clinic is here: https://forums.homeseer.com/forum/ho...le-of-contents
          HS 4.2.8.0: 2134 Devices 1252 Events
          Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

          Comment

          Working...
          X