Announcement

Collapse
No announcement yet.

Dim or brighten over time?

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

    Dim or brighten over time?

    I've seen videos about having a light come on dimly at sunrise and slowly brighten over an hour or so to wake you. What's the best way to do this kind of thing in hs3?
    -Tim

    HSPro - 3.XXX - Dell mini W7 x32
    Way2 Call
    Elk M1 Gold
    UPB HAI switches
    HAI RC2000 Thermostat

    #2
    Hi Tim,

    I use a script for that:

    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
    It needs 3 parameters passed to it separated by commas. The parameters are explained in the first part of the script. The script will be interrupted if you manually change the light. I use it as my wake-up light but it stops if I turn the light off (i.e. if I decide to sleep in). You also need to set the dim level of the device to at least 1% first in your event before calling the script.

    Cheers
    Al
    Last edited by sparkman; May 20, 2016, 03:51 PM.
    HS 4.2.8.0: 2134 Devices 1252 Events
    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

    Comment


      #3
      Awesome. Thanks Al!
      -Tim

      HSPro - 3.XXX - Dell mini W7 x32
      Way2 Call
      Elk M1 Gold
      UPB HAI switches
      HAI RC2000 Thermostat

      Comment


        #4
        Al
        Would you please post an example of the proper syntax to pass the variables to the script.?
        many thanks
        Blair

        HomeSeer: HS3 Pro | Blue-Iris 4 on Windows10Pro
        | Devices: 832 | Events: 211 |
        Plug-Ins: Z-Wave | RFXCOM | UltraRachio3 | Sonos
        BLLAN | BLLOCK | NetCAM | Global Cache Pro | Blue-Iris4

        Comment


          #5
          Also check this out:

          http://board.homeseer.com/showthread.php?t=167926
          Originally posted by rprade
          There is no rhyme or reason to the anarchy a defective Z-Wave device can cause

          Comment


            #6
            Al
            Would you please post an example of the proper syntax to pass the variables to the script.?
            many thanks
            Blair

            HomeSeer: HS3 Pro | Blue-Iris 4 on Windows10Pro
            | Devices: 832 | Events: 211 |
            Plug-Ins: Z-Wave | RFXCOM | UltraRachio3 | Sonos
            BLLAN | BLLOCK | NetCAM | Global Cache Pro | Blue-Iris4

            Comment


              #7
              if the light is z-wave, and scene compatible...
              just make a z-wave scene containing the one light, with a 30 minute fade time.
              trigger it once, and forget it.

              also, if you then take manual control of the light, it just overrides the scene, and you don't have to worry about disabling the script.

              Comment


                #8
                Originally posted by BlairG View Post
                Al
                Would you please post an example of the proper syntax to pass the variables to the script.?
                many thanks
                Here you go:

                Click image for larger version

Name:	Capture.jpg
Views:	1
Size:	15.2 KB
ID:	1184780

                The first number is the reference ID of the device that you want to control.
                The second number is the max dim level you want the script to go to (60% in the example)
                The third number is the number of seconds between each increment in dim level (30 seconds in the example)
                Last edited by sparkman; May 20, 2016, 03:49 PM.
                HS 4.2.8.0: 2134 Devices 1252 Events
                Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

                Comment


                  #9
                  So silly question, could this be modified, or does someone else have a script to have the lights adjusted for dimness depending on current outside light conditions?

                  IE dimmer for evening if turned on, vs day would be brighter when turned on.

                  Comment


                    #10
                    Originally posted by waynehead99 View Post
                    So silly question, could this be modified, or does someone else have a script to have the lights adjusted for dimness depending on current outside light conditions?

                    IE dimmer for evening if turned on, vs day would be brighter when turned on.
                    Yes, could be done relatively easily. You could pass an extra parameter for the outside luminance device and then modify the max brightness value based on the value of the luminance device. Let me know if you need some help with that.

                    Cheers
                    Al
                    HS 4.2.8.0: 2134 Devices 1252 Events
                    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

                    Comment


                      #11
                      Al, that script does nothing for me. I get no error in the log. The event runs but nothing happens. Ideas?
                      Attached Files
                      Originally posted by rprade
                      There is no rhyme or reason to the anarchy a defective Z-Wave device can cause

                      Comment


                        #12
                        Originally posted by S-F View Post
                        Al, that script does nothing for me. I get no error in the log. The event runs but nothing happens. Ideas?

                        Sorry, forgot to mention that in my event I set the dim level to 1% first and then run the script. Can you try that and see if that works?
                        Last edited by sparkman; May 20, 2016, 03:50 PM.
                        HS 4.2.8.0: 2134 Devices 1252 Events
                        Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

                        Comment


                          #13
                          I was thinking the same thing Wayne. Al, AGAIN this is a great script and has lot of uses. Nice work.

                          Originally posted by waynehead99 View Post
                          So silly question, could this be modified, or does someone else have a script to have the lights adjusted for dimness depending on current outside light conditions?

                          IE dimmer for evening if turned on, vs day would be brighter when turned on.
                          Tom
                          baby steps...starting again with HS3
                          HS3Pro: Z-NET & 80 Z wave Devices,
                          HSTouch: 4 Joggler (Android Kitkat), 2 iPhone, 3 iPads
                          Whole House Audio: 5 SqueezePlay Jogglers w Bose Speakers
                          In The Works: 10 Cameras Geovision, new Adecmo/Envisalink Alarm, Arduinos
                          System: XP on Fanless Mini-ITX w/ SSD

                          Comment


                            #14
                            If you are using lights with a Hue Bridge, check out some of the scenes here:

                            http://labs.meethue.com/

                            Not a lot there but there are a couple pleasant good morning scenes.

                            Comment


                              #15
                              Originally posted by sparkman View Post
                              Sorry, forgot to mention that in my event I set the dim level to 1% first and then run the script. Can you try that and see if that works?

                              Yep. That did it. Thanks for this one Al. It's a lot less cumbersome than Moskus' script. Though his is great as well!
                              Originally posted by rprade
                              There is no rhyme or reason to the anarchy a defective Z-Wave device can cause

                              Comment

                              Working...
                              X