Announcement

Collapse
No announcement yet.

Script for "Sunrise clock" that works with HS 2.2?

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

  • #16
    Originally posted by Moskus View Post
    But this is directly from the HS Status screen. I would have thought that HS chose Bright automaticly when the dim is 10% and I select 20% from the combobox. Or perhaps I'm missing an option?
    On the device status screen, HomeSeer goes by the device's configuration options, which are determined by the device TYPE. You can change the device's device type in the device properties, and you can view the device type's settings or create new device types on the device types tab of the configuration screens.

    Originally posted by Moskus View Post
    That would do the trick too, I guess. But I would prefer a method that didn't create a lot of unnessesary events...
    If the events are accomplishing what you want, then I don't understand what would make any one of those events unnecessary??? I have 718 events and at least 95 scripts. Other than a dozen or so of those events that are disabled (they remain as examples, nostalgia, or because I will use them again someday) -- all of them are necessary!
    Regards,

    Rick Tinker (a.k.a. "Tink")

    Comment


    • #17
      Originally posted by Rick Tinker View Post
      On the device status screen, HomeSeer goes by the device's configuration options, which are determined by the device TYPE. You can change the device's device type in the device properties, and you can view the device type's settings or create new device types on the device types tab of the configuration screens.
      Aha! So there's different "Lamp modules"...
      I'm currently using Marimteks LM12(G) plugin (lamp) module and some S-line micro modules (like S2264E) for lamps. What should these be set as?

      Originally posted by Rick Tinker View Post
      If the events are accomplishing what you want, then I don't understand what would make any one of those events unnecessary??? I have 718 events and at least 95 scripts. Other than a dozen or so of those events that are disabled (they remain as examples, nostalgia, or because I will use them again someday) -- all of them are necessary!
      Well, I guess it depends on your of "necessary". If I have a script that can achieve the same as 30 events, then I would prefer the script over the 30 events, just because it's easier to maintain.

      You've been a great help!



      fran_joel, I'm currently testing your idea. It seems to work fine, I will no for sure tomorrow morning...
      HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
      Running on Windows 10 (64) virtualized
      on ESXi (Fujitsu Primergy TX150 S8).
      WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

      Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

      Comment


      • #18
        Originally posted by Moskus View Post
        I'm currently using Marimteks LM12(G) plugin (lamp) module and some S-line micro modules (like S2264E) for lamps. What should these be set as?
        Yikes! Unfortunately, those models are as foreign to me as my mother-in-law's native tongue! I can't help you with that, but I'm sure somebody else here will be able to.

        Originally posted by Moskus View Post
        Well, I guess it depends on your of "necessary". If I have a script that can achieve the same as 30 events, then I would prefer the script over the 30 events, just because it's easier to maintain.
        Ah, but if you have little experience with scripting, then a script is not really easier to maintain is it? I was shooting for what you would be most comfortable with. If you prefer a script, I can do that too, but these days I only do VB.NET scripts.

        Glad you (provisionally) got it working - with the help of the others who understand your modules, you will probably learn a lot about those devices working with HomeSeer and so your automation setup will probably undergo a few changes in the next weeks.
        Regards,

        Rick Tinker (a.k.a. "Tink")

        Comment


        • #19
          Originally posted by Moskus View Post
          I want a light to slowly bright from 0% to 100% during 30 minute.
          Ok, so when it starts to get light you wish to start brightening the lights basically in time with the sun rising! Odd, but everyone to there own.

          One way you could accomplish this, even in the evening when it starts to get dark, is by one simple script which writes events using the built in HS sunrise/set facilitie.

          The script is triggered by whatever, surise, sunset or flicking a switch. The events are set to trigger some time after the script run and delete after excicution.

          An example of the script is
          Code:
          Sub Main
          dim T
          T=dateadd ("N",+2,NOW)
          hs.NewTimeEvent "Lights1",T,"",1,1,1,1,1,1,1,"",1,"Lights Up1.txt","System"
          T=dateadd ("N",+4,NOW)
          hs.NewTimeEvent "Lights2",T,"",1,1,1,1,1,1,1,"",1,"Lights Up2.txt","System"
          End Sub
          What that script will do is create 2 events timed to trigger 2 mins after it was run and 4 mins after it was run. The events it has created run the script (which you must wright, something like hs.device "H1" bright, 10)"Lights Up1" after 2 mins then "Lights Up2" after 4 mins. You can duplicate as many scripts to run under the events as you wish.

          I use this princaple a lot for delaying lights going off to allow me to leave the room before it fades into darkness. It saves tying up mem with delayed events or using the Time delay call.

          I have written this very quickly, there may be errors in the code, if you are interested, try it and it does not work post a message and I'll check the code, but looking at it, it should work, probably the explanation thats out.
          sigpic
          A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"
          HomeSeer 3 V 3.0.0.318 with ALEXA (AKA Amazon Echo)
          BL Radar V2.0.217; BLRF V2.0.85.0; HS Touch V3.0.0.1034 X10 V3.0.0.42; PHLocation V3.0.0.38; Zwave V3.0.1.110; X10 V3.0.0.42
          BLBackup V2.0.39;ImperiHome3.0.0.20 All on Windows XP Pro

          Comment


          • #20
            Originally posted by Rick Tinker View Post
            Yikes! Unfortunately, those models are as foreign to me as my mother-in-law's native tongue! I can't help you with that, but I'm sure somebody else here will be able to.
            Well, thanks anyway! It was worth a try.

            Originally posted by Rick Tinker View Post
            Ah, but if you have little experience with scripting, then a script is not really easier to maintain is it? I was shooting for what you would be most comfortable with. If you prefer a script, I can do that too, but these days I only do VB.NET scripts.
            I'm not used to scripting (or at least, I don't know all the HS functions yet), but I'm very comfortable with VB.NET, so reading code is easier for me than looking through a bunch of events.

            Looking through the event list would be easier in a tree view, like a Windows browser or something.




            Originally posted by Rick Tinker View Post
            Glad you (provisionally) got it working - with the help of the others who understand your modules, you will probably learn a lot about those devices working with HomeSeer and so your automation setup will probably undergo a few changes in the next weeks.
            Yeah, you're probably right. I'll learn as I work.


            Originally posted by Gogs
            Ok, so when it starts to get light you wish to start brightening the lights basically in time with the sun rising! Odd, but everyone to there own.
            It's supposed to help me get up in the morning. The sun does not rise until 9 AM, and I need to get up before that...

            If I understand your scripts/code correctly, I think I'm already doing what you're suggesting, look at frank_joels sollution.
            HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
            Running on Windows 10 (64) virtualized
            on ESXi (Fujitsu Primergy TX150 S8).
            WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

            Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

            Comment


            • #21
              Originally posted by Moskus View Post
              Well, thanks anyway! It was worth a try. ..................If I understand your scripts/code correctly, I think I'm already doing what you're suggesting, look at frank_joels sollution.
              Not exactly, if I have read the same post by Frank as you have.

              I take it you wish your, lets say bedroom lghts to slowly bright from zero to full on, or ramp, over a period of 30 mins?

              This is very simple and many ways to do it, DEPENDING on the module that is controlling the lamp.

              Use the script I posted above, you could have a X10 switch to cancel the operation if you wish,

              You have given me an idea for my bedroom.

              I'll put it into my system tomorrow and if it works post the way I did it.
              sigpic
              A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"
              HomeSeer 3 V 3.0.0.318 with ALEXA (AKA Amazon Echo)
              BL Radar V2.0.217; BLRF V2.0.85.0; HS Touch V3.0.0.1034 X10 V3.0.0.42; PHLocation V3.0.0.38; Zwave V3.0.1.110; X10 V3.0.0.42
              BLBackup V2.0.39;ImperiHome3.0.0.20 All on Windows XP Pro

              Comment


              • #22
                I tried my solution with 2 events and 1 script for the sake of it last night and it works...
                (good to know I didn't make a fool of myself... )

                The only thing is that the "time" variable can't be set to 0 to start with, as the first time delayed event will not actually run and Homeseer will eventually have to remove it while doing its housecleaning chores...

                So "time" has to be set to something larger than zero to start with. I've corrected the initial post accordingly.

                Joel

                Comment


                • #23
                  Originally posted by fran_joel View Post
                  I tried my solution with 2 events and 1 script for the sake of it last night and it works...
                  (good to know I didn't make a fool of myself... )

                  The only thing is that the "time" variable can't be set to 0 to start with, as the first time delayed event will not actually run and HomeSeer will eventually have to remove it while doing its housecleaning chores...

                  So "time" has to be set to something larger than zero to start with. I've corrected the initial post accordingly.

                  Joel
                  Explain "time".

                  What is, and what are you trying to to with time?

                  Us mortals cannot interfere with Time. Or at least we do so at our own risk.

                  Exactly what do you wish to accomplish?

                  Let us know, you may get the solution.
                  sigpic
                  A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"
                  HomeSeer 3 V 3.0.0.318 with ALEXA (AKA Amazon Echo)
                  BL Radar V2.0.217; BLRF V2.0.85.0; HS Touch V3.0.0.1034 X10 V3.0.0.42; PHLocation V3.0.0.38; Zwave V3.0.1.110; X10 V3.0.0.42
                  BLBackup V2.0.39;ImperiHome3.0.0.20 All on Windows XP Pro

                  Comment


                  • #24
                    Originally posted by Gogs View Post
                    Explain "time".

                    What is, and what are you trying to to with time?

                    Us mortals cannot interfere with Time. Or at least we do so at our own risk.

                    Exactly what do you wish to accomplish?

                    Let us know, you may get the solution.
                    Sorry Gogs maybe you did not read my earlier post...

                    I am referring to the small script I wrote earlier in this discussion where "time" is a mere variable

                    Joel

                    Comment


                    • #25
                      Here's the VB.NET equivalent of the script:
                      Code:
                      Sub Main(parm as object)
                      
                      Dim time as Integer = 0     'Initial delay
                      Dim uptime as Integer = 180 'The delay between each trigger in seconds
                      
                      for i as Integer = 0 to 10
                         hs.DelayTrigger (time, "Your_event_that_brights_the_light(s)")
                         time += uptime
                      next
                      
                      End Sub
                      HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
                      Running on Windows 10 (64) virtualized
                      on ESXi (Fujitsu Primergy TX150 S8).
                      WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

                      Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

                      Comment


                      • #26
                        So let me get this straight. All I do is create an event to fire at a certain time of day that launches the above script? And if I wanted the light to increase in increments of 1% I just change "for i as Integer = 0 - 10" to "for i as Integer = 0 - 1" and "Dim uptime as Integer = 180" to "Dim uptime as Integer = 18"? How do I specify the device?
                        Originally posted by rprade
                        There is no rhyme or reason to the anarchy a defective Z-Wave device can cause

                        Comment


                        • #27
                          BUMP:

                          Anyone? I'm going to be putting HomeSeer in production in the next week but I have to get this working first. No way am I going to keep Vera for this one task and I'll be damned if I use an alarm clock ever again. The batteries on that thing died several years ago. I don't even know where it is. Or care for that matter.
                          Originally posted by rprade
                          There is no rhyme or reason to the anarchy a defective Z-Wave device can cause

                          Comment


                          • #28
                            In the above script it's "Your_event_that_brights_the_light(s)") that controls the device.

                            It may be useful to create a virtual device so that when triggered it knows what the current state is.
                            sigpic
                            A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"
                            HomeSeer 3 V 3.0.0.318 with ALEXA (AKA Amazon Echo)
                            BL Radar V2.0.217; BLRF V2.0.85.0; HS Touch V3.0.0.1034 X10 V3.0.0.42; PHLocation V3.0.0.38; Zwave V3.0.1.110; X10 V3.0.0.42
                            BLBackup V2.0.39;ImperiHome3.0.0.20 All on Windows XP Pro

                            Comment


                            • #29
                              Virtual device, yes this is how it's done in vera. I will research virtual devices and report back here if I hit a snag.

                              Thanks for the help.
                              Last edited by S-F; September 8th, 2012, 12:52 PM.
                              Originally posted by rprade
                              There is no rhyme or reason to the anarchy a defective Z-Wave device can cause

                              Comment


                              • #30
                                S-F, thank you for reminding me about this. I got your email, but have been too busy with my new house and my new setup, I apologize.

                                This is a very old thread, and I've solved this years ago:

                                Code:
                                    Private WithEvents tmr As Timers.Timer
                                    Private devMaster As String = "C20"
                                    Private counter As Single = 1
                                    Private bolIsRunning As Boolean = False
                                    Private _start As Integer = 20
                                    Private _stop As Integer = 100 'Nexa preset dim has 32 steps. Regular Z-wave dim usually has 100 steps. X10 often has 10 steps.
                                
                                    Public Sub Main(ByVal p_params As String)
                                        If p_params = "start" Then
                                            Start()
                                        Else
                                            If bolIsRunning Then Stopp()
                                        End If
                                    End Sub
                                
                                    Public Sub Start()
                                        counter = _start
                                
                                        tmr = New Timers.Timer
                                        tmr.Interval = CInt(1000 * 60 * 30 / (_stop - _start)) '30 minutes / steps * 60 seconds pr minute * 1000 milliseconds pr second
                                        tmr.AutoReset = True
                                
                                        tmr.Start()
                                
                                        bolIsRunning = True
                                        hs.WriteLog("Alarm Sunshine", "Good morning sunshine! Timer has started.")
                                        IncreaseLight()
                                    End Sub
                                
                                    Public Sub Stopp()
                                        tmr.Stop()
                                        tmr.Close()
                                        tmr.Dispose()
                                        tmr = Nothing
                                
                                        bolIsRunning = False
                                        hs.WriteLog("Alarm Sunshine", "Timer has been stopped")
                                    End Sub
                                
                                    Public Sub Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles tmr.Elapsed
                                        IncreaseLight()
                                    End Sub
                                
                                    Private Sub IncreaseLight()
                                        'For Nexa dimmer
                                        'Dim dimlevel As Integer = GetDimlevel(counter)
                                        'hs.ExecX10NoLog(devMaster, "preset dim", dimlevel, 0)
                                        'hs.WriteLog("Alarm Sunshine", "Light has been increased (time: " & counter & " - level: " & dimlevel & ")")
                                
                                        'For Z-wave dimmer
                                        hs.Transmit(devMaster, "dim", counter, 0)
                                        hs.WriteLog("Alarm Sunshine", "Light has been increased (dim level = " & counter & "%)")
                                
                                        counter += 1
                                
                                        'For Nexa dimmer
                                        'If dimlevel >= _stop Then
                                        '    bolIsRunning = False
                                        '    Stopp()
                                        'End If
                                
                                
                                        'For Z-wave dimmer
                                        If counter >= _stop Then
                                            bolIsRunning = False
                                            Stopp()
                                        End If
                                
                                    End Sub
                                
                                    Private Function GetDimlevel(ByVal time As Integer)
                                        Return Math.Ceiling(0.00019 * time ^ 4 - 0.0081 * time ^ 3 + 0.1197 * time ^ 2 - 0.4465 * time + 1)
                                    End Function
                                You might want to adjust the _start dim level and and the _stop dim level to your liking.
                                HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
                                Running on Windows 10 (64) virtualized
                                on ESXi (Fujitsu Primergy TX150 S8).
                                WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

                                Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

                                Comment

                                Working...
                                X