Announcement

Collapse
No announcement yet.

Time variable for Zee alarm clock

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

    Time variable for Zee alarm clock

    Dear HomeSeer Experts,
    I have set up an event on the Zee that starts slowly to increase the light level of my bedroom bedside lamp. I am using this as a natural light alarm clock in the morning.


    Is there a way where I could use a variable to trigger an event on the HomeTroller Zee? I could change this variable by sending a mail to the Zee. But I did not find such a variable for a specific time without a date, e.g. 7:30 am.
    Please advice.
    Best regards,
    Alex

    #2
    Create a manual event with the wait command set light 15% wait 15 seconds set light 20% etc. Then call that event as a second event at the time you want it to go off.

    Using a light alarm is a great idea - I like the idea of gradually adding lux.
    Last edited by wkomorow; January 24, 2015, 05:54 PM. Reason: spelling/grammar

    Comment


      #3
      Thank you. Great idea.

      But how would you call the event at a specific time that I can change without to change the event code?

      Comment


        #4
        Originally posted by Alzi View Post
        Thank you. Great idea.

        But how would you call the event at a specific time that I can change without to change the event code?
        In the first event, it is a manually triggered with no time set to start. You just use the wait command to create the gradually increasing luminance.

        Then you create an event for the time, which calls that original event. Rhe original event has only relative time (through wait) and not an absolute time, so there is no need to modify the code.

        Comment


          #5
          Using the wait command inside the first event is clear. A great idea and I will use it.

          What I still miss is how I initiate the 2nd event at a specific time that I can easily change. So that at the evening I decide to start the event at 7 am next morning but the following day I decide to start the event at 8 am in the morning.

          I can set the event to start every day at 7 am. This is clear and works fine. But if I want to adjust this to lets say 8 am spontaneously I have to open the event and change the time manually to 8 am.

          My question is if there is a way I could use a "wake up" variable that I can set e.g. by email or by the UI. I could than adjust the wake up time for the next day easily

          Would be great if you could help.
          I appreciate the support!

          Comment


            #6
            Yes there is no easy way to set time of the event thru out-of-the-box HS Touch UI on android/iOS. One has to use web interface which is not very useful for most folks in your household. I really hope HS folks will wake up one day and give us virtual alarm clock that works out of the box with HS Touch.

            For now I did this:

            http://board.homeseer.com/showthread.php?t=157454

            It requires few steps but you can setup as many clocks as you want and use stock HS Touch to set the time.

            Comment


              #7
              Excellent :-) Thank you.

              Unfortunately it is not working on the Zee.

              The event is called:

              Running script in background: /usr/local/HomeSeer/scripts/wake_up_zora.vb("Main","A20,Wake up everyone event,15,Wake up everyone event early")

              But than it shows a error 3:

              Running script /usr/local/HomeSeer/scripts/wake_up_zora.vb :Exception has been thrown by the target of an invocation.->Does entry point Main exist in script? at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0 at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in :0 at A.c17b105f989efe61e5979e67bec1ef734.cffd66cb0782c50126727e3f a75582d7a () [0x00000] in :0

              Comment


                #8
                Hmm seems like you didn't copy entire script for some reason - does it have this at the top of the file:

                Sub Main(ByVal Parm As Object)

                ???

                Comment


                  #9
                  Thanks for the quick reply.

                  The script is downloaded and directly uploaded without any modification.
                  Please find attached a screenshot of the Zee event that is calling the script.

                  Is it possible that it requires modifications for the Hometroller Zee due to Linux?

                  Once again, thank you for the help.
                  Attached Files

                  Comment


                    #10
                    Try removing the word Main from the sub or fiction field in the event. It will call Main by default so does not need to be entered. I've seen that issue with some of my events before and that's resolved it for me. Not sure why it works most of the time, but not consistently.

                    Cheers
                    Al
                    HS 3.0.0.548: 1990 Devices 1172 Events
                    Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

                    Comment


                      #11
                      Thank you very much :-)

                      Still an error message, even different at this time.

                      Running script /usr/local/HomeSeer/scripts/wake_up_zora.vb :Exception has been thrown by the target of an invocation.Cast from 'String' to type 'Integer' is not valid.

                      Any idea what this means?



                      The events before are recorded as:

                      Feb-05 1:22:41 PM Event Running script in background: /usr/local/HomeSeer/scripts/wake_up_zora.vb


                      Feb-05 1:22:41 PM Event Event Trigger "Wake_up_everyone_event_early Wake up everyone set event"

                      Comment


                        #12
                        Well, that means the script is actually running but failing due to a value not being able to be converted from a string to an integer. Maybe post a screen shot of the Device Value tab of your A20 device that you created.

                        Cheers
                        Al
                        HS 3.0.0.548: 1990 Devices 1172 Events
                        Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

                        Comment


                          #13
                          Sorry for the delay.
                          Attached the images as requested.
                          Would be great if you could help.
                          Attached Files

                          Comment


                            #14
                            You need to use the Device Reference ID to call the script. In your case that's 14 not A20. Change the parameters in your event that calls the script and replace A20 with 14.

                            Cheers
                            Al
                            HS 3.0.0.548: 1990 Devices 1172 Events
                            Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

                            Comment


                              #15
                              Thank you Al.

                              We are getting closer to a solution. The log shows that the wake-up time is set. Great. Thank you :-)

                              Unfortunately it still displays a small error message in the log:

                              Running script /usr/local/HomeSeer/scripts/wake_up_zora.vb :Exception has been thrown by the target of an invocation.Cannot find the requested class member.

                              Attached the screenshots of the log and the event that calls below script that I did copy 1:1 (moved the file) from the great post of Person: http://board.homeseer.com/showthread.php?t=157454

                              Any advise how to avoid the invocation?

                              Best regards and thank you for the help,
                              Alex


                              --------------------------------------------------------



                              Sub Main(ByVal Parm As Object)
                              ' This script expects input in the following format
                              '
                              ' "Alarm device ID,Wake up event name,Early event offset in minutes,Early wake up event name"
                              ' E.g.
                              ' wake_up_zora.vb("Main","A20,Wake_up_everyone event,23,Wake_up_everyone event early")
                              '
                              ' Early offset in minutes must be less than 720 (12 hours)
                              ' If early offset is set to zero then only wake up event exists. Put zero for offset *and*
                              ' early event.

                              Dim Parameters () As String
                              Dim WakeUpEvent, WakeUpEventEarly As String
                              Dim EarlyOffset, AlarmClockDevice
                              Dim WakeUpTime
                              Dim Minutes, Hours, Minutes2, Hours2
                              Dim MinutesEarly, HoursEarly

                              Dim MessageID As String
                              MessageID = "INFO: WakeUpZora"

                              ' Split input on comma
                              '
                              Parameters = Split(Parm.ToString,",")
                              AlarmClockDevice = Parameters(0)
                              WakeUpEvent = Parameters(1)
                              EarlyOffset = Parameters(2)
                              WakeUpEventEarly = Parameters(3)

                              ' Get the time set from the clock device
                              '
                              WakeUpTime = hs.DeviceValue(AlarmClockDevice)
                              hs.WriteLog (MessageID, "Wake up time is set to " & WakeUpTime)

                              ' If real wake up time provided (alarm enabled)
                              ' then setup appropriate events
                              '
                              If WakeUpTime <= 2359 Then

                              ' Grab hours and minutes from the clock value
                              '
                              WakeUpTime = WakeUpTime / 100
                              Hours = Math.Floor(WakeUpTime)
                              Minutes = 100*(WakeUpTime - Math.Floor(WakeUpTime))

                              ' Set WakeUpTime for main event
                              '
                              Call SetEventTime (Hours, Minutes, WakeUpEvent, MessageID)

                              ' Error out on offset > 720 (12 hours) and clamp at 1 hours
                              '
                              If EarlyOffset < 0 OR EarlyOffset > 720
                              hs.WriteLog (MessageID, "ERROR: Early Offset Out of 0-720 BOUNDS!: " & EarlyOffset)
                              hs.WriteLog (MessageID, "Forcing early offset to 1 hour")
                              EarlyOffset = 60
                              End If

                              ' Calculate hours and minutes to adjust
                              '
                              MinutesEarly = (EarlyOffset Mod 60)
                              HoursEarly = (EarlyOffset - MinutesEarly)/60

                              ' Subtract Minutes/Hours Early, adjust if negative
                              '
                              Hours2 = Hours - HoursEarly
                              Minutes2 = Minutes - MinutesEarly

                              If Minutes2 < 0 Then
                              Minutes2 = Minutes2 + 60
                              Hours2 = Hours2 - 1
                              End If

                              If Hours2 < 0 Then
                              Hours2 = Hours2 + 24
                              End If

                              ' Adjust and set WakeUpTime for early event
                              '
                              If EarlyOffset = 0 Then
                              ' No early event for this clock defined
                              Else
                              Call SetEventTime (Hours2, Minutes2, WakeUpEventEarly, MessageID)
                              End If

                              Else If WakeUpTime = 9999 Then
                              ' Disable events since alarm is turned off
                              '
                              hs.WriteLog (MessageID, "Disabling WakeUp Events")
                              hs.DisableEvent(WakeUpEvent)

                              If EarlyOffset = 0 Then
                              ' No early event for this clock defined
                              Else
                              hs.DisableEvent(WakeUpEventEarly)
                              End If

                              Else
                              hs.WriteLog (MessageID, "Time set is OUT OF BOUNDS!:" & WakeUpTime)
                              End If

                              End Sub
                              Sub SetEventTime (ByVal Hours As Integer, ByVal Minutes As Integer, ByVal WakeUpEvent As String, ByVal MessageID As String)
                              Dim IRef
                              Dim AM_PM As String
                              Dim FinalWakeUpTime As String

                              ' Detect if we need to use 24 hour or AM/PM time format
                              '
                              If Now.ToString.Contains("AM") OR Now.ToString.Contains("PM") Then

                              ' - if <1200 -> this is AM, otherwise PM
                              '
                              If Hours < 12 Then
                              AM_PM = "AM"
                              ElseIf Hours <= 23 Then
                              Hours = Hours - 12
                              AM_PM = "PM"
                              Else
                              hs.WriteLog (MessageID, "Hours set if OUT OF BOUNDS!: " & Hours)
                              End If

                              ' When time is 00:00 or 12:00 the AM/PM scheme
                              ' requires making it 12AM/12PM so add 12
                              ' if hours < 1
                              '
                              If Hours = 0 Then
                              Hours = Hours + 12
                              End If
                              FinalWakeUpTime = String.Concat(Hours, ":", Minutes, " ", AM_PM)
                              Else
                              FinalWakeUpTime = String.Concat(Hours, ":", Minutes)
                              End If

                              hs.EnableEvent(WakeUpEvent)
                              hs.WriteLog (MessageID, "Wake Up Time for " & WakeUpEvent & " event is set to: " & FinalWakeUpTime)
                              IRef = hs.GetEventEx(WakeUpEvent)
                              IRef.ev_time = FinalWakeUpTime

                              End Sub
                              Attached Files

                              Comment

                              Working...
                              X