Announcement

Collapse
No announcement yet.

Sunrise Clock Scripting Troubles

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

  • Sunrise Clock Scripting Troubles

    I want to have a lamp (my wife's bedside light), come on slowly in the morning. Perhaps over a 30 to 45 minute period from 0 to 100% brightness. I know that this has been discussed many times, but after searching the board endlessly as well as much tweaking on my end, I still have a problem.

    I am trying to use this script:
    http://forums.homeseer.com/showthrea...=sunrise+clock

    However, I cannot get my lamp to come on, much less slowly come on. I am trying to use a standard X-10 (read: cheap) lamp module. Are they even compatible for this type of thing?

    I can post any/all of the script I'm trying to use, if it helps.

    Any help would be appreciated.

  • #2
    ob,
    Can you turn the light on using the HS interface?
    -Rupp
    sigpic

    Comment


    • #3
      Rupp,

      Yes I can.
      I am actually working with the script using a light that is right next to me. I'm too lazy to run over to the bedroom every time.

      Comment


      • #4
        What syntax did you put in the script to run field or the event you created.
        -Rupp
        sigpic

        Comment


        • #5
          Purely for testing purposes, in the script box I have:
          sunrise.txt ("solarclockstart", "A4;10;100;5;10")

          Comment


          • #6
            This is the full script I am trying to use:

            Option Explicit
            '=========================================================== ==============
            Sub Main()
            End Sub


            '=========================================================== ==============
            Sub solarclockstart (as_parameters)
            'Variables
            Dim larr_parameter
            Dim ls_device
            Dim li_start
            Dim li_end
            Dim li_step
            Dim li_minutes
            Dim li_seconds
            Dim lo_event
            Dim ls_eventName
            Dim ls_arguments

            '-----------------------------------------------------------------------
            'Initialization
            larr_parameter = Split (as_parameters, ";") 'Get all parameters

            ls_device = Trim (larr_parameter(0)) ' The device to be dimmed
            li_start = Trim (larr_parameter(1)) ' The starting light intensity
            li_end = Trim (larr_parameter(2)) ' The light intensity at end of process. Can be no more as 100 for absolute dim of 63 for extended dim.
            li_step = Trim (larr_parameter(3)) ' Amount by which the light intensity is increased with every step
            li_seconds = Trim (larr_parameter(4)) ' The time between two steps in minutes
            ls_eventName = "SolarClock"&ls_device ' A unique name for the event

            '-----------------------------------------------------------------------
            'Functionality

            If Sgn (li_end - li_start) <> Sgn (li_step) Then
            hs.writeLog "Error", "SolarClockStart: Multiple steps will not take startvalue past endvalue."
            Exit Sub
            End If
            If li_seconds <= 0 Then Exit Sub End If ' Make sure there is a reasonable interval

            li_minutes = Round (li_seconds / 60)
            li_seconds = li_seconds Mod 60

            hs.saveIniSetting ls_device, "start", li_start, "solarclock.ini" ' Save startvalue as current value (not stricly needed)
            hs.saveIniSetting ls_device, "current", li_start, "solarclock.ini" ' Save startvalue as current value
            hs.saveIniSetting ls_device, "endvalue", li_end, "solarclock.ini" ' Save endvalue
            ls_arguments = ls_device & ";" & li_step & ";" & li_end
            hs.NewRecurringEvent ls_eventName,10,1,1,1,1,1,1,1,"",FALSE,"sunrise.txt (""solarclockrun"", """&ls_arguments&""")","Temp"

            Set lo_event = hs.getEventEx (ls_eventName) ' Get a reference to the object
            lo_event.rec_mins = li_minutes
            lo_event.rec_secs = li_seconds
            lo_event.misc = lo_event.misc OR &H4000 ' Disable logging
            hs.writeLog "SolarClock", "Light(s) "&ls_device&" will be illuminated from "&li_start&" to "&li_end&" in "&Round((li_end - li_start)/li_step)&" steps of "&(li_minutes * 60)+li_seconds&" sec for every step."

            end sub 'end sub solarclockstart (...)



            '=========================================================== ==============
            Sub solarclockrun (as_parameters)
            'Variables
            Dim larr_parameter ' The parameters of the function
            Dim ls_device ' The x10-address of the device
            Dim li_start ' Starting light intensity
            Dim li_end ' Maximum light intensity
            Dim li_step ' The increase in light intensity on every step
            Dim ls_eventname ' The name of the event
            Dim lo_event

            dim li_current ' Current light intensity

            '-----------------------------------------------------------------------------
            'Initialisation
            larr_parameter = Split (as_parameters, ";") ' Get all parameters

            ls_device = Trim (larr_parameter(0)) ' The device to be dimmed
            li_step = Trim (larr_parameter(1)) ' Amount by which the light intensity is increased with every step
            li_end = Trim (larr_parameter(2)) ' The light intensity at end of process. Can be no more as 100 for absolute dim of 63 for extended dim.
            li_start = Int(hs.getIniSetting (ls_device, "current", "0", "solarclock.ini"))
            li_current= hs.DeviceValue (ls_device) ' Get the current light intensity in percentages
            ls_eventName = "SolarClock"&ls_device

            '-----------------------------------------------------------------------------
            'Process
            'li_current = Round (li_current*0.63) ' Calculate current light intesity in extended values
            li_start = li_start + li_step

            'Delete event if endvalue is reached.
            If Sgn (li_start - li_end) = Sgn (li_step) Then
            ls_eventName = "SolarClock"&ls_device ' A unique name for the event
            hs.deleteEvent ls_eventname
            hs.clearIniSection ls_device, "solarclock.ini"
            Exit Sub
            End If

            'Increase the light intensity
            If (Sgn (li_start - li_current) = Sgn (li_step)) AND (abs(li_start - li_current) <= Abs(li_step)) Then
            'hs.ExecX10 ls_device, "extended", li_start, 49 ' Set the lights to the desired light intensity
            hs.ExecX10 ls_device, "Dimab", li_start, 0 ' Alternative using presetdim
            'hs.ExecX10 ls_device, "Dim", li_start
            End If

            hs.saveIniSetting ls_device, "current", li_start, "solarclock.ini" ' Save startvalue as current value

            End Sub

            Comment


            • #7
              Dim first

              In order for me to make any sunrise script work with my "cheap" x10 modules, I had to create a goodnight script that, among other things, dimmed all the lights involved in the sunrise clock to 0%. It makes for a nice fade to black at night :-), and allows for the lights to slowly "bright" in the morning using whatever script you choose, assuming you have no events that will turn the lights to "off" before the sunrise script runs. Hope this helps with your particular problem.

              Comment


              • #8
                outrbanx,
                I was so intent on looking at the code that I didn't even think about what you were doing. The only way you can use this script with a cheap X10 module would be as a sunset emulator. The cheapy X10 modules only turn on to full and then dim down. To use this script as a sunrise emulator you will need a 2 way X10 lamp module or any other switch that works with preset dims.

                Something like these:
                http://www.smarthome.com/2000s.html
                -Rupp
                sigpic

                Comment


                • #9
                  Yep. I knew that I would have to deal with the full on then dim to zero problem with this module. I'm willing to deal with that for the time being, even if I wrote a script to dim it to zero to make this work.

                  I was going to upgrade the module as soon as I could to make it as efficient as possible. But even with that factor involved, I still can't get the script to work.

                  Provided that this is still possible with the cheap ones, coupled with my limited scripting knowledge, I'm thinking that there is some variable within the script that I do not have set correctly.

                  Comment


                  • #10
                    Are you getting any errors in the HS log? Is it creating the event?
                    -Rupp
                    sigpic

                    Comment


                    • #11
                      The event is created and the log states "Light(s) A4 will be illuminated from 10 to 100 in 18 steps of 10 sec for every step."

                      After about 2 minutes or so, the event (solar clock) goes away.

                      The light does nothing.

                      Comment


                      • #12
                        Try just 2 steps at first. The 18 steps may be to granular for the module.
                        -Rupp
                        sigpic

                        Comment


                        • #13
                          Not even a blink.

                          Comment


                          • #14
                            Can you repost the entire script and I will try it here. I was able to get to the old link yesterday but not today.
                            -Rupp
                            sigpic

                            Comment


                            • #15
                              Here ya go:
                              http://forums.homeseer.com/showthrea...=sunrise+clock

                              Comment

                              Working...
                              X